Skip to content

Fix pending uploads on reconnect - #26

Open
julianallchin wants to merge 1 commit into
powersync-ja:mainfrom
julianallchin:fix-reconnect-uploads
Open

Fix pending uploads on reconnect#26
julianallchin wants to merge 1 commit into
powersync-ja:mainfrom
julianallchin:fix-reconnect-uploads

Conversation

@julianallchin

Copy link
Copy Markdown
Contributor

What changed

  • check the upload queue when the upload actor connects
  • add a regression for an upload trigger arriving before Connect

Root cause

The download actor can trigger an upload while the upload actor is still disconnected. That trigger is dropped, leaving offline writes queued until another local write occurs. An initial queue notification makes connecting check the existing backlog.

Validation

  • cargo +1.97.1 test -p powersync
  • cargo +1.97.1 clippy -p powersync --all-targets -- -D warnings

The regression fails before the fix and passes afterward, without sleeps or a live service.

@julianallchin
julianallchin marked this pull request as ready for review September 10, 2026 00:54
Comment on lines +135 to +146
// Let the download actor's upload trigger arrive before the upload
// actor receives Connect. No new writes should be needed afterward.
assert!(future::poll_once(connect.as_mut()).await.is_none());
assert!(future::poll_once(&mut download).await.is_none());
assert!(future::poll_once(&mut upload).await.is_none());
assert!(future::poll_once(&mut download).await.is_none());
assert!(future::poll_once(connect.as_mut()).await.is_none());
assert!(future::poll_once(&mut upload).await.is_none());
assert!(future::poll_once(connect.as_mut()).await.is_some());

assert_eq!(uploads.load(Ordering::SeqCst), 1);
assert!(db.next_crud_transaction().await.unwrap().is_none());

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

This feels absurdly specific and fragile.

What we want to test is that calling connect() eventually emits upload_data even without any additional local writes. So give the connector the writing end of an async channel, send in upload_data and make the test wait on the reading end.

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.

2 participants