Skip to content

fix(databases): bound offset and limit for transaction-aware listing - #14964

Merged
ChiragAgg5k merged 1 commit into
mainfrom
fix/transaction-list-window
Oct 27, 2026
Merged

ChiragAgg5k merged 1 commit into
mainfrom
fix/transaction-list-window

Conversation

@ChiragAgg5k

@ChiragAgg5k ChiragAgg5k commented Oct 26, 2026 •

Copy link
Copy Markdown
Member

Reads inside a transaction merge stored rows with staged writes in memory, so the fetch window grew with the offset and an unbounded offset loaded that many rows into PHP. TransactionState now caps offset plus limit at APP_LIMIT_COUNT for these reads, with an error that points to cursor pagination.

Test: TransactionStateTest::testOffsetPastTheWindowInATransactionIsRejected (fails without the change).

Verified with composer lint, PHPStan on the changed files and vendor/bin/phpunit tests/unit/Databases.

Related: appwrite-labs/cloud#6674

Transaction reads merge stored rows with staged writes in memory, so the fetch window grows with the offset. Cap offset plus limit at APP_LIMIT_COUNT and point callers at cursor pagination.
@luxor-code-review

luxor-code-review Bot commented Oct 26, 2026 •

Copy link
Copy Markdown

Something went wrong while processing your review.

Our team has been automatically notified and is investigating the issue. We'll reach out as soon as we have updates. In the meantime, you can retry by tagging @tenki-reviewer.

Sorry for the inconvenience.

@ghost

ghost commented Oct 26, 2026 •

Copy link
Copy Markdown

🟢 Tier S · Ready to merge

The bound is applied on the in-memory listing path, and the new rejection behavior is covered by a regression test.

Transaction-aware plain document listing now rejects requests whose offset plus limit exceeds APP_LIMIT_COUNT, with an error directing callers to cursor pagination. A unit regression test covers an offset at the cap with an additional requested row.

Verdict New comments Fixed Still open
✅ Approved 0 0 0
📂 Walkthrough · 2
File Change
src/Appwrite/Databases/TransactionState.php Bounds the in-memory transaction listing window and documents the query exception.
tests/unit/Databases/TransactionStateTest.php Adds regression coverage for rejecting an offset-plus-limit window above the cap.

Reviewed 24adfdb · Details · Comment @hansi-codes review to re-run, or mention @hansi-codes with a question.

@ghost ghost left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

🟢 Tier S · Looks good to merge. Summary

@github-actions

Copy link
Copy Markdown

Security rules

No new WARNING or ERROR findings from security rules.

6 existing findings tracked in .semgrep/baseline.json
  • php.appwrite.guest-write-without-abuse-limit (3)
  • php.appwrite.secret-compare-timing (1)
  • php.appwrite.weak-secret-env-default (2)

Posted by Checks / Rules. Re-runs update this comment in place. Rule details and baseline: .semgrep/README.md.

@github-actions

Copy link
Copy Markdown

✨ Benchmark results

Comparing main (before) → fix/transaction-list-window (after).

Metric Before After Change
🚀 Requests/sec 195.4 208.03 🟢 +6.5%
⏱️ Latency P50 88.61 ms 81.6 ms 🟢 -7.9%
⏱️ Latency P95 209.01 ms 196.75 ms 🟢 -5.9%
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 81.6 196.75 13,053 208.03 -12.26
Account 158.81 297.53 687 11.35 +9.93
TablesDB 77.26 140.8 7,099 115.55 -29.98
Storage 79.17 185.04 3,435 57.54 -2.32
Functions 121.15 239.82 1,832 31.34 +8.16

Top API waits (after)

API request Max wait (ms)
account.prefs.update 463.83
account.name.update 421.65
storage.buckets.create 414.38
functions.variables.update 412.77
functions.variables.create 385.76

@ChiragAgg5k

Copy link
Copy Markdown
Member Author

@tenki-reviewer

@luxor-code-review

luxor-code-review Bot commented Oct 27, 2026 •

Copy link
Copy Markdown

Review complete. No issues found — approved ✅.


This small change bounds the in-memory window built when paging through a transaction's uncommitted (staged) rows, throwing an Exception\Query with a message steering callers toward cursor pagination.

Files Change
src/Appwrite/Databases/TransactionState.php Adds the offset + limit > APP_LIMIT_COUNT check with a new @throws Exception\Query doc annotation in listPlainDocuments.
tests/unit/Databases/TransactionStateTest.php Adds testOffsetPastTheWindowInATransactionIsRejected covering the new bound at the APP_LIMIT_COUNT offset.

Scanners found no defects: the check is cheap and protective, cursor-based reads remain the intended escape hatch, and the error type matches existing Query exception conventions.

Reviewed commit: 24adfdb

@ChiragAgg5k
ChiragAgg5k merged commit b36a09e into main Oct 27, 2026
40 checks passed
@ChiragAgg5k
ChiragAgg5k deleted the fix/transaction-list-window branch October 27, 2026 08:58
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.

1 participant