Skip to content

API Reference parrot.stores.lancedb_concurrency

github-actions[bot] edited this page Dec 2, 2026 · 4 revisions

parrot.stores.lancedb_concurrency

View source

Process-shared mutation coordination for one local LanceDB directory.

The asyncio lock here is an in-process optimization only. Cross-process correctness comes from the coordinator interface TASK-3057's gate proved sufficient (recorded in sdd/state/FEAT-542/lancedb-sdk-contract.md): a POSIX fcntl.flock guarding a critical section, since the pinned SDK (lancedb==0.38.0) raises NO distinguishable conflict exception for a colliding-insert race between two independent processes — an in-process lock and/or catching an exception is not sufficient by itself. The bounded retry in :meth:MutationCoordinator.run_mutation is defense-in-depth for genuine CommitConflict-raising failures (e.g. lock acquisition contention), not the primary correctness mechanism.

Class CommitConflict

A concurrent writer won the commit race; the caller may retry.

Class CoordinationConfig

Bounded-contention settings. Values come from TASK-3057's evidence doc.

Fields:

Field Type Default Description
max_attempts int 5
base_backoff_seconds float 0.05
max_backoff_seconds float 2.0
acquire_timeout_seconds float 30.0

Class MutationCoordinator

Serializes mutations in-process and mediates cross-process conflicts.

Covers collection/FTS-index creation as well as upsert and count/delete transactions — every mutating operation the gate identified as unsafe to race goes through :meth:exclusive (directly, for a multi-step critical section like "count under the same lock as delete") or :meth:run_mutation (for a single retryable operation).

Parameter Type Default Description
dataset_key str
config CoordinationConfig CoordinationConfig()

Fields:

Field Type Default Description
dataset_key str
config CoordinationConfig field(default_factory=CoordinationConfig)

Method MutationCoordinator.for_directory

Build a coordinator keyed by canonical directory + collection identity.

for_directory(uri: str | Path, collection: str, **kwargs: Any) -> 'MutationCoordinator'

Parameter Type Default Description
uri str | Path
collection str
**kwargs Any {}

Returns: 'MutationCoordinator'

Method MutationCoordinator.exclusive

Cross-process exclusion for operations the gate proved unsafe to race.

Acquires an OS-level lock off the event loop, honours acquire_timeout_seconds, and releases on every exit path (including cancellation raised inside the async with body). A write already committed by the SDK before cancellation is NOT undone by releasing this lock — release only relinquishes future mutation ownership.

exclusive(*, description: str) -> AsyncIterator[None]

Parameter Type Default Description
description str

Returns: AsyncIterator[None]

Method MutationCoordinator.run_mutation

Run one mutation with in-process serialization and bounded retry.

run_mutation(operation: Callable[[], Any], *, description: str) -> Any

Parameter Type Default Description
operation Callable[[], Any]
description str

Returns: Any

Raises:

  • CommitConflict — retries exhausted; the caller decides whether to surface or escalate. Never swallowed into a silent no-op.

Attribute T

Architecture

Clients

Bots & Agents

Memory

Knowledge

Tools & Toolkits

Flows

Experts

Skills

Stores & Loaders

MCP & A2A

Server & APIs

Integrations

Outputs & A2UI

Prompts

Security

Operations

Migration

SDD Tooling

LLM Wiki

Deployment

Decisions

API Reference

Clone this wiki locally