Optimistic concurrency: auto-increment version field support
Maintainers usually reply within 2 days
Nobody has claimed this yet.
Assessment
- Difficulty
- 5/5
- Estimated time
- Over a week
- Newbie friendliness
- 22/100
Research direction
This is engine-level optimistic concurrency for BLite.Core, then the BLite client, gRPC DocumentService and DynamicService, and REST. Start from the issue’s two API options and the open questions (field name, opt-in vs global, transactions, integer vs hash). Done means a chosen design plus version checks on update across those layers; there is no named file or test in the issue.
Written by the indexing model from the issue text.
Description
Summary
BLite currently has no built-in mechanism for optimistic concurrency control. To support EF Core's concurrency tokens and general multi-client scenarios, BLite needs either:
- Auto-increment version field: A
_version(or configurable name) field that the engine automatically increments on every update, enabling conditional writes ("update only if version == N"). - Default version field convention: Documents could carry a
_versionfield by default, but this would require a more invasive refactoring of the storage engine.
Motivation
- EF Core provider (see EntglDb/BLite.Server#9): EF Core relies on concurrency tokens (e.g.,
_etagin Cosmos,xminin PostgreSQL) to implement optimistic concurrency. Without engine-level support, the BLite EF Core provider cannot offerConcurrencyCheck/[Timestamp]attributes. - Multi-client scenarios: When multiple clients update the same document concurrently, stale writes can silently overwrite newer data. A version check on update prevents lost updates.
- Industry standard: MongoDB has
__v, Cosmos DB has_etag, CouchDB has_rev— document databases typically provide some form of optimistic concurrency primitive.
Proposed API
// Option A: Explicit conditional update
await collection.UpdateAsync(id, doc, expectedVersion: 3, ct);
// Throws ConcurrencyException if current version != 3
// Option B: Auto-versioned documents
// Engine automatically manages a _version field
// UpdateAsync checks and increments atomically
Scope
- Engine-level support in
BLite.Core - Exposed through
BLiteclient SDK - Exposed through gRPC
DocumentServiceandDynamicService - REST API support via conditional headers or request body field
Open Questions
- Should the version field name be configurable or fixed (
_version)? - Should this be opt-in per collection or enabled globally?
- How does this interact with transactions (version check inside vs. outside transaction)?
- Should the version be an integer counter or a hash/timestamp?
- Dominant language
- C#
- Stars
- 66
- Forks
- 6
- Avg merge
- 1d 2h
- Merged PRs (30d)
- 58
Getting set up
- No Dockerfile or Docker Compose file
- No pull request template
- Read the contributing guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
More from EntglDb/BLite
-
GdprMode.Strict warns that deleted documents are not zeroed, but every delete zero-fills themPossibly taken @CaffeinatedCoder claimed this 1 day ago. Openbug gdpr package/core severity/low
Difficulty 2/5 1-3 hours Newbie friendliness 88/100
EntglDb/BLite#299 · 1 comment ·
Maintainers usually reply within 2 days
-
bug package/core severity/medium triage
Difficulty 4/5 3-5 days Newbie friendliness 54/100
Maintainers usually reply within 2 days
-
bug package/core severity/medium
Difficulty 4/5 3-5 days Newbie friendliness 48/100
EntglDb/BLite#322 · 1 comment ·
Maintainers usually reply within 2 days
-
enhancement package/core
Difficulty 4/5 3-5 days Newbie friendliness 48/100
EntglDb/BLite#320 · 1 comment ·
Maintainers usually reply within 2 days
-
BLiteSession.Rollback() does not await the rollback: it returns while the transaction is still active, and failures go unobservedPossibly taken @CaffeinatedCoder claimed this 1 day ago. Openbug package/core severity/medium
Difficulty 3/5 1-2 days Newbie friendliness 78/100
EntglDb/BLite#307 · 1 comment ·
Maintainers usually reply within 2 days
Similar issues
-
Backend enhancement
Difficulty 2/5 1-3 hours Newbie friendliness 65/100
Maintainers usually reply within 1 day
-
UI: money shows the minus sign next to the number, not before the currency (IL -3.0m, not -IL 3.0m)Openarea: sim area: unity enhancement
Difficulty 2/5 1-3 hours Newbie friendliness 78/100
eyalgolan/statecraft-israel#1107 · 1 comment ·
Maintainers usually reply within 1 day
-
Difficulty 2/5 1-3 hours Newbie friendliness 83/100
dimitar-radenkov/Pointframe#271 ·
Maintainers usually reply within 1 day
-
Difficulty 2/5 1-3 hours Newbie friendliness 66/100
qew21/Genshin-Subtitles#45 ·
-
Difficulty 2/5 1-3 hours Newbie friendliness 72/100
HoffmanEngineering/3d-print-log-api#274 ·
Maintainers usually reply within 1 day