Skip to content

fix: retry full synchronization after polling errors - #3509

Draft
sunchengzhu wants to merge 1 commit into
nervosnetwork:developfrom
sunchengzhu:scz/fix-sqlite-busy-sync-recovery
Draft

fix: retry full synchronization after polling errors#3509
sunchengzhu wants to merge 1 commit into
nervosnetwork:developfrom
sunchengzhu:scz/fix-sqlite-busy-sync-recovery

Conversation

@sunchengzhu

@sunchengzhu sunchengzhu commented Sep 1, 2026

Copy link
Copy Markdown
Collaborator

Summary

  • keep the full-node wallet synchronizer (FullSynchronizer) alive when one polling iteration fails
  • wait for the existing five-second polling interval before retrying
  • report the failure as a full-synchronization iteration error instead of an indexer connection error
  • add a regression test covering recovery from a transient SQLITE_BUSY failure

Fixes #3508.

Root cause

FullSynchronizer.initSync() previously wrapped the lifetime polling loop in a single try/catch. If indexer.tip() or the wallet-cache work in synchronize() threw, including a transient SQLITE_BUSY failure, control left the loop and the catch only logged the error. Because connect() starts initSync() in the background, the queue had already considered startup successful, so the existing indexer-error restart path was not reached.

This change catches errors around one polling iteration. A failed iteration is logged, the synchronizer waits five seconds, and the next iteration can continue. connect() remains non-blocking, so the queue can still install its block-tip and transaction subscriptions.

Scope

This is a recovery fix for the permanently stopped polling loop. It does not remove the underlying SQLite contention, enable WAL, change busy_timeout, serialize database writers, or implement bounded/exponential retry. Persistent failures are not escalated to indexer-error or surfaced as an actionable UI error by this change. Those can be evaluated separately.

This change only affects FullSynchronizer. Transaction-status tracking and LightSynchronizer are unchanged, so SQLITE_BUSY warnings or pop-ups may still occur. The fix specifically prevents a transient error in the full-node polling path from leaving wallet synchronization permanently stopped.

Testing

  • yarn workspace neuron-wallet test --runTestsByPath tests/block-sync-renderer/full-synchronizer.test.ts tests/block-sync-renderer/queue.test.ts --coverage=false — 28 passed
  • yarn workspace neuron-wallet test --coverage=false — 1,070 passed, 1 skipped
  • yarn workspace neuron-wallet build
  • Prettier and ESLint on both changed files
  • Windows A/B regression check of the original recovery test, before the additional queue-start assertion:
    • previous loop implementation: 2 failed, 15 passed
    • this change: 17 passed

@sunchengzhu
sunchengzhu force-pushed the scz/fix-sqlite-busy-sync-recovery branch from b68bf3d to e36483d Compare September 1, 2026 12:40
@eval-exec
eval-exec requested a balanced review from Copilot September 1, 2026 12:49

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot encountered an error and was unable to review this pull request. You can try again by re-requesting a review.

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot encountered an error and was unable to review this pull request. You can try again by re-requesting a review.

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟢 Approval recommended

The change is small, well-scoped, correctly retries failed polling iterations, and is backed by targeted regression tests with no issues found.

Review details
  • Files reviewed: 2/2 changed files
  • Comments generated: 0 new
  • Review effort level: Balanced

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.

[Bug Report] Wallet synchronization stops permanently after a transient SQLITE_BUSY error

2 participants