Fix race conditions interacting with Cloud SQLite jobs#9207
Fix race conditions interacting with Cloud SQLite jobs#9207tcobbs-bentley merged 13 commits intomasterfrom
Conversation
There was a race condition where the progress callback handler could happen after the Cloud SQLite job had completed, and this would lead to an unhandled exception thrown from a timer callback.
|
@khanaffan @wgoehrig This really needs a new unit test, but I don't know how to create a unit test that forces the race condition to occur. Do you have any suggestions? I could probably force it to happen in the delete case by having a progress callback that sleeps and then returns 1, but I have no idea how to force it to happen in any other case. |
There was a problem hiding this comment.
Pull request overview
Fixes a backend race where Cloud SQLite job progress polling could outlive job completion and throw from a timer callback, leading to an unhandled exception.
Changes:
- Added a helper to recognize the native “transfer already completed” error.
- Wrapped
setIntervalprogress polling for cleanup and transfer jobs intry/catchto ignore that completion race. - Updated imports to use
ITwinErrorfor error-shape checking.
Co-authored-by: Copilot Autofix powered by AI <223894421+github-code-quality[bot]@users.noreply.github.com>
Co-authored-by: Copilot Autofix powered by AI <223894421+github-code-quality[bot]@users.noreply.github.com>
|
@wgoehrig @khanaffan I added an integration test that uses a slow |
* Add a new `UtilityFunctions.ts` to core-bentley with an `intervalWrapper` function * Wrap the CloudSqlite `setInterval` callback code using `setInterval` so that any exceptions thrown will propagate to the main promise chain * Update the integration test to fail if `cleanDeletedBlocks` throws an exception
|
This is a common problem when using timer to simulate event or progress. It can fire after the resource is disposed. I think your fix is fine for what we have right now. |
|
@Mergifyio backport release/5.8.x |
✅ Backports have been createdDetails
|
There was a race condition where the progress callback handler could happen after the Cloud SQLite job had completed, and this would lead to an unhandled exception thrown from a timer callback.