Hacktoberfest 2026: the issues maintainers tagged for October, open and beginner-friendly. Browse Hacktoberfest issues

Optimistic concurrency: auto-increment version field support

Open
#20 0 comments 1 reaction 0 assignees View on GitHub

Maintainers usually reply within 2 days

Nobody has claimed this yet.

Assessment

Difficulty
5/5
Estimated time
Over a week
Newbie friendliness
22/100
Issue type
Feature
Clarity
Mostly clear
Activity status
Stale
Tech stack
csharp, grpc
Domain
api, backend, databases

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

enhancement package/core priority/P3

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:

  1. 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").
  2. Default version field convention: Documents could carry a _version field 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., _etag in Cosmos, xmin in PostgreSQL) to implement optimistic concurrency. Without engine-level support, the BLite EF Core provider cannot offer ConcurrencyCheck / [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 BLite client SDK
  • Exposed through gRPC DocumentService and DynamicService
  • 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

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

More from EntglDb/BLite

All issues in EntglDb/BLite

Similar issues

More C# issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.