Repository navigation
fix(server): inline LIMIT/OFFSET so TiDB Cloud accepts paged queries - #251
Merged
Merged
Conversation
i098
commented
Nov 24, 2026
i098
left a comment
Owner
Author
There was a problem hiding this comment.
no-mistakes run 01M865C566GW5EG9473Q8EGX96, validated head 9adf984.
Checked: intent, rebase, review, test, document, lint, push, PR, CI.
- review (info): the change does not itself prove the job-ledger and double-claim questions. Resolved: Cloud evidence is
tidb-six-final.log(six tests on TiDB Cloud Starter); no claim or lease defect found, thestatus = 'pending'claim guard is in base (#244). - test warning test-1 (ask-user): double claim on Cloud still open, local TiDB does not reproduce. Resolved by firstmate approval, citing the Cloud log above.
- ci finding ci-1 (ask-user): PR title 75 chars over the 72 limit. Resolved: title renamed to 68 chars, Commit standard re-ran and passed.
- Final CI: all checks pass, including Application checks. The Pages jobs are skipped.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Intent
Uhh tidb cloud starter + a d1 clone so we can switch over once free runs out
Launch: hosted Sanctum app back up and proven live
Context: production runs on TiDB Cloud Starter since #244 (main b48350f). Six server tests fail against TiDB and pass on MySQL 8.4: #245 (job ledger tests: claims each due job exactly once, fences completion by lease token, keeps renewing through a database outage, runs handlers and renews leases; action tests: lists one meeting's receipts in offset pages, records unknown when the job ceiling cuts off a submission). It is not known whether production jobs can be claimed two times on TiDB.
What Changed
server/src/db.ts: on a database withoutFULLTEXT(TiDB), thetranslatedconnection wrapper now passes each safe non-negative integerLIMIT ?orOFFSET ?bound as text in the SQL. TiDB rejects a preparedLIMIT ?. The parameter leaves the list, and other placeholders stay bound. This fixes paged queries such as a meeting's action receipts (fix(server): job ledger and action tests fail against TiDB Cloud #245).server/vitest.config.tsreads the test timeout fromSANCTUM_TEST_TIMEOUT_MS(default 30000), for a database across the internet.server/tests/actions.test.tsraises the workerceilingMsfrom 300 to aCEILING_MSof 3000, because each statement to TiDB Cloud takes about 33 ms.docs/operations.mddescribes the TiDBLIMIT ?handling and the new timeout variable.changelog.d/245.fixed.mdadds a changelog entry.Risk Assessment
✅ Low: The code change is a narrow TiDB-only rewrite of
LIMIT/OFFSETplaceholders plus a test-only ceiling and timeout. Whether the job-ledger tests and the double-claim question are settled on TiDB stays unverified until a TiDB run.Testing
The jobs and actions suites passed 22 of 22 on target code against both a disposable local TiDB v8.5.0 and MySQL 8.4.3, so there is no regression off TiDB. The offset-pages test fails on the base
db.tsand passes with the change, which proves the LIMIT/OFFSET inlining. The other five tests from issue 245 pass locally but also passed at base for the one I re-ran (the claims test). I did not re-run the other four on base. Their Cloud failures are not reproduced here, and the double-claim question stays open until a run on TiDB Cloud Starter. The change has no UI, so there are no screenshots.SANCTUM_TEST_TIMEOUT_MS=180000set for a slow disk.SANCTUM_TEST_MYSQL_URLto a Starter account allowed to CREATE/DROP DATABASE and `SANCTUM_TEST_M…inlineBoundsis not exported and the suites only pass valid integer bounds. I did not add a test that checks the source text. A listing test that passes a negative or fractional bound against TiDB w…Evidence: Jobs and actions suites on TiDB v8.5.0 with the fix: 22 of 22 passed
Evidence: Jobs and actions suites on MySQL 8.4.3: 22 of 22 passed
Pipeline
Updates from git push no-mistakes
✅ **Intent** - passed
✅ No issues found.
✅ **Rebase** - passed
✅ No issues found.
server/vitest.config.ts:8- This change does not prove the intent's job-ledger and double-claim questions.claimJobuses a literalLIMIT 1, soinlineBoundsnever touches it. TheAND status = 'pending'plusaffectedRowsguard that stops a double claim is already in base (6fd0a52). For the four job-ledger tests (jobs.test.ts:75,:100,:208,:301), the only lever here is the opt-inSANCTUM_TEST_TIMEOUT_MS. The comment says migrating one test database takes 50-110 s on TiDB Cloud. The 30 s test timeout would cover that migration, so a timeout-only failure is plausible. I could not show it without running tests. The changelog names only the LIMIT fix. The env var appears only in this config file, not indocs/operations.md. Closing fix(server): job ledger and action tests fail against TiDB Cloud #245 and the double-claim question needs a run against TiDB with the variable set; the changelog and the operations docs should also mention the override.SANCTUM_TEST_MYSQL_URLandSANCTUM_TEST_MYSQL_CA_CERTset for a Starter cluster, withSANCTUM_TEST_TIMEOUT_MSraised, and add a double-claim check against that cluster.SANCTUM_TEST_TIMEOUT_MS=180000set for a slow disk.SANCTUM_TEST_MYSQL_URLto a Starter account allowed to CREATE/DROP DATABASE and `SANCTUM_TEST_M…inlineBoundsis not exported and the suites only pass valid integer bounds. I did not add a test that checks the source text. A listing test that passes a negative or fractional bound against TiDB w…Localtidb-serverv8.5.0 (unistore),SET GLOBAL time_zone='+00:00':npx vitest run tests/jobs.test.ts tests/actions.test.tson the target commit, 22 of 22 passedWithserver/src/db.tsrestored to the base commit and-t "claims each due job|offset pages"on the same TiDB: the offset-pages test failed with ER_WRONG_ARGUMENTS 'Incorrect arguments to LIMIT'. The claims test passed.db.tswas restored afterwards.Portable MySQL 8.4.3 tarball (libaio taken from a downloaded deb into the temp dir), started with relaxed fsync settings on port 3399 with--default-time-zone=+00:00, then the same suites withSANCTUM_TEST_TIMEOUT_MS=180000: 22 of 22 passed. A first run at the default 30 s timeout failed 15 tests because migrating each test database took about 28 s on this slow disk. I treat that as a setup problem, not a product failure.The 'Table ... jobs doesn't exist' log lines also appear on MySQL 8.4.3, so they are not TiDB-specific. They look like a worker outliving suite teardown, and the tests still pass.Cleanup: stopped the processes I started (TiDB and mysqld), removed the downloaded binaries and temp data.git statusis clean.✅ **Document** - passed
✅ No issues found.
✅ **Lint** - passed
✅ No issues found.
✅ **Push** - passed
✅ No issues found.
Closes #245
Before and after (TiDB Cloud Starter, us-east-1, median round trip 32.9 ms)
Before: the six tests from #245 failed on Cloud. After: all six pass on Cloud, and the full server suite passes on MySQL 8.4 (513 of 513).
data/sanctum-tidb-jobs/tidb-six-final.log(six tests, 453 s): claims once 87 s, fences 83 s, runs handlers 74 s, keeps renewing 58 s, offset pages 50 s, job ceiling 75 s. Earlier Cloud runs:tidb-six-1.log,tidb-six-2.log,tidb-six-3.log,tidb-six-4.log. MySQL proof:mysql-full-final.log. All indata/sanctum-tidb-jobs/.LIMIT ?is rejected. Fixed by thedb.tsinlining.SANCTUM_TEST_TIMEOUT_MSraised; no code change. The claim test returned 12 distinct claims from 4 concurrent workers. No claim or lease defect was found; the base claim already guards withstatus = 'pending'(fix(server): run migrations, search and upserts on TiDB Cloud #244).inlineBoundsstays indb.ts(the one place every statement passes), and it counts?characters, so a?in a SQL string literal would misalign it.