docs: rewrite Concurrency Control as a learning guide - #9648
Open
khanaffan wants to merge 21 commits into
Open
Conversation
The existing ConcurrencyControl.md had drifted from the implementation: it referenced `locks.acquireExclusiveLock`/`acquireSharedLock`, which no longer exist on `LockControl`, and described lock/merge behavior that has since changed. Rewrite it as a learning-oriented document covering how concurrency works when multiple users edit an iModel, verified against the current source: - Locking vs `noLocks` policies, and how `ServerBasedLocks`/`NoLocks` is selected when a BriefcaseDb is opened. - The pull -> lock -> change -> save -> push -> release lifecycle. - Lock types, the model/parent ownership hierarchy, implicit downward locking and automatic upward shared locks. - The per-operation lock table, including aspects, models, changeParent and changeModel (which requires exclusive locks on the whole subtree). - Locks acquired automatically: newly created elements, owner locks, schema import, dropSchemas, profile/domain upgrade (which only takes the schema lock when a data transformation is required), and the exemption for indirect changes during change propagation. - The Schema Lock, plus the Schema Sync and semantic-rebase variations. - Distinguishes LockOwnedByAnotherBriefcase, PullIsRequired and LockNotHeld, and documents the per-lock freshness rules. - Release/abandon semantics and the beta Txn-level lock APIs. - How the briefcase tracks locks locally (locks/txn_locks/metadata). Conflict-resolution details are deferred to PullMerge.md rather than duplicated. Adds mermaid diagrams, including sequence diagrams for the edit lifecycle, schema import, and two briefcases contending for the same element, and links the doc from the backend learning index. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
…n Concurrency Control
…k handling in code
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Member
|
is this a rewrite of #9645 |
Contributor
|
This pull request is now in conflicts. Could you fix it @khanaffan? 🙏 |
Contributor
Author
wgoehrig
requested changes
Sep 3, 2026
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Co-authored-by: Bill Goehrig <33036725+wgoehrig@users.noreply.github.com>
Co-authored-by: Bill Goehrig <33036725+wgoehrig@users.noreply.github.com>
Co-authored-by: Bill Goehrig <33036725+wgoehrig@users.noreply.github.com>
Co-authored-by: Bill Goehrig <33036725+wgoehrig@users.noreply.github.com>
Co-authored-by: Bill Goehrig <33036725+wgoehrig@users.noreply.github.com>
Co-authored-by: Bill Goehrig <33036725+wgoehrig@users.noreply.github.com>
Co-authored-by: Bill Goehrig <33036725+wgoehrig@users.noreply.github.com>
Co-authored-by: Bill Goehrig <33036725+wgoehrig@users.noreply.github.com>
Co-authored-by: Bill Goehrig <33036725+wgoehrig@users.noreply.github.com>
Co-authored-by: Bill Goehrig <33036725+wgoehrig@users.noreply.github.com>
Co-authored-by: Bill Goehrig <33036725+wgoehrig@users.noreply.github.com>
Co-authored-by: Bill Goehrig <33036725+wgoehrig@users.noreply.github.com>
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
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.
Summary
docs/learning/backend/ConcurrencyControl.mdhad drifted from the implementation — most visibly it told readers to calllocks.acquireExclusiveLock/acquireSharedLock, which no longer exist onLockControl. This rewrites it as a learning document explaining how concurrency works when multiple users edit an iModel.Every claim was verified against the current source:
LockControl.ts,internal/ServerBasedLocks.ts,internal/NoLocks.ts,IModelDb.ts,Element.ts,Model.ts,ElementAspect.ts,EditTxn.ts,LocalHub.ts, andBackendHubAccess.ts.What the doc now covers
noLocks, and the flow that selectsServerBasedLocksvs the no-opLockControlwhen aBriefcaseDbis opened.LockOwnedByAnotherBriefcase(contention),PullIsRequired(stale briefcase), andLockNotHeld(local edit-time check). Includes the per-lock freshness rules for shared vs exclusive acquisition.changeElementParent, andchangeElementModel(which requires exclusive locks on the entire moved subtree).dropSchemas, profile/domain upgrade, and the exemption for indirect changes duringElementDrivesElementpropagation.upgradeSchemasonly takes the lock when a data transformation is required.locks/txn_locks/metadatatables and theAcquired/NewElement/Discoveredorigins.Conflict-resolution details are deferred to
PullMerge.mdrather than duplicated (the old doc's conflict table had gone stale).Notable corrections vs the old text
locks.acquireExclusiveLock(...)/acquireSharedLock(...)locks.acquireLocks({ shared, exclusive })pullChangesdoes not release locks; only push/explicit release doesupgradeSchemasis optimistic, acquiring the schema lock only onDataTransformRequired; Schema Sync and semantic rebase further relax importsPullMerge.md, which is the authoritative descriptionThe
#acquiring-locks-on-elementsanchor is preserved, sinceBackendHubAccess.tsandIModelError.tsdoc comments link to it.Diagrams
Adds mermaid diagrams (matching the fence/style already used in
Settings.mdandWorkspace.md), including sequence diagrams for the edit lifecycle, schema import, and two briefcases contending for the same element.Testing
Docs-only change. Verified all relative links and heading anchors resolve, that every
($backend)/($common)symbol referenced exists and is public, and that code fences are balanced. Norush changefile — no published package is affected.