Skip to content

Transaction exception catch - #13703

Merged
ArnabChatterjee20k merged 4 commits into
mainfrom
transaction-exception-catch
Sep 15, 2026
Merged

ArnabChatterjee20k merged 4 commits into
mainfrom
transaction-exception-catch

Conversation

@ArnabChatterjee20k

Copy link
Copy Markdown
Member

What does this PR do?

(Provide a description of what this PR does and why it's needed.)

Test Plan

(Write your test plan here. If you changed any code, please provide us with clear instructions on how you verified your changes work. Screenshots may also be helpful.)

Related PRs and Issues

  • (Related PR or issue)

Checklist

  • Have you read the Contributing Guidelines on issues?
  • If the PR includes a change to an API's metadata (desc, label, params, etc.), does it also include updated API specs and example docs?

@greptile-apps

greptile-apps Bot commented Sep 15, 2026 •

Copy link
Copy Markdown
Contributor

RetriggerConfidence Score: 5/5

No new reportable issue remains, so the PR appears safe to merge under the review’s thread-handling rules.

Fix All in Claude CodeFindings

  1. P1 Status Can Remain Committing ▶
Fix with agent prompt
### Issue 1
src/Appwrite/Platform/Modules/Databases/Http/Databases/Transactions/Update.php:354-358
After the tenant-data transaction commits, this separate update from `committing` to `committed` can still throw. It is now outside the failure handling and has no reconciliation path, so a project-database failure can leave durable tenant writes paired with an indefinitely `committing` transaction and return an error to the client. A later completion attempt cannot recover it because the endpoint accepts only `pending` transactions.

---

For each issue above, determine whether it is valid and should be fixed. If so, fix it directly.

Summary

This PR expands transaction commit failure handling and adds end-to-end coverage for authorization failures during commit.

  • Maps commit-time database authorization failures to the public unauthorized response while marking the transaction failed.
  • Marks transactions failed for other exceptions raised within the commit handling block.
  • Verifies that revoked write permission produces a terminal failed transaction and leaves the staged write unapplied.

Reviews (3) · Last reviewed commit: "Revert "fix(transactions): ensure transa..."

@github-actions

github-actions Bot commented Sep 15, 2026 •

Copy link
Copy Markdown

✨ Benchmark results

Comparing main (before) → transaction-exception-catch (after).

⚠️ Before benchmark did not complete — change column unavailable.

Metric Before After Change
🚀 Requests/sec n/a 195.64 n/a
⏱️ Latency P50 n/a 89.22 ms n/a
⏱️ Latency P95 n/a 205.46 ms n/a
Per-scenario breakdown & investigation details

Metrics below reflect the current branch (after). Δ P95 compares against the base.

Scenario P50 (ms) P95 (ms) Requests RPS Δ P95 (ms)
API total 89.22 205.46 12,540 195.64 n/a
Account 164.07 317.71 660 10.96 n/a
TablesDB 86.82 162.69 6,820 108.97 n/a
Storage 82.84 177.85 3,300 54.3 n/a
Functions 125.31 248.45 1,760 29.47 n/a

Top API waits (after)

API request Max wait (ms)
storage.buckets.create 539.29
account.name.update 515.27
functions.variables.create 481.28
tablesdb.rows.get 468.25
tablesdb.rows.decrement 455.3

Comment on lines +354 to +358
$transaction = $authorization->skip(fn () => $dbForProject->updateDocument(
'transactions',
$transactionId,
new Document(['status' => 'committed'])
));

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

P1 Status Can Remain Committing

After the tenant-data transaction commits, this separate update from committing to committed can still throw. It is now outside the failure handling and has no reconciliation path, so a project-database failure can leave durable tenant writes paired with an indefinitely committing transaction and return an error to the client. A later completion attempt cannot recover it because the endpoint accepts only pending transactions.

Knowledge Base Used: Database data API and transactions

Prompt To Fix With AI
This is a comment left during a code review.
Path: src/Appwrite/Platform/Modules/Databases/Http/Databases/Transactions/Update.php
Line: 354-358

Comment:
**Status Can Remain Committing**

After the tenant-data transaction commits, this separate update from `committing` to `committed` can still throw. It is now outside the failure handling and has no reconciliation path, so a project-database failure can leave durable tenant writes paired with an indefinitely `committing` transaction and return an error to the client. A later completion attempt cannot recover it because the endpoint accepts only `pending` transactions.

**Knowledge Base Used:** [Database data API and transactions](https://app.greptile.com/appwrite/-/custom-context/knowledge-base/appwrite/appwrite/-/docs/database-data-api.md)

---

For each issue above, determine whether it is valid and should be fixed. If so, fix it directly.

Fix in Claude Code Fix in Codex

…ommitted' or 'failed' during error handling"

This reverts commit ded0528.
@ArnabChatterjee20k
ArnabChatterjee20k merged commit 71f1ddd into main Sep 15, 2026
46 checks passed
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.

2 participants