Skip to content

Enforce operations cap per transaction #10319

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 78 commits into from
Aug 14, 2025

Conversation

abnegate
Copy link
Member

What does this PR do?

This PR enforces a per-transaction operations cap across all database operations that stage transactions. This ensures consistency with the existing AddOperations behavior, preventing a single transaction from exceeding the defined operation limit.

The enforcement logic is applied to:

  • Document operations: Create, Update, Delete, Upsert
  • Bulk document operations: Bulk/Delete, Bulk/Update, Bulk/Upsert
  • Attribute operations: Attribute/Increment, Attribute/Decrement

For each affected operation, the plan parameter is injected (if not already present), and a check is performed before staging the operation to ensure the transaction's operation count does not exceed databasesBatchSize (or APP_LIMIT_DATABASE_BATCH by default).

Test Plan

  1. Configure Transaction Limits: Ensure APP_LIMIT_DATABASE_BATCH is set to a small number (e.g., 1 or 2) in your .env file for easier testing.
  2. Initiate a Transaction: Start a database transaction using the relevant API endpoint (e.g., POST /databases/{databaseId}/transactions). Note the transactionId.
  3. Perform a Single Operation:
    • Attempt to Create, Update, Delete, Upsert a single document, or Increment/Decrement an attribute within the transaction.
    • Verify the operation succeeds if it's the first operation in the transaction and APP_LIMIT_DATABASE_BATCH is 1 or more.
    • Attempt a second single operation within the same transaction.
    • Verify that it fails with Exception::TRANSACTION_LIMIT_EXCEEDED if APP_LIMIT_DATABASE_BATCH is 1.
  4. Perform a Bulk Operation:
    • Start a new transaction.
    • Attempt a Bulk/Create, Bulk/Update, or Bulk/Upsert operation with multiple documents (e.g., 2 documents).
    • Verify that it fails with Exception::TRANSACTION_LIMIT_EXCEEDED if APP_LIMIT_DATABASE_BATCH is 1.
    • Verify it succeeds if APP_LIMIT_DATABASE_BATCH is set to a value greater than or equal to the number of documents in the bulk operation.

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?

Open in Cursor Open in Web

abnegate and others added 30 commits August 8, 2025 23:45
…oker

Feat: Make functions worker customizable
Skip redundant subqueries in users list route
…ache-clearing-bug-2799

Fix databases worker cache clearing bug
…e-function-broker

Revert "Feat: Make functions worker customizable"
Feat: Redis functions queue (reapply with fixes)
abnegate and others added 16 commits August 13, 2025 21:16
…ate-required-attributes

# Conflicts:
#	composer.json
#	composer.lock
…rnings

chore: remove experiment warnings from bulk methods
# Conflicts:
#	app/config/specs/open-api3-latest-client.json
#	app/config/specs/open-api3-latest-console.json
#	app/config/specs/open-api3-latest-server.json
#	app/config/specs/swagger2-latest-client.json
#	app/config/specs/swagger2-latest-console.json
#	app/config/specs/swagger2-latest-server.json
#	app/controllers/api/databases.php
#	composer.lock
#	src/Appwrite/SDK/Specification/Format/OpenAPI3.php
Co-authored-by: jakeb994 <jakeb994@gmail.com>
Copy link

cursor bot commented Aug 14, 2025

Cursor Agent can help with this pull request. Just @cursor in comments and I'll start working on changes in this branch.
Learn more about Cursor Agents

Copy link
Contributor

coderabbitai bot commented Aug 14, 2025

Note

Other AI code review bot(s) detected

CodeRabbit has detected other AI code review bot(s) in this pull request and will avoid duplicating their findings in the review comments. This may lead to a less comprehensive review.

Important

Review skipped

Auto reviews are disabled on base/target branches other than the default branch.

🗂️ Base branches to auto review (4)
  • main
  • 1.6.x
  • 1.7.x
  • 1.8.x

Please check the settings in the CodeRabbit UI or the .coderabbit.yaml file in this repository. To trigger a single review, invoke the @coderabbitai review command.

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

✨ Finishing Touches
🧪 Generate unit tests
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch cursor/enforce-operations-cap-per-transaction-6dd5

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share
🪧 Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>, please review it.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.

Support

Need help? Create a ticket on our support page for assistance with any issues or questions.

CodeRabbit Commands (Invoked using PR/Issue comments)

Type @coderabbitai help to get the list of available commands.

Other keywords and placeholders

  • Add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.
  • Add @coderabbitai summary to generate the high-level summary at a specific location in the PR description.
  • Add @coderabbitai anywhere in the PR title to generate the title automatically.

Status, Documentation and Community

  • Visit our Status Page to check the current availability of CodeRabbit.
  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

Copy link

github-actions bot commented Aug 14, 2025

Security Scan Results for PR

Docker Image Scan Results

Package Version Vulnerability Severity
golang.org/x/crypto v0.31.0 CVE-2025-22869 HIGH
golang.org/x/oauth2 v0.24.0 CVE-2025-22868 HIGH
stdlib 1.22.10 CVE-2025-47907 HIGH

Source Code Scan Results

🎉 No vulnerabilities found!

Copy link

✨ Benchmark results

  • Requests per second: 20,146
  • Requests with 200 status code: n,ull
  • P99 latency: 0.007219764

⚡ Benchmark Comparison

Metric This PR Latest version
RPS 20,146 961
200 n,ull 173,082
P99 0.007219764 0.199445658

…operations

Co-authored-by: jakeb994 <jakeb994@gmail.com>
@abnegate abnegate marked this pull request as ready for review August 14, 2025 10:22
@abnegate abnegate merged commit 2dd8dd8 into feat-txn Aug 14, 2025
8 of 9 checks passed
@abnegate abnegate deleted the cursor/enforce-operations-cap-per-transaction-6dd5 branch August 14, 2025 10:23
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.

7 participants