Repository navigation
Fixes #34058: Evict a committed cascade from the cache in one step; give the IT server production's search pool - #34059
Conversation
…op L1 With the Redis cache on, an async restore of a database could leave its schemas answering 404 right after the restore committed. RestoreHierarchyIT.asyncRestore_returns202AndRestoresFullHierarchy failed in 7 of the 86 postgres-elasticsearch-redis parallel-lane runs whose commit contains #33866, and in none of the 188 without it. Since #33866 the cascade's children leave Redis only after commit, in drainCacheInvalidations, one entity at a time with about ten synchronous Redis calls each. The restored root still evicts inline in EntityUpdater, so it reads as restored the moment the transaction commits, while its children keep serving their soft-deleted copies until the drain reaches them. The test polls the database, then reads a schema inside that window. The drain now evicts the committed batch in one pass: - it bumps every write epoch first, so a loader that read the pre-commit row cannot write it back after the eviction; - it deletes every entity key (id hash, by-name and reference aliases) in one DEL, split only past 1,000 keys; - it evicts L1 after that DEL, since a reader in the window copies the stale Redis entry into L1 and nothing evicted it after the commit; - it re-arms EntityCacheRepair from the commit, because the repair armed inside the transaction fires 500 ms after that eviction, which a long transaction outlives. Co-Authored-By: Claude Opus 5.5 <[email protected]>
TestSuiteBootstrap never set maxConnTotal or maxConnPerRoute, so the in-process server ran on the schema defaults: 10 connections to the single Elasticsearch host (30 total) instead of the 50/100 in conf/openmetadata.yaml. Under the parallel lane that pool stayed empty longer than connectionRequestTimeoutSecs (5 s), and requests failed with "error while performing request", Rest5Client's wrapper for the lease timeout. That is how SearchResourceIT.testEntityTypeCountsResponseFormat failed in the merge queue for #33338. Co-Authored-By: Claude Opus 5.5 <[email protected]>
✅ PR checks passedThe linked issue has a description and all required Shipping project fields set. Thanks! |
Code Review ✅ Approved🟡 Medium risk · Committed cascade eviction changes cache behavior, alongside integration-server pool sizing. Fixes two flaky integration tests by evicting committed cascades from Redis in one atomic step and configuring the IT server with production search pool sizes. The cache drain now bumps write epochs, deletes all entity keys in a single OptionsDisplay: compact → Counting what did not apply, without listing it. Comment with these commands to change the behavior for this request:
Was this helpful? React with 👍 / 👎 | Powered by Gitar — free for open source |
🚦 Removed from the merge queue —
|
Describe your changes:
Fixes #34058
Two integration tests have been failing intermittently and evicting PRs from the merge queue. One is a real cache bug, the other a test-harness setting.
1. With the Redis cache on, restored children could 404 right after an async restore. This is
RestoreHierarchyIT.asyncRestore_returns202AndRestoresFullHierarchyin thepostgres-elasticsearch-redislane.Since #33866, a cascade's children are evicted from Redis only after its transaction commits, in
drainCacheInvalidations. The drain goes one entity at a time, with about ten synchronous Redis calls each. The restored root still evicts inline inEntityUpdater, so it reads as restored the moment the transaction commits. Its children keep serving their soft-deleted copies until the drain reaches them. The test polls the database, then reads a schema inside that window. In one failing run the schema GET 404'd about 0.2 s after the database was re-read as restored, and the async job finished about 2.5 s after that.2. The IT server ran on the search client's schema pool defaults. This is
SearchResourceIT.testEntityTypeCountsResponseFormatin themysql-elasticsearchlane.TestSuiteBootstrapnever setmaxConnTotalormaxConnPerRoute. The in-process server therefore had 10 connections to the single Elasticsearch host instead of the 50/100conf/openmetadata.yamlships. Under the parallel lane the pool stayed empty pastconnectionRequestTimeoutSecs(5 s), which surfaced asDeadlineTimeoutExceptioninStrictConnPool.Rest5Clientwraps that timeout as "error while performing request". The bootstrap now sets the production values.These are the
postgres-elasticsearch-redisparallel-lane reports from 2026-09-23 06:51 to 2026-09-25 15:57 UTC, split by whether the tested commit contains #33866. This is CI observation, not a controlled run:syncRestorefailsasyncRestorefailstest_sdkOnlyAsyncOperationsfails (unrelated)#33866 fixed the sync failure (#33860) and opened this async one.
Type of change:
High-level design:
The fix is in the post-commit cache drain,
EntityRepository.drainCacheInvalidations→evictCommittedWrites. For the keys a transaction deferred, it now:DEL. That covers the id hash (base and reference) plus the by-name and reference aliases, via the newCachedEntityDao.invalidateEntities. The batch is split only past 1,000 keys, so a very large cascade never blocks Redis on one command. The whole batch turns over at once. The root still evicts inline, so a reader can still see the root restored before its children for about one Redis round trip after the commit. Before this change that gap lasted the whole sequential drain, which is the window the test hit.DEL. A reader in the window copies the stale Redis entry into L1, and until now nothing evicted it after the commit.EntityCacheRepairre-armed from the commit. The repair armed inside the transaction fires 500 ms after that eviction, which a long transaction can outlive.invalidateRedisL2ForEntity, used when no scope is open and by the repair, now uses the same one-DELeviction instead of four round trips.Without Redis (for example the MySQL lane), the drain now also re-evicts L1 and re-arms the repair for each deferred key. That is local work only, and it closes the same L1 hole there.
Alternatives considered and rejected:
No migration, schema or config changes.
Tests:
Use cases covered
invalidateEntitiesevicts every variant of a batch in oneDEL, and splits only past 1,000 keys.Unit tests
openmetadata-service/src/test/java/org/openmetadata/service/jdbi3/DeferredCacheInvalidationTest.java(5 tests). It runs the real L1 loader and the realCachedEntityDaoover an in-memory Redis stand-in; only the DB read is stubbed.CachedEntityDaoAliasEvictionTest(+2 tests). InEntityRepositoryRestoreTest, the two mock-verify deferral tests from Fixes 33860: evict Redis L2 after commit, not inside the write transaction #33866 were replaced by state-based versions in the new class.main), 3 of the 5 new tests fail. After the drain, L1 still serves the soft-deleted copy. The watched Redis keys left after each write are[2, 2, 2, 2, 1, 1, 1, 1, 0, 0, 0, 0]. No repair is armed at commit.EntityRepository.javaand 13/14 inCachedEntityDao.java. The uncovered line is theEntityCacheBypassguard'sreturnininvalidateEntities.Backend integration tests
-Pcache-tests, parallel lane):RestoreHierarchyIT5/5 andSearchResourceIT77/77 (3 pre-existing skips). Neither flake reproduces locally without CI load, so this run confirms the restore and search paths still work. The regression proof is the unit tests above, and CI'spostgres-elasticsearch-redislane on this PR.Ingestion integration tests
Playwright (UI) tests
Manual testing performed
Verified through the tests above, not on a manual stack. To check by hand with the Redis cache enabled:
include=all, which caches its soft-deleted copy.PUT /api/v1/databases/restore?async=true.GET /api/v1/databases/{id}until it is restored, then immediatelyGET /api/v1/databaseSchemas/{schemaId}. It should return 200. Before this fix it intermittently returned 404 under load.UI screen recording / screenshots:
Not applicable.
Checklist:
Fixes <issue-number>: <short explanation>Fixes #<issue-number>above.🤖 Generated with Claude Code