fix: settle couchbase seed before asserting unfiltered count - #720
Merged
Conversation
countAffectedRowsCountsUpdateWithoutWhereAsWholeCollection intermittently read 1 or 2 of the 3 seeded documents in CI, failing unrelated PRs. An unfiltered SELECT COUNT(*) — what CouchbaseCountRewriter emits for a WHERE-less UPDATE/DELETE — is planned as a CountScan over the primary index, and that fast path can read a just-committed INSERT as short even under REQUEST_PLUS. EXPLAIN confirms the divergence: the bare count plans to CountScan, every WHERE-bearing count to PrimaryScan3 + Fetch. Settle the @beforeeach seed on the same probe before any assertion, which also removes the unsettled DELETE-then-INSERT for all 32 tests. Test-only: the shaded jar SHA-256 pin is unchanged.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem
CouchbaseQueryEngineIntegrationTest.countAffectedRowsCountsUpdateWithoutWhereAsWholeCollectionis flaky: it asserts 3 seeded documents but intermittently reads 1 or 2. Because the couchbase
engine job runs on any
backend/**change, this fails unrelated PRs — it took down#717 (a Slack SDK bump) and the ArchUnit bump in the same CI wave, with different wrong values
(1 and 2 respectively).
Root cause
Not scan consistency — every executor path shares one
options()helper and the test runsREQUEST_PLUSthroughout. The differentiator is the query shape.CouchbaseCountRewriterturns the WHERE-lessUPDATE _default SET bonus = 1into a bareSELECT COUNT(*) AS af_count FROM _default. Verified against a real 7.6.2 container:SELECT COUNT(*) FROM itestCountScanSELECT COUNT(*) FROM itest WHERE team = "eng"PrimaryScan3+Fetch+FilterThe
CountScanfast path can read a just-committed INSERT as short even underrequest_plus;driving that loop directly reproduced a stale
COUNT=1, while the filtered shape never wentstale. That is exactly why this is the only count test in the class that flakes — every other one
carries a WHERE clause.
Fix
Settle the
@BeforeEachseed on the same probe before any assertion runs, bounded at 30s with aclear failure message. Since it sits in
@BeforeEachit also removes the unsettledDELETE-then-INSERTwindow for all 32 tests in the class, not just this one.Deliberately test-only: the engine already requests the strongest consistency Couchbase
offers, and touching
src/main/— even a comment, which shifts theLineNumberTable— wouldchange the shaded jar bytes and force a
connectors/couchbase/connector.jsonSHA-256 re-pin.Verification
mvn -f engines/couchbase/pom.xml clean verify— green (32/32 IT, 2/2 failsafe)node .github/scripts/check-engine-pins.mjs couchbase— pin unchanged, confirming the shadedjar is byte-identical