Skip to content

πŸ› Bug Report: Concurrent staging bypasses the transaction operation limit and loses acknowledged operationsΒ #14332

Closed

Description

@JoshiJoshiJoshi

πŸ‘Ÿ Reproduction steps

A – limit

  1. Create a transaction (default limit: 100 operations, APP_LIMIT_DATABASE_TRANSACTION; on Cloud databasesTransactionSize per plan).
  2. Send 8 POST /v1/tablesdb/transactions/{id}/operations requests at the same time, each with 60 create operations.
  3. Commit.

B – lost operations

  1. Create a transaction and stage one operation.
  2. Send the commit and, at the same time, 6 more staging requests with one create each.
  3. Check which staged rows exist after the commit.

πŸ‘ Expected behavior

A: at most 100 operations are accepted; the requests that would exceed the limit get 400 transaction_limit_exceeded.
B: every staging request that returns 201 is applied by the commit, or the request fails because the transaction is no longer pending.

πŸ‘Ž Actual Behavior

A: all 8 requests return 201, the transaction counts 480 operations, and the commit applies all 480 rows (4 of 4 rounds). Sequential staging is limited correctly (101st operation β†’ 400).

B: in 2 Γ— 20 rounds, 109 and 112 staging requests returned 201; 106 and 103 of them were never applied, and their logs stay behind. The commit returns 200. A client that does not await each staging call before committing (e.g. Promise.all over staging plus commit) silently loses writes it was told succeeded. When the commit is already running, staging is refused correctly (400, status committing).

Cause: Transactions/Operations/Create.php checks the status (L100–L102) and the operation count (L110–L118) on a plain read, and writes the logs and increments the counter later (L258–L266) without locking the transaction row or bounding the increment. The commit claims the transaction atomically since #14163 and then reads the logs, so logs written after that read are never applied.

🎲 Appwrite version

2.4.0

πŸ’» Operating system

Linux (Debian 12), Docker

🧱 Your Environment

Self-hosted Appwrite 2.4.0, Postgres adapter, two API nodes (requests spread over both).

πŸ’‘ Suggested fix

Do the check and the write in one database transaction that locks the transaction row, as the commit claim does: getDocument('transactions', $id, forUpdate: true), re-check status === 'pending', expiry and operations + count <= max, then insert the logs and increment the counter.

πŸ‘€ Have you spent some time to check if this issue has been raised before?

  • I checked and didn't find a similar issue

🏒 Have you read the Code of Conduct?

  • I have read the Code of Conduct

Activity

  1. added
    product / databases
    sdk / cli
    on Oct 11, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    product / databasessdk / cli

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions