Skip to content

fix(testing): reset zodb_pgjsonb SharedLoadCache after PG snapshot restore#169

Merged
jensens merged 4 commits into
mainfrom
fix/reset-storage-caches-on-test-restore
Jun 15, 2026
Merged

fix(testing): reset zodb_pgjsonb SharedLoadCache after PG snapshot restore#169
jensens merged 4 commits into
mainfrom
fix/reset-storage-caches-on-test-restore

Conversation

@jensens

@jensens jensens commented Jun 15, 2026

Copy link
Copy Markdown
Member

Problem

Two PG-backed integration tests fail in CI with ZODB.POSException.ConflictError on Products.ZCTextIndex...PLexicon:

  • TestMaintenanceOps::test_clear_find_and_rebuild_hierarchy
  • TestMaintenanceOps::test_clear_find_and_rebuild_survives_missing_path_column

They pass in isolation but fail whenever a clearFindAndRebuild test runs after another one. Green on main through 2026-04-22; red since — a dependency-drift symptom, not a code regression here.

Root cause

zodb_pgjsonb 1.12.0 introduced a process-wide SharedLoadCache (L2) that outlives a ZODB.DB connection pool and uses a strictly monotonic consensus TID. The PG-backed test layer's per-test restore() rolls the database backwards to a snapshot. cacheMinimize() / pool.clear() reset only the ZODB connection caches — not the shared cache, which then serves PLexicon at a TID newer than the rolled-back DB. The next commit conflict-checks the in-memory _serial (newer) against the DB row (older) → unresolvable ConflictError.

Full analysis + minimal repro confirmed locally (the failing pair goes green once the shared cache is reset).

Fix

PGCatalogPGFixture.testSetUp now resets zodb_pgjsonb's caches after restore():

Verification (local, Postgres 17)

  • Previously failing module 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).
  • Full suite: 1436 passed, 40 skipped (BM25/vchord skipped locally).

Note — unblocking #162

This fix lands on main; PR #122/α (#162) needs to be rebased onto / merged with main to pick up the fixed testSetUp. No zodb_pgjsonb release is required first thanks to the fallback.

Depends on (cleaner once merged): bluedynamics/zodb-pgjsonb#70

🤖 Generated with Claude Code

jensens and others added 4 commits April 23, 2026 23:46
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>
@jensens jensens merged commit 02fc020 into main Jun 15, 2026
5 checks passed
@jensens jensens deleted the fix/reset-storage-caches-on-test-restore branch June 15, 2026 22:47
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant