[Fix] Keep uploading when a write races the write checkpoint - #1055
Draft
bean1352 wants to merge 2 commits into
Draft
[Fix] Keep uploading when a write races the write checkpoint#1055bean1352 wants to merge 2 commits into
bean1352 wants to merge 2 commits into
Conversation
🦋 Changeset detectedLatest commit: 44914ed The changes in this PR will be included in the next version bump. This PR includes changesets to release 7 packages
Not sure what this means? Click here to learn what changesets are. Click here if you're a maintainer who wants to add another changeset to this PR |
Contributor
Shouldn't the new write also have triggered a crud trigger? If we change private async crudUploadLoop(signal: AbortSignal, options: ResolvedSyncOptions): Promise<void> {
while (!signal.aborted) {
const crudChangeNotification = this.crudUploadNotifier.waitForNotification(signal);
await Promise.all([
// Start the initial CRUD upload on connect. Then, keep polling until we're done.
this._uploadAllCrud(signal, options),
this.delayRetry(signal, options.crudUploadThrottleMs)
]);
await crudChangeNotification;
}
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What's wrong
When the CRUD queue drains, the upload loop requests a write checkpoint. If a local write lands inside that window,
updateLocalTargetreturns false because it found new CRUD, but false is also its "nothing left to upload" answer. The loop can't tell those apart, so it breaks out while the row is still inps_crud.The sync core then refuses every checkpoint with "Could not apply checkpoint due to local data". Usually the racing write's own notification is latched while the loop is busy and wakes it again right after it exits, so this shows up as a short stall.
The fix
Ask the adapter whether CRUD is still pending before breaking, and go round again if it is. This covers both cases where
updateLocalTargetreports a race, including thesequence updatedbranch.hasCrud()is only reached afternextCrudItem()returned null, so a true result means new data really did arrive during the round trip. If a connector doesn't complete its batch, the existing "previously encountered CRUD item" guard still catches that on the next pass, so this can't spin.AI disclosure
I used Opus 5 to help research the original bug report, narrow down where the fault could be, and apply the fix. I reviewed and supervised the work.