Pass the permit turn on when a woken waiter cannot start (#197) - #198
Merged
Conversation
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.
Closes #197.
Problem
Since the ETag gate landed, the tray icon stays on cloud-sync forever even when every folder is idle: the aggregate reports a
SyncQueued/Syncingfolder that never runs (nonextcloudcmdprocess, ~0 CPU).Root cause
SyncPermit::release()wakes exactly ONE waiter and assumes it willtry_acquireagain. But the woken scheduler'sstart()can bail out through an early guard (empty queue, already running, paused, offline, auth/delete gates...) without taking the permit and without waking the next waiter. The turn is swallowed: the permit sits free while every other waiter sleeps forever.With the pre-gate full reconciliations, runs took minutes and the interleavings were rare. The ETag-skip makes runs milliseconds long, so the double-waiter scenario happens routinely: a folder that receives a second trigger while queued registers two waiters; the leftover waiter's abort strands the folders behind it in
SyncQueuedforever.Fix
start()now reports aStartAttempt(Ran/Waiting/Aborted). The permit-waiter callback checks the attempt: when it aborts (nothing launched, nothing waiting), it callspermit.release()to pass the turn to the next waiter (releasetoleratesin_use == 0).Waiting(the scheduler re-queued itself) andRankeep the turn, exactly as before.Testing
New regression test
aborted_permit_waiter_passes_the_turn_to_the_next_folder(three schedulers on one permit, double waiter on the middle one), red-green verified: without the propagationthirdnever starts and the assertion fails; with it every folder endsIdleOk.Gate: 706 tests, clippy clean, fmt applied.