Repository navigation
fix: [SDK-5832] hold OpRepo HTTP under SyncJob when backgrounded - #2861
Closed
abdulraqeeb33 wants to merge 0 commit into
Closed
abdulraqeeb33 wants to merge 0 commit into
abdulraqeeb33 wants to merge 0 commit into
Conversation
Contributor
📊 Diff Coverage ReportDiff Coverage Report (Changed Lines Only)Gate: aggregate coverage on changed executable lines must be ≥ 80% (JaCoCo line data for lines touched in the diff). Changed Files Coverage
Overall (aggregate gate)107/117 touched executable lines covered (91.5% — requires ≥ 80%) Per-file detail (informational; gate is aggregate above):
|
abdulraqeeb33
force-pushed
the
fix/SDK-5832-patch-user-disconnect
branch
from
December 1, 2026 20:04
97e4607 to
40f471f
Compare
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.
Description
One Line Summary
Run due OpRepo HTTP under a held SyncJob when the app is backgrounded, so property user PATCHes are not started on an unprotected daemon thread.
Details
Motivation
SDK-5832: Turbine sees Android
PATCH /apps/:id/users/by/:alias/:idhang up during GetUser within ~1–3ms (~650k/day). Server cancel is a client TCP close, not an SDK HTTP timeout (timeouts are 120s+). p50 ≈ 1.6ms. Android is ~100–200× iOS.The queue is not cleared in background. Ops stay on disk until
SUCCESS. What fails is the in-flight TCP: OpRepo still starts HTTP afteropRepoExecutionInterval(~5s) on a daemon thread with no process hold, Android kills the socket, Turbine logs a cancel, and the SDK retries (status 0→FAIL_RETRY).Property-only PATCHes (
refresh_device_metadata=false) cancel ~46× more often than session-start refreshes. Session start usesenqueue(..., flush=true)while typically foregrounded. Property ops from model listeners use defaultflush=false, so the 5s batching window often ends after backgrounding.When this started
Not a single-line regression. The unprotected OpRepo path existed in mid-5.1; later releases increased how often HTTP starts while killable:
flush=true; Sync path is JobScheduler-only and does not drain OpRepo HTTP.flush=false, raising unprotected PATCH volume.runBackgroundServices()without waiting on OpRepo HTTP. Peak cancel share ~0.3% of 202s.Scope
Make
OperationRepoanIBackgroundService(same bridgeSessionServicealready uses):scheduleBackgroundRunIn: time until the next due op (or0if a batch is ready).backgroundRun(): wake the queue, execute the due batch, await in-flight HTTP, then return under the heldSyncJobService.FAIL_RETRYunchanged.Punted from this PR (separate follow-ups if still wanted):
languagehygiene (volume reduction only; not the disconnect cause)HttpClientwithContext(IO)+ request-body stream close (structure only)Testing
Unit testing
TBD with the OpRepo / BackgroundManager changes (backgrounded due-batch defers to SyncJob;
backgroundRundrains HTTP before return).Manual testing
Not yet. Draft while the OpRepo lifetime gate is implemented.
Affected code checklist
Checklist
Overview
Testing
Final pass
IBackgroundServiceimplementation still to land. Blank-language / withContext commit dropped from the branch.