Skip to content

feat(lock): add dedicated Lock API module for resource locking#438

Open
kisielewski wants to merge 3 commits into
feat/search-apifrom
feat/lock-api
Open

feat(lock): add dedicated Lock API module for resource locking#438
kisielewski wants to merge 3 commits into
feat/search-apifrom
feat/lock-api

Conversation

@kisielewski

Copy link
Copy Markdown
Member

Important

Depends on: simplito/privmx-bridge#17 — add distributed resource lock API with hierarchical lock levels

Summary

  • Adds a new endpoint/lock/ module exposing lock, unlock, and
    checkReservedLock operations backed by direct server-side RPC calls
    (lockLock, lockUnlock, lockCheckReservedLock).
  • Removes LockSession / LockSetLogic from the search module — these
    relied on KVDB (read + write per acquisition), creating a TOCTOU window
    and doubling bridge round-trips.
  • Wires SearchApiImpl and PrivmxFS to the new Lock API.

Motivation

The old approach in SearchApi used KVDB as a locking primitive:

  1. Read the current lock value.
  2. Conditionally write the new value.

This meant two bridge round-trips per lock and a race window
between the read and the write. The dedicated Lock API collapses both
steps into a single atomic server call, eliminating the race and halving
the number of requests.

Introduces a new lock module (endpoint/lock/) with lock, unlock, and
checkReservedLock operations backed by direct server-side RPC calls.

Replaces the KVDB-based LockSession/LockSetLogic in SearchApi, which
required a read followed by a write — creating a TOCTOU window and
doubling the number of bridge round-trips per lock acquisition.
@kisielewski kisielewski requested a review from Uriagat May 25, 2026 11:47
@Uriagat Uriagat self-requested a review May 26, 2026 08:16

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[build] In file included from /privmx-endpoint/endpoint/search/src/PrivmxFS.cpp:1:
[build] /privmx-endpoint/endpoint/search/include/privmx/endpoint/search/PrivmxFS.hpp:37:10: fatal error: privmx/endpoint/search/LockSession.hpp: No such file or directory
[build] 37 | #include "privmx/endpoint/search/LockSession.hpp"

@kisielewski kisielewski requested a review from Uriagat May 26, 2026 09:17
@kisielewski kisielewski self-assigned this May 28, 2026
@kisielewski kisielewski requested a review from djenczewski May 28, 2026 20:18
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants