Add file-based transaction support and enhance revert functionality to support large size and number of changesets#9322
Open
khanaffan wants to merge 11 commits into
Open
Add file-based transaction support and enhance revert functionality to support large size and number of changesets#9322khanaffan wants to merge 11 commits into
khanaffan wants to merge 11 commits into
Conversation
Contributor
There was a problem hiding this comment.
Pull request overview
This PR enhances backend revert functionality to support very large changesets by leveraging native file-based transaction storage, and adds new API surface to control/inspect file-based transaction mode while improving revert cleanup behavior.
Changes:
- Add internal
BriefcaseDbAPIs to enable/disable and query file-based transaction mode (fileBasedTxnslocal value). - Extend
revertAndPushChangesto restore the pre-call file-based txn setting and add configurable failure cleanup viainCaseOfFailure. - Add an integration test that reverts schema+data changesets and verifies the resulting state across two briefcases.
Reviewed changes
Copilot reviewed 5 out of 5 changed files in this pull request and generated 7 comments.
Show a summary per file
| File | Description |
|---|---|
| full-stack-tests/backend/src/integration/TxnManager.test.ts | Adds an integration test covering revertAndPushChanges across two briefcases and validates reverted schema/data state. |
| core/backend/src/IModelDb.ts | Adds file-based txn toggles and updates revertAndPushChanges cleanup/restore logic and failure handling. |
| core/backend/src/BriefcaseManager.ts | Extends RevertChangesArgs with inCaseOfFailure to control cleanup strategy on failure. |
| common/changes/@itwin/core-backend/affank-file-based-txns_2026-05-20-15-09.json | Changelog entry for the revert robustness improvement. |
| common/api/core-backend.api.md | Updates extracted API to include new internal members and the updated RevertChangesArgs shape. |
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
Agent-Logs-Url: https://github.com/iTwin/itwinjs-core/sessions/47500152-cc3d-4a11-b090-5fde1b1dda72 Co-authored-by: khanaffan <29756942+khanaffan@users.noreply.github.com>
rschili
reviewed
May 21, 2026
| throw err; | ||
| } finally { | ||
| this[_nativeDb].abandonChanges(); | ||
| if (!wasFileBasedTxnsEnabled && !nativeDb.hasPendingTxns() && !nativeDb.hasUnsavedChanges()) |
Contributor
There was a problem hiding this comment.
Suggested change
| if (!wasFileBasedTxnsEnabled && !nativeDb.hasPendingTxns() && !nativeDb.hasUnsavedChanges()) | |
| if (!wasFileBasedTxnsEnabled && !nativeDb.hasPendingTxns() && !nativeDb.hasUnsavedChanges() && this.isOpen) |
rschili
approved these changes
May 21, 2026
soham-bentley
approved these changes
May 22, 2026
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.
imodel-native: iTwin/imodel-native#1438
Issue
RevertTimelineChanges could not handle large amounts of changes or very large changesets. The limitation is SQLite's inability to store blobs greater than 2 GB in the dgn_Txn table. Reverting anything exceeding 2 GB resulted in a failure when SQLite could not allocate the blob.
Solution
Add support for file-based transaction storage. When enabled, changeset data is written to individual .txn files on disk (LZMA-compressed) rather than stored as blobs in dgn_Txns. Only a small header (signature + uncompressed size + SHA1 checksum) is stored in the Change column.
This is activated automatically when calling RevertTimelineChanges, which enables the fileBasedTxns briefcase-local property and saves each reverted changeset individually with SaveChanges("reverted changeset ").