Repository navigation
test(electric): isolate persistence promises for retry holds - #2513
Conversation
The retry driver reused a resolved deferred after the first hold released. Create a deferred per transaction, keep the original CI regression, and construct repeated holds in all four source modes. Preserve secondary cleanup diagnostics while suppressing only the expected preload warning. Law: accepted sync work waits for the current optimistic transaction; subset settlement follows row visibility, while truncates apply at once. Authority: the glossary and the unchanged Electric retry reference model. Reach: 25 histories per source mode across the final fixed/random campaigns. RED: seed -903876084, path 10:1:0:0:1:11:8, electric.retry-decision, random seed: generated; the demand fulfilled and its row appeared too early. GREEN: 589 selected tests and type tests pass; the exact CI replay, ESLint, oracle lint, formatting, and diff checks pass. Mutant: restoring the singleton deferred fails the new full-log snapshot comparison. A primary-failure plus cleanup-rejection probe also rejects broad warning suppression and retains both errors after the repair. Limits: controlled ShapeStream, one to three prior releases; no new real provider or native-persistence claim. Production code is unchanged. Related: #2497
|
|
No actionable comments were generated in the recent review. Walkthrough
Merge Risk:
|
Incremental update benchmarkComparing Overall median write time vs base: 0.99× · cold hydrate time: 1.01× (geometric mean of per-case ratios; lower is faster). Writes: No significant changes (threshold: ±20% and >0.05ms). Cold hydrate: 1 regression(s), 0 improvement(s) (threshold: ±50% and >5ms). CI regression gate: PASS. Query geometric means: >+30% writes or >+50% cold. A case also fails when every repetition exceeds the entire base range by >+50% and the metric's absolute floor. Per-case flags are noisy on shared runners. Read the geometric means first. Writes
Cold hydrate
Each row aggregates that query's scale/index/write-mode configurations; per-configuration tables below. 100 rows/collection | source indexes: none | synced writes — geomean 0.93×, cold 1.01×
100 rows/collection | source indexes: none | optimistic writes — geomean 1.00×, cold 0.95×
100 rows/collection | source indexes: manual | synced writes — geomean 0.98×, cold 1.03×
100 rows/collection | source indexes: manual | optimistic writes — geomean 1.02×, cold 0.99×
1,000 rows/collection | source indexes: none | synced writes — geomean 1.04×, cold 1.01×
1,000 rows/collection | source indexes: none | optimistic writes — geomean 0.76×, cold 0.87×
1,000 rows/collection | source indexes: manual | synced writes — geomean 0.91×, cold 0.91×, 1 change(s)
1,000 rows/collection | source indexes: manual | optimistic writes — geomean 1.05×, cold 1.02×
10,000 rows/collection | source indexes: none | synced writes — geomean 0.96×, cold 1.02×
10,000 rows/collection | source indexes: none | optimistic writes — geomean 1.01×, cold 1.09×
10,000 rows/collection | source indexes: manual | synced writes — geomean 1.12×, cold 1.17×
10,000 rows/collection | source indexes: manual | optimistic writes — geomean 1.10×, cold 1.12×
Runner: node v22.23.5, linux 7.0.0-1020-azure, AMD EPYC 9V74 80-Core Processor. Timings on shared CI runners are noisy; treat small deltas as indicative only. |
|
Size Change: 0 B Total Size: 203 kB ℹ️ View Unchanged
|
More templates
@tanstack/angular-db
@tanstack/browser-db-sqlite-persistence
@tanstack/capacitor-db-sqlite-persistence
@tanstack/cloudflare-durable-objects-db-sqlite-persistence
@tanstack/convex-db-collection
@tanstack/db
@tanstack/db-ivm
@tanstack/db-sqlite-persistence-core
@tanstack/electric-db-collection
@tanstack/electron-db-sqlite-persistence
@tanstack/expo-db-sqlite-persistence
@tanstack/node-db-sqlite-persistence
@tanstack/offline-transactions
@tanstack/powersync-db-collection
@tanstack/powersync-direct-db-collection
@tanstack/preact-db
@tanstack/query-db-collection
@tanstack/react-db
@tanstack/react-native-db-sqlite-persistence
@tanstack/react-router-with-db
@tanstack/rxdb-db-collection
@tanstack/solid-db
@tanstack/supabase-db-collection
@tanstack/svelte-db
@tanstack/tauri-db-sqlite-persistence
@tanstack/trailbase-db-collection
@tanstack/vue-db
commit: |
Name the new property's file in the guarded replay manifest. The existing owner-completeness check caught the omitted entry in Test (db-replay). Law: every registered property names its actual replay owner. Reach: exhaustive registered-name comparison and two guarded campaign units. RED: names an owner for every registered property reports [electric.retry-renewed-hold] before the registration. GREEN: all 125 replay tests pass; generated and full-log guarded replays report the correct owner and executions: 1. ESLint and oracle lint pass. Mutant: the original missing entry fails the owner-completeness comparison. Limits: replay routing only; model, histories, checks and production stay.
🎯 Changes
The Electric retry oracle fails when a history releases one optimistic hold and starts another before the first snapshot. Every transaction reused one persistence promise, so the first release also settled later holds.
Give each optimistic transaction its own persistence promise. Retain the CI history and add generated coverage for repeated holds in all four source modes. Preserve cleanup diagnostics when a history fails. The runner previously suppressed these warnings along with expected preload warnings. The adapter and reference model remain unchanged.
Related: #2497.
🔬 Oracle Coverage
The coverage map names
packages/electric-db-collection/tests/electric-oracle.property.test.tsas the primary oracle owner.The declared bug class is reuse of a settled persistence promise across sequential optimistic holds in the controlled test driver. The driver compares row visibility and subset settlement after each step, including snapshot delivery, the final release, and cleanup.
-903876084, path10:1:0:0:1:11:8reproduces premature row visibility and subset fulfillment on the parent implementation.🚀 Release Impact
This test-only fix does not need a changeset. The separate
pkg-pr-newPreview failure in #2497 returns HTTP 404 and remains outside this change.A same-runner fault injection now reports both the primary mismatch and its cleanup failure. The lifecycle regression also checks cleanup error identity and later resource release.
See the fix evidence for commands, reach counts, and the oracle audit.
✅ Checklist
Summary by CodeRabbit
Tests
Documentation