fix(testing): reset zodb_pgjsonb SharedLoadCache after PG snapshot restore#169
Merged
Merged
Conversation
Eleven tasks: Bundle dataclasses → filter-field extractor → shape classifier → btree-builder → GIN-builder → signature migration (list[Bundle]) → probe → partial WHERE → hybrid dispatch → GIN coverage → CHANGES.md. Refs #122. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
…store The PG-backed test layer's per-test restore() rolls the database backwards to a snapshot. cacheMinimize()/pool.clear() only reset ZODB connection caches, not zodb_pgjsonb's process-wide SharedLoadCache, which then served PLexicon at a newer TID than the rolled-back DB -> spurious ConflictError in whichever clearFindAndRebuild test ran second. testSetUp now calls storage.clear_caches() (zodb_pgjsonb >= 1.13.0) after restore(), with a fallback that resets the shared cache directly on older releases. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
1.13.0 ships the public PGJsonbStorage.clear_caches(), so testSetUp can call it directly and the floor is bumped to guarantee it. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
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
Two PG-backed integration tests fail in CI with
ZODB.POSException.ConflictErroronProducts.ZCTextIndex...PLexicon:TestMaintenanceOps::test_clear_find_and_rebuild_hierarchyTestMaintenanceOps::test_clear_find_and_rebuild_survives_missing_path_columnThey pass in isolation but fail whenever a
clearFindAndRebuildtest runs after another one. Green onmainthrough 2026-04-22; red since — a dependency-drift symptom, not a code regression here.Root cause
zodb_pgjsonb1.12.0 introduced a process-wideSharedLoadCache(L2) that outlives aZODB.DBconnection pool and uses a strictly monotonic consensus TID. The PG-backed test layer's per-testrestore()rolls the database backwards to a snapshot.cacheMinimize()/pool.clear()reset only the ZODB connection caches — not the shared cache, which then servesPLexiconat a TID newer than the rolled-back DB. The next commit conflict-checks the in-memory_serial(newer) against the DB row (older) → unresolvableConflictError.Full analysis + minimal repro confirmed locally (the failing pair goes green once the shared cache is reset).
Fix
PGCatalogPGFixture.testSetUpnow resetszodb_pgjsonb's caches afterrestore():storage.clear_caches()— public API added inzodb_pgjsonb≥ 1.13.0 (feat(storage): clear_caches() for out-of-band snapshot restore in tests zodb-pgjsonb#70).SharedLoadCachedirectly, so this is green against the currently publishedzodb_pgjsonb1.12.0 without waiting for a release.Verification (local, Postgres 17)
test_pg_integration.py: 64 passed, 1 skipped — via both the public API (editable 1.13.0-dev) and the fallback (wheel 1.12.0).Note — unblocking #162
This fix lands on
main; PR #122/α (#162) needs to be rebased onto / merged withmainto pick up the fixedtestSetUp. Nozodb_pgjsonbrelease is required first thanks to the fallback.Depends on (cleaner once merged): bluedynamics/zodb-pgjsonb#70
🤖 Generated with Claude Code