Skip to content

Deterministic ~30s post-connect sync round blocks all local reads on a 6.4k-row store (web SDK 2.3.1, IDBBatchAtomicVFS) #1114

Open

Description

@princehaon

Environment

  • @powersync/web 2.3.1, @powersync/common 2.2.1, @powersync/shared-internals 1.2.0, @powersync/vue 0.6.0, @powersync/kysely-driver 2.0.1, @powersync/capacitor 0.9.1
  • WASM SQLite over IDBBatchAtomicVFS (no SharedArrayBuffer / COOP-COEP), Quasar/Vue 3 dev server, Chrome
  • Sync service: journeyapps/powersync-service:1.26.0, source Postgres 16, sync rules with one parameter bucket (org) + a branch-scoped stream
  • Dataset: 6,383 products + 6,383 branchStock + 2,000 transactions + 2,000 transactionProducts rows replicated locally; all rows stored in the default ps_data__<table>(id, data) JSON layout with auto-generated json_extract views

Symptom

Every page load, after connect() resolves, all local reads stall for a deterministic ~30 seconds, then complete together. Steady-state reads on the same store run in 5–25 ms.

Measured with instrumentation around database.getAll (page-age timestamps):

probe result
boot phases (init / schema / stores / subscribe) 0 / 3 / 11 / 22 ms
connect() + fetchCredentials 82–150 ms, token mint in 15 ms
catalogue SELECT (LIMIT 20, via views) started @ 555 ms after load, ran 29,503 ms
catalogue count ran 29,180 ms, completed at the same instant
SELECT count(*) FROM "branches" (1 row) issued mid-round 13,141 ms
same catalogue SELECT after the round settles 11–25 ms
server-side checkpoint New checkpoint → checkpoint_complete in 24–48 ms (ms: {bucket_data: 1, checksum: 27, parameters: 16, total: 48}), data_synced_bytes: 2767, operations_synced: 0

The determinism is the striking part: consecutive reloads produce 29.7 s and 29.5 s almost to the millisecond, with zero errors logged client- or server-side, and with essentially nothing to download.

What we ruled out

  • Server/service: checkpoints issue in 24–48 ms; the replication slot is healthy and caught up.
  • Query plans: the affected SQL is identical to queries we run manually post-round (11–25 ms through the same getAll path). The app's queries start immediately (first getAll begins at page-age 555 ms) and spend the wall inside the SDK.
  • Indexes: expression indexes on every joined/filtered/sorted column (verified used via EXPLAIN QUERY PLAN); post-round queries are fast with them present.
  • Credentials: no auth failures or retry storms in the measured boots.
  • WASM thread: a direct getAll issued mid-round completes in 13 s while the app's larger queries are still pending, so the worker is not simply CPU-pegged on one statement — reads appear to be serialized behind repeated write/commit work.

Observations that look abnormal

  1. ps_oplog currently holds 23,195 rows and never shrinks — across many connect/sync cycles its count is frozen. We would have expected applied download journal entries to be pruned.
  2. Deleting ps_oplog manually did not fix the round cost (and the count stays 0 afterwards), so the ~30 s is not only journal replay — but the never-vacuating journal still looks like a bug on its own.
  3. Every connect re-runs the same deterministic local work over the full store even when operations_synced: 0 — the cost appears to scale with total local rows (checkpoint/bucket reconciliation over the JSON rows), not with the delta.

Ask

  • Is a ~30 s post-connect round on a ~6.4k-row store expected for this storage backend, or is this a known hot path (oplog bookkeeping / bucket checksum computation row-by-row over json_extract views)?
  • Is ps_oplog supposed to be vacuumed after checkpoints in the web SDK? If yes, what would prevent it?
  • Any guidance on keeping reads flowing during the post-connect round (separate read connection, deferred checksum validation, configuration), or whether a fix is planned?

Happy to provide the full instrumented timelines or run dev builds against our reproduction.

Activity

  1. simolus3 commented on Sep 20, 2026

    @simolus3
    Contributor

    Is a ~30 s post-connect round on a ~6.4k-row store expected for this storage backend

    No, a sync operation on a mostly up-to-date client should be very fast without holding any database locks that long.

    For debugging purposes, could you try setting enableMultiTabs: false and debugMode: true as options when opening databases? This logs the actual query time without time spent waiting for a worker to be available (disabling multi-tab ensures the sync client runs in the local context, logging query times for internal statements too). It would be interesting to see query times for queries with powersync_control in their SQL text.

    It would also be interesting to see the results of SELECT COUNT(1) FROM ps_updated_rows before you call connect().

    Is ps_oplog supposed to be vacuumed after checkpoints in the web SDK?

    No, we need to preserve most of the operation history to be able to reconstruct the correct state for cases where a local write is uploaded but ignored by your backend (the correct behavior for those cases is to revert the write on the client too, so we need to keep the history).

  2. Chriztiaan commented on Nov 3, 2026

    @Chriztiaan
    Contributor

    @princehaon could you provide more information if possible?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions