Repository navigation
fix(logservice): preserve HAKeeper ID batch boundaries - #25911
mergify[bot] merged 3 commits into
Conversation
Qodo reviews are paused for this user.Troubleshooting steps vary by plan Learn more → On a Teams plan? Using GitHub Enterprise Server, GitLab Self-Managed, or Bitbucket Data Center? |
### Root cause `TestJsonMergePatchWrapperAllocationsDoNotScaleWithRows` measures the complete 8192-row JSON merge path with `testing.AllocsPerRun(3)`, even though its asserted invariant is wrapper allocation behavior. Under `-race`, that path also executes instrumented and race-build-only vector operations, so process-wide allocation deltas outside the intended invariant can be charged to the test. The same package source passed the Ubuntu/x86 race UT in #25728, then failed an unrelated PR in #25911 with `one=1, many=45`. #25911 only changes the HAKeeper client and its tests, which run in a separate package test binary. ### Fix Move the allocation-statistics-only test unchanged into a `!race` test file. This keeps: - the 1-row versus 8192-row allocation regression assertion in non-race builds; - all JSON merge functional tests in both race and non-race builds; - production code and JSON merge behavior unchanged. ### Validation ```text .agents/skills/mo-dev/scripts/mo-cgo-test -v -count=100 -timeout=10m \ -run '^TestJsonMergePatchWrapperAllocationsDoNotScaleWithRows$' \ ./pkg/sql/plan/function .agents/skills/mo-dev/scripts/mo-cgo-test -race -count=20 -timeout=10m \ -run '^TestJsonMerge($|DepthValidation$)' \ ./pkg/sql/plan/function .agents/skills/mo-dev/scripts/mo-cgo-test -count=20 -timeout=10m \ -run '^TestJsonMerge($|DepthValidation$|PatchWrapperAllocationsDoNotScaleWithRows$)' \ ./pkg/sql/plan/function .agents/skills/mo-dev/scripts/mo-cgo-test -count=1 -timeout=20m \ ./pkg/sql/plan/function .agents/skills/mo-dev/scripts/mo-cgo-test -race -count=1 -timeout=30m \ ./pkg/sql/plan/function ``` The race-built test list was also checked to confirm that only the allocation-statistics test is excluded. Approved by: @XuPeng-SH
gouhongshen
left a comment
There was a problem hiding this comment.
Codex automated review
The inclusive cache invariant matches HAKeeper’s allocation semantics for shared and keyed IDs, preserves batch-one uniqueness, and rejects keyed zero-sized batches before RPC. No correctness, compatibility, concurrency, resource, performance, or test-coverage regressions found. CI unit tests passed; local focused tests were blocked by missing prebuilt CGo artifacts.
|
Queued — the merge queue status continues in this comment ↓. |
Merge Queue Status
This pull request spent 2 hours 48 minutes 59 seconds in the queue, with no time running CI. ReasonThe pull request can't be updated
HintYou should update or rebase your pull request manually. If you do, this pull request will automatically be requeued once the queue conditions match again. Requeued — the merge queue status continues in this comment ↓. |
XuPeng-SH
left a comment
There was a problem hiding this comment.
Reviewed the allocator boundary fix and its full functional closure. The inclusive cache invariant is correct for shared and keyed allocations, zero-sized keyed batches are rejected before RPC, and focused/race/full-package verification passed. No merge-blocking findings.
Merge Queue Status
This pull request spent 1 hour 41 minutes 30 seconds in the queue, including 1 hour 5 minutes 42 seconds running CI. Required conditions to merge
|
…n#25915) ### Root cause `TestJsonMergePatchWrapperAllocationsDoNotScaleWithRows` measures the complete 8192-row JSON merge path with `testing.AllocsPerRun(3)`, even though its asserted invariant is wrapper allocation behavior. Under `-race`, that path also executes instrumented and race-build-only vector operations, so process-wide allocation deltas outside the intended invariant can be charged to the test. The same package source passed the Ubuntu/x86 race UT in matrixorigin#25728, then failed an unrelated PR in matrixorigin#25911 with `one=1, many=45`. matrixorigin#25911 only changes the HAKeeper client and its tests, which run in a separate package test binary. ### Fix Move the allocation-statistics-only test unchanged into a `!race` test file. This keeps: - the 1-row versus 8192-row allocation regression assertion in non-race builds; - all JSON merge functional tests in both race and non-race builds; - production code and JSON merge behavior unchanged. ### Validation ```text .agents/skills/mo-dev/scripts/mo-cgo-test -v -count=100 -timeout=10m \ -run '^TestJsonMergePatchWrapperAllocationsDoNotScaleWithRows$' \ ./pkg/sql/plan/function .agents/skills/mo-dev/scripts/mo-cgo-test -race -count=20 -timeout=10m \ -run '^TestJsonMerge($|DepthValidation$)' \ ./pkg/sql/plan/function .agents/skills/mo-dev/scripts/mo-cgo-test -count=20 -timeout=10m \ -run '^TestJsonMerge($|DepthValidation$|PatchWrapperAllocationsDoNotScaleWithRows$)' \ ./pkg/sql/plan/function .agents/skills/mo-dev/scripts/mo-cgo-test -count=1 -timeout=20m \ ./pkg/sql/plan/function .agents/skills/mo-dev/scripts/mo-cgo-test -race -count=1 -timeout=30m \ ./pkg/sql/plan/function ``` The race-built test list was also checked to confirm that only the allocation-statistics test is excluded. Approved by: @XuPeng-SH
…n#25915) ### Root cause `TestJsonMergePatchWrapperAllocationsDoNotScaleWithRows` measures the complete 8192-row JSON merge path with `testing.AllocsPerRun(3)`, even though its asserted invariant is wrapper allocation behavior. Under `-race`, that path also executes instrumented and race-build-only vector operations, so process-wide allocation deltas outside the intended invariant can be charged to the test. The same package source passed the Ubuntu/x86 race UT in matrixorigin#25728, then failed an unrelated PR in matrixorigin#25911 with `one=1, many=45`. matrixorigin#25911 only changes the HAKeeper client and its tests, which run in a separate package test binary. ### Fix Move the allocation-statistics-only test unchanged into a `!race` test file. This keeps: - the 1-row versus 8192-row allocation regression assertion in non-race builds; - all JSON merge functional tests in both race and non-race builds; - production code and JSON merge behavior unchanged. ### Validation ```text .agents/skills/mo-dev/scripts/mo-cgo-test -v -count=100 -timeout=10m \ -run '^TestJsonMergePatchWrapperAllocationsDoNotScaleWithRows$' \ ./pkg/sql/plan/function .agents/skills/mo-dev/scripts/mo-cgo-test -race -count=20 -timeout=10m \ -run '^TestJsonMerge($|DepthValidation$)' \ ./pkg/sql/plan/function .agents/skills/mo-dev/scripts/mo-cgo-test -count=20 -timeout=10m \ -run '^TestJsonMerge($|DepthValidation$|PatchWrapperAllocationsDoNotScaleWithRows$)' \ ./pkg/sql/plan/function .agents/skills/mo-dev/scripts/mo-cgo-test -count=1 -timeout=20m \ ./pkg/sql/plan/function .agents/skills/mo-dev/scripts/mo-cgo-test -race -count=1 -timeout=30m \ ./pkg/sql/plan/function ``` The race-built test list was also checked to confirm that only the allocation-statistics test is excluded. Approved by: @XuPeng-SH
…25911) HAKeeper returns an allocated batch as the inclusive range `[firstID, firstID+batchSize-1]`, and the managed client stores `lastID` with that same inclusive meaning. The cache-consumption check previously treated `nextID == lastID` as exhausted. That boundary mismatch had three concrete effects: - batches larger than one skipped the final allocated ID; - a batch of one left `nextID > lastID`, so the client generated IDs locally without another HAKeeper allocation and could collide with another client; - `AllocateIDByKeyWithBatch(..., 0)` reached HAKeeper, where `batch-1` underflowed. This change uses one inclusive cache invariant for shared and keyed allocation: a cached ID is available only when `nextID != 0 && nextID <= lastID`. It also rejects a zero keyed batch before preparing or calling the HAKeeper client. No wire format, persisted HAKeeper state, allocation key, default batch size, or public API signature changes. Regression tests cover complete batch consumption, batch-one uniqueness across independent clients, and zero-batch rejection before RPC. Approved by: @gouhongshen, @volgariver6, @XuPeng-SH
…n#25915) ### Root cause `TestJsonMergePatchWrapperAllocationsDoNotScaleWithRows` measures the complete 8192-row JSON merge path with `testing.AllocsPerRun(3)`, even though its asserted invariant is wrapper allocation behavior. Under `-race`, that path also executes instrumented and race-build-only vector operations, so process-wide allocation deltas outside the intended invariant can be charged to the test. The same package source passed the Ubuntu/x86 race UT in matrixorigin#25728, then failed an unrelated PR in matrixorigin#25911 with `one=1, many=45`. matrixorigin#25911 only changes the HAKeeper client and its tests, which run in a separate package test binary. ### Fix Move the allocation-statistics-only test unchanged into a `!race` test file. This keeps: - the 1-row versus 8192-row allocation regression assertion in non-race builds; - all JSON merge functional tests in both race and non-race builds; - production code and JSON merge behavior unchanged. ### Validation ```text .agents/skills/mo-dev/scripts/mo-cgo-test -v -count=100 -timeout=10m \ -run '^TestJsonMergePatchWrapperAllocationsDoNotScaleWithRows$' \ ./pkg/sql/plan/function .agents/skills/mo-dev/scripts/mo-cgo-test -race -count=20 -timeout=10m \ -run '^TestJsonMerge($|DepthValidation$)' \ ./pkg/sql/plan/function .agents/skills/mo-dev/scripts/mo-cgo-test -count=20 -timeout=10m \ -run '^TestJsonMerge($|DepthValidation$|PatchWrapperAllocationsDoNotScaleWithRows$)' \ ./pkg/sql/plan/function .agents/skills/mo-dev/scripts/mo-cgo-test -count=1 -timeout=20m \ ./pkg/sql/plan/function .agents/skills/mo-dev/scripts/mo-cgo-test -race -count=1 -timeout=30m \ ./pkg/sql/plan/function ``` The race-built test list was also checked to confirm that only the allocation-statistics test is excluded. Approved by: @XuPeng-SH
…25911) HAKeeper returns an allocated batch as the inclusive range `[firstID, firstID+batchSize-1]`, and the managed client stores `lastID` with that same inclusive meaning. The cache-consumption check previously treated `nextID == lastID` as exhausted. That boundary mismatch had three concrete effects: - batches larger than one skipped the final allocated ID; - a batch of one left `nextID > lastID`, so the client generated IDs locally without another HAKeeper allocation and could collide with another client; - `AllocateIDByKeyWithBatch(..., 0)` reached HAKeeper, where `batch-1` underflowed. This change uses one inclusive cache invariant for shared and keyed allocation: a cached ID is available only when `nextID != 0 && nextID <= lastID`. It also rejects a zero keyed batch before preparing or calling the HAKeeper client. No wire format, persisted HAKeeper state, allocation key, default batch size, or public API signature changes. Regression tests cover complete batch consumption, batch-one uniqueness across independent clients, and zero-batch rejection before RPC. Approved by: @gouhongshen, @volgariver6, @XuPeng-SH
…n#25915) ### Root cause `TestJsonMergePatchWrapperAllocationsDoNotScaleWithRows` measures the complete 8192-row JSON merge path with `testing.AllocsPerRun(3)`, even though its asserted invariant is wrapper allocation behavior. Under `-race`, that path also executes instrumented and race-build-only vector operations, so process-wide allocation deltas outside the intended invariant can be charged to the test. The same package source passed the Ubuntu/x86 race UT in matrixorigin#25728, then failed an unrelated PR in matrixorigin#25911 with `one=1, many=45`. matrixorigin#25911 only changes the HAKeeper client and its tests, which run in a separate package test binary. ### Fix Move the allocation-statistics-only test unchanged into a `!race` test file. This keeps: - the 1-row versus 8192-row allocation regression assertion in non-race builds; - all JSON merge functional tests in both race and non-race builds; - production code and JSON merge behavior unchanged. ### Validation ```text .agents/skills/mo-dev/scripts/mo-cgo-test -v -count=100 -timeout=10m \ -run '^TestJsonMergePatchWrapperAllocationsDoNotScaleWithRows$' \ ./pkg/sql/plan/function .agents/skills/mo-dev/scripts/mo-cgo-test -race -count=20 -timeout=10m \ -run '^TestJsonMerge($|DepthValidation$)' \ ./pkg/sql/plan/function .agents/skills/mo-dev/scripts/mo-cgo-test -count=20 -timeout=10m \ -run '^TestJsonMerge($|DepthValidation$|PatchWrapperAllocationsDoNotScaleWithRows$)' \ ./pkg/sql/plan/function .agents/skills/mo-dev/scripts/mo-cgo-test -count=1 -timeout=20m \ ./pkg/sql/plan/function .agents/skills/mo-dev/scripts/mo-cgo-test -race -count=1 -timeout=30m \ ./pkg/sql/plan/function ``` The race-built test list was also checked to confirm that only the allocation-statistics test is excluded. Approved by: @XuPeng-SH
…25911) HAKeeper returns an allocated batch as the inclusive range `[firstID, firstID+batchSize-1]`, and the managed client stores `lastID` with that same inclusive meaning. The cache-consumption check previously treated `nextID == lastID` as exhausted. That boundary mismatch had three concrete effects: - batches larger than one skipped the final allocated ID; - a batch of one left `nextID > lastID`, so the client generated IDs locally without another HAKeeper allocation and could collide with another client; - `AllocateIDByKeyWithBatch(..., 0)` reached HAKeeper, where `batch-1` underflowed. This change uses one inclusive cache invariant for shared and keyed allocation: a cached ID is available only when `nextID != 0 && nextID <= lastID`. It also rejects a zero keyed batch before preparing or calling the HAKeeper client. No wire format, persisted HAKeeper state, allocation key, default batch size, or public API signature changes. Regression tests cover complete batch consumption, batch-one uniqueness across independent clients, and zero-batch rejection before RPC. Approved by: @gouhongshen, @volgariver6, @XuPeng-SH
What type of PR is this?
Which issue(s) this PR fixes:
issue #25887
What this PR does / why we need it:
HAKeeper returns an allocated batch as the inclusive range
[firstID, firstID+batchSize-1], and the managed client storeslastIDwith that same inclusive meaning. The cache-consumption check previously treated
nextID == lastIDas exhausted.That boundary mismatch had three concrete effects:
nextID > lastID, so the client generated IDs locallywithout another HAKeeper allocation and could collide with another client;
AllocateIDByKeyWithBatch(..., 0)reached HAKeeper, wherebatch-1underflowed.
This change uses one inclusive cache invariant for shared and keyed allocation:
a cached ID is available only when
nextID != 0 && nextID <= lastID. It alsorejects a zero keyed batch before preparing or calling the HAKeeper client.
No wire format, persisted HAKeeper state, allocation key, default batch size, or
public API signature changes. Regression tests cover complete batch consumption,
batch-one uniqueness across independent clients, and zero-batch rejection before
RPC.
Test
.agents/skills/mo-dev/scripts/mo-cgo-test -count=100 -timeout=5m -run '^(TestAllocateIDConsumesEntireBatch|TestAllocateBatchOneIDsRemainUniqueAcrossClients|TestAllocateIDByKeyRejectsZeroBatchBeforeRPC)$' ./pkg/logservice.agents/skills/mo-dev/scripts/mo-cgo-test -race -count=20 -timeout=5m -run '^(TestAllocateIDConsumesEntireBatch|TestAllocateBatchOneIDsRemainUniqueAcrossClients|TestAllocateIDByKeyRejectsZeroBatchBeforeRPC)$' ./pkg/logservice.agents/skills/mo-dev/scripts/mo-cgo-test -count=1 -timeout=10m ./pkg/logservice.agents/skills/mo-dev/scripts/mo-cgo-test -race -count=1 -timeout=15m ./pkg/logservice.agents/skills/mo-dev/scripts/mo-cgo-test -run '^$' -count=1 -timeout=5m ./pkg/cnservicego build -mod=readonly ./pkg/logservicego vet -mod=readonly ./pkg/logservicegit diff --check