Repository navigation
fix(storage-sqlite): keep each partition key in one parallel Scan segment - #1087
Conversation
…ment A parallel Scan on the SQLite backend put a row in a segment by its rowid. The rowid is the order in which SQLite stored the row, so the items of one partition key spread over the segments. DynamoDB returns all items of a partition key from one segment, on a table and on a global secondary index. Measured in us-east-1 on 13 and 14 Nov 2026, each Scan twice. The scan predicate now puts a row in a segment by the CRC32 of its pk column text modulo TotalSegments. The MongoDB backend applies the same rule. A SQL function, extenddb_scan_segment, evaluates it per row. Every connection of the engine's pool registers the function when it opens. On a GSI the pk column holds the index partition key, so the rule applies to it unchanged. The start-key check applies the same Rust function to the key text. It no longer reads the row, and a deleted start key still gets a definite answer. A Scan without Segment, the order of items within a segment, and the other backends are unchanged. Fixes #1046.
On SQLite, the start-key check of a parallel Scan hashed the first HASH attribute of the key. The pk column of an index with two or more HASH attributes holds the text of all of them, which the scan predicate hashes. The check therefore refused the LastEvaluatedKey such a Scan had returned. It now builds the key text with composite_pk_to_text, as the predicate does. scan_segment moves to a module of its own in extenddb_storage::util. The SQLite SQL function, the SQLite start-key check and both MongoDB sites call it, so one rule remains. The clamp of the segment count stays, so a NULL or 0 count in SQL cannot divide by zero. The SQL function answers NULL only for a NULL pk. When SQLite cannot convert another value to text, it reports an out of memory error instead. Tests: the GSI with two HASH attributes is a row of the Rust test's data table. The in-memory engine helper of the restore job tests is shared. The wire test pages each segment with the bounded helper, now in conftest. Repeated comments and a test that repeated the first one are gone.
Main is at 80490c6, 43 commits after the base of this branch. One file conflicted: crates/storage/src/util/mod.rs. #588 adds mod prefix and pub use prefix::string_prefix_upper_bound, and this branch adds mod scan_segment and pub use scan_segment::scan_segment. The merge keeps all four lines, each list in name order. Git merged eight other files that both sides change, with no overlap: Cargo.lock, crates/storage-sqlite/src/data/query_scan.rs, crates/storage-sqlite/src/lib.rs, crates/storage-sqlite/src/sqlite_util.rs, crates/storage-sqlite/src/store.rs, crates/storage/Cargo.toml, crates/storage/src/lib.rs and tests/conftest.py.
#1009 added the wasm32 build of this crate after this branch added the SQL function extenddb_scan_segment. After the merge of main, the wasm32 build does not compile. sqlite_util.rs imports libsqlite3_sys, which the wasm32 build does not have, and the SqliteConnection of the wasm_sqlx shim has no lock_handle method. On wasm32, sqlite_util.rs takes SQLite's C API from sqlite-wasm-rs, which exports the same names and types. Both targets use the same scan_segment_sql. The shim gets lock_handle and as_raw_handle, the names sqlx gives them, so register_scan_segment is the same code on both targets. The Scan SQL calls the function on both targets, so the wasm32 build must register it too. The parity corpus gets a parallel Scan of the Page table, segment 0 of 3. It counts the two keys whose CRC32 modulo 3 is 0, k0 and k2. CI's test job runs the corpus natively, and the corpus step of the WebAssembly workflow runs it on wasm32.
Main is at 5252eda. The last merge of main was at 80490c6, and main has four commits since then: #864, #895, #929 and #949. They change CI workflows, the auth and fuzz crates, a PostgreSQL test and the security manual. None of them changes a file that this branch changes, so git merged them with no conflict.
…mments The comment on libsqlite3-sys named only the online-backup copy. Since 9067287 the crate also registers the SQL function extenddb_scan_segment through it. The comment on sqlite-wasm-rs said that the wasm_sqlx shim stands in for sqlx and libsqlite3-sys. Since 7274a30, sqlite_util.rs also calls the sqlite-wasm-rs C ABI to register the function on wasm32. Both comments now name the function.
The paragraph said that a backend whose segments depend on storage identity must accept a start key that it cannot resolve. Its reason was that DynamoDB accepts an ExclusiveStartKey that no longer exists. After this branch, no backend assigns segments by storage identity. PostgreSQL, MongoDB and SQLite hash the key text, and Cassandra computes token(?) of it. DynamoDB also refuses a deleted start key from another segment (us-east-1, 17 Nov 2026, each request sent twice). The doc of the Cassandra scan_key_in_segment_impl named the rule of that paragraph, so this commit deletes that clause too.
The measurement of 13 and 14 Nov 2026 has no Limit. The expectation for paged segments comes from a measurement in us-east-1 on 17 Nov 2026. It used a GSI with two HASH attributes, 12 items, TotalSegments 3 and Limit 1. Each pair of HASH values came back from one segment, and each item came back once.
On main, SQLite read the row of the start key to find its segment, and it accepted a start key that had no row. This branch computes the segment from the key, so ExtendDB refuses a start key from another segment also when its item no longer exists. No test sent a deleted start key or checked the refusal message. A new data table in tests/test_scan_segments.py holds the answers that DynamoDB gave in us-east-1 at 09:22 UTC on 17 Nov 2026, each request sent twice. The table has 20 items keyed on pk S HASH, and each Scan reads Segment 0 of TotalSegments 4 with ConsistentRead. The test finds the segment of each key on the target first. - A start key of an existing item from another segment: 400 ValidationException with the full message. - The same key after the test deletes its item: 400 with the same message. - A deleted start key from segment 0: 200. The row checks the status only, because the items after the start key depend on the hash of the target.
On SQLite, a parallel Scan that pages across the upgrade can be refused, miss items or get items twice. The section Behavior Changes by Release of the upgrade manual now says so, with the clients it affects and what to do. The entry goes after the last v1.1.0 entry of the section.
navareamol
left a comment
There was a problem hiding this comment.
I have one test request and one number I cannot reproduce.
-
Nothing outside the wasm corpus pins the hash that
scan_segmentuses.scan_segment_tests.rsandtests/test_scan_segments.pycheck that each partition key comes from one segment and each item once. They pass for any hash that the scan filter and the start-key check share. I changedscan_segmentincrates/storage/src/util/scan_segment.rstocrc32fast::hash(pk).wrapping_add(1) % totalon b3baff0.scan_segment_testspassed,cargo test -p extenddb-storage --libpassed (290), and only theextenddb-wasm-adapterparity case "Scan Page with Segment 0 of 3 counts k0 and k2" failed. That case runs the SQLite path. The description says the MongoDB segments stay the same. I think a changed hash would move MongoDB segments and no MongoDB test would fail. Could you add a unit test next toscan_segmentwith fixed values (k0,k1,k2with 3 segments give 0, 1, 0) and the clamp (total_segments0, 1 and a negative value)? -
The description says
cargo test -p extenddb-storage --libgives 292 passed at b3baff0. I get 290 passed, 0 failed at that commit. The other counts match (storage-sqlite 330 with the twowrite_lock_testspassing here, storage-mongodb 190 and 84 ignored, storage-cassandra 192). Which command gives 292? If it needs a feature flag, could the description say which?
The branch has a merge conflict with main, so it needs a merge of main before it can land.
I will approve once the test in point 1 is added.
Two files conflicted. In crates/storage-sqlite/src/data/query_scan.rs, main (#1166) changed the rowid query of the start-key check, which this branch deletes, so the merge keeps the check of this branch. In docs/manuals/07-upgrade-manual.md, main (#1514) moved the ClientRequestToken entry, and this branch added its entry after the old place. The merge keeps the ClientRequestToken entry of main. The entry of this branch becomes "v1.2.0: SQLite parallel Scan segments follow the partition key". It goes after the v1.2.0 entries of main, because v1.1.0 does not include this change. Its text names 1.1.0 as the release before the change.
A unit test next to scan_segment checks fixed segments. k0, k1 and k2 with 3 segments give 0, 1 and 0, and k0 with 1,000,000 segments gives 500,351. A count above u32::MAX gives the whole CRC32 of k0. A count of 1, 0 or -3 gives segment 0. Before, only the parity case of the wasm adapter pinned the hash. The SQLite and MongoDB scan filters and start-key checks call this function. So a change to the hash or to the clamp now fails a test of extenddb-storage.
8fe573f merges main at c8e66fb and resolves the conflicts in |
…rder The branch of #1220 is at 57c4d7a, which merges main at 5826e1b. This branch last had it at 4f3e0f2, with main at c8e66fb. Git merged docs/manuals/07-upgrade-manual.md with no conflict. #1087 added its v1.2.0 entry after the other v1.2.0 entries of main. The entry of #1220 and the entry of this branch follow it, in that order. No other file that this branch changes moved.
Main is at 5826e1b. This branch last had main at c8e66fb. Since then, four PRs merged into main: #1446, #1531, #1466 and #1087. One file conflicted. In docs/manuals/07-upgrade-manual.md, #1087 added its v1.2.0 entry after the other v1.2.0 entries of main, where this branch has its entry. The merge keeps the entries of main first, then the entry of this branch. Main changed no other file that this branch changes.
Main is at 5826e1b, one commit past b6c8595: #1087. #1087 adds its v1.2.0 entry to "Behavior Changes by Release" in docs/manuals/07-upgrade-manual.md after the other v1.2.0 entries of main, where this branch has its entry. That is the one conflict. The merge keeps both entries without change: the entry of #1087 first, then the entry of this branch, before the v1.1.0 entries. No other file has changes on both sides.
Main is at 5826e1b, three commits past c057660: #1531, #1466 and #1087. In docs/manuals/07-upgrade-manual.md, #1531 adds a v1.2.0 entry at the top of "Behavior Changes by Release", and git merged it with no conflict. #1087 adds its v1.2.0 entry after the other v1.2.0 entries of main, where this branch has its entry. That is the one conflict. The merge keeps both entries without change: the entry of #1087 first, then the entry of this branch, before the v1.1.0 entries. No other file has changes on both sides.
Main is at 5826e1b, three commits past c057660: #1531, #1466 and #1087. In docs/manuals/07-upgrade-manual.md, #1531 adds a v1.2.0 entry at the top of "Behavior Changes by Release", and git merged it with no conflict. #1087 adds its v1.2.0 entry after the other v1.2.0 entries of main, where this branch has its entry. That is the one conflict. The merge keeps both entries without change: the entry of #1087 first, then the entry of this branch, before the v1.1.0 entries. Git merged three other files with no conflict: - crates/storage-sqlite/src/data/data_engine.rs: #1087 changes scan_key_in_segment to compute the segment from the key, with no read of the data table. This branch maps the error of a dropped data table to StorageError::TableNotFound in the other data-plane calls, and it does not change scan_key_in_segment. - crates/storage-sqlite/src/lib.rs: #1087 declares the scan_segment_tests module, and this branch declares deleting_window_data_tests. - crates/storage-cassandra/tests/direct_integration.rs: #1531 declares the update_item_retry module, and this branch declares deleting_window.
Main is at 5826e1b, three commits past c057660: #1531, #1466 and #1087. In docs/manuals/07-upgrade-manual.md, #1531 adds a v1.2.0 entry at the top of "Behavior Changes by Release", and git merged it with no conflict. #1087 adds its v1.2.0 entry after the other v1.2.0 entries of main, where this branch has its entry. That is the one conflict. The merge keeps both entries without change: the entry of #1087 first, then the entry of this branch, before the v1.1.0 entries. No other file has changes on both sides. #1087 changes how SQLite puts items in parallel Scan segments. This branch changes the Scan request checks in crates/engine, and #1087 changes no file in that crate.
Main is at 5826e1b, three commits past c057660: #1531, #1466 and #1087. In docs/manuals/07-upgrade-manual.md, #1531 adds a v1.2.0 entry at the top of "Behavior Changes by Release", and git merged it with no conflict. #1087 adds its v1.2.0 entry after the other v1.2.0 entries of main, where this branch has its entry. That is the one conflict. The merge keeps both entries without change: the entry of #1087 first, then the entry of this branch, before the v1.1.0 entries. No other file has changes on both sides.
Main is at 44a7b79, four commits past db8a90d: #1466, #1087, #768 and #1296. #1087 adds its v1.2.0 entry to docs/manuals/07-upgrade-manual.md after the other v1.2.0 entries of main, where this branch has its entry. That is the one conflict. The merge keeps both entries without change: the entry of #1087 first, then the entry of this branch, before the v1.1.0 entries. Git merged three other files with no conflict: - CONTRIBUTING.md: #1466 describes devtools/freeze-migrations in the step that freezes the released bodies. This branch gives the example migration the id 14 and adds migration 13 to the list of ids in use. - crates/storage-mongodb/src/data_engine.rs: #1087 computes the parallel Scan segment with scan_segment in scan_key_in_segment and in scan_impl. This branch changes other functions. - crates/storage/src/util/mod.rs: #1087 declares and exports scan_segment, and this branch declares and exports control_chars.
Main is at 44a7b79, five commits past c057660: #1531, #1466, #1087, #768 and #1296. In docs/manuals/07-upgrade-manual.md, #1531 adds a v1.2.0 entry at the top of "Behavior Changes by Release", and git merged it with no conflict. #1087 adds its v1.2.0 entry after the other v1.2.0 entries of main, where this branch has its entry. That is the one conflict. The merge keeps both entries without change: the entry of #1087 first, then the entry of this branch, before the v1.1.0 entries. Git merged crates/storage-sqlite/src/data/query_scan.rs with no conflict. #1087 replaces the rowid rule of the parallel Scan with the SQL function extenddb_scan_segment. It computes the segment of a start key from the key alone. This branch sets creation_date_time in the TableKeyInfo of the test helper key_info. The tests that #1087 adds in crates/storage-sqlite/src/scan_segment_tests.rs build each TableKeyInfo from a clone, so they need no change for the new field.
Main is at 44a7b79, six commits past c8e66fb: #1446, #1531, #1466, #1087, #768 and #1296. In docs/manuals/07-upgrade-manual.md, #1446 and #1531 add v1.2.0 entries at the top of "Behavior Changes by Release", and git merged them with no conflict. #1087 adds its v1.2.0 entry after the other v1.2.0 entries of main, where this branch has its entry. That is the one conflict. The merge keeps both entries without change: the entry of #1087 first, then the entry of this branch, before the v1.1.0 entries. Git merged five other files with no conflict: - crates/storage-cassandra/tests/direct_integration.rs: #1531 declares the update_item_retry module, and this branch declares gsi_backfilling. - crates/storage-mongodb/src/table_engine.rs: #1446 changes DeleteTable. It marks the table DELETING by table_id, and it removes the tags and the table document in one transaction. This branch changes create_table_impl_inner, index_info_by_table_id_impl and doc_to_table_description_in. - crates/storage-sqlite/src/lib.rs: #1087 declares the scan_segment_tests module, and this branch declares gsi_backfilling_tests. - crates/storage-sqlite/src/store.rs: #1087 registers extenddb_scan_segment on each connection of the pool. This branch adds the gsi_backfills field and gsi_creating_phase_delay. - crates/storage/src/lib.rs: #1087 rewrites the doc comment of scan_key_in_segment, and this branch declares the gsi_backfill module.
Main is at 44a7b79, five commits past c057660: #1531, #1466, #1087, #768 and #1296. In docs/manuals/07-upgrade-manual.md, #1531 adds a v1.2.0 entry at the top of "Behavior Changes by Release", and git merged it with no conflict. #1087 adds its v1.2.0 entry after the other v1.2.0 entries of main, where this branch has its entry. That is the one conflict. The merge keeps both entries without change: the entry of #1087 first, then the entry of this branch, before the v1.1.0 entries. Git merged two other files with no conflict: - crates/storage-mongodb/src/data_engine.rs: #1087 computes the parallel Scan segment with scan_segment in scan_key_in_segment and in scan_impl. This branch changes the write functions and their retries at other lines. - crates/storage/src/lib.rs: #1087 rewrites the doc comment of scan_key_in_segment, and this branch declares the request_clock module.
Main is at 44a7b79, six commits past c8e66fb: #1446, #1531, #1466, #1087, #768 and #1296. In docs/manuals/07-upgrade-manual.md, #1446 and #1531 add v1.2.0 entries at the top of "Behavior Changes by Release", and git merged them with no conflict. #1087 adds its v1.2.0 entry after the other v1.2.0 entries of main, where this branch has its entry. That is the one conflict. The merge keeps both entries without change: the entry of #1087 first, then the entry of this branch, before the v1.1.0 entries. Git merged four other files with no conflict: - Cargo.lock: #1087 adds crc32fast to the dependencies of extenddb-storage, and this branch adds form_urlencoded and tempfile to the dependencies of extenddb-storage-sqlite. - crates/storage-sqlite/Cargo.toml: #1087 rewrites the comments of libsqlite3-sys and sqlite-wasm-rs. This branch adds form_urlencoded and the tempfile dev-dependency. - crates/storage-sqlite/src/lib.rs: #1087 declares the scan_segment_tests module, and this branch declares file_mode and sqlite_uri. - crates/storage-sqlite/src/store.rs: #1087 registers extenddb_scan_segment on each connection of the pool, in after_connect. This branch calls file_mode::prepare before the pool connects, and it removes the mode change after the connect. The pool keeps the after_connect of main.
Main is at 44a7b79, four commits past db8a90d: #1466, #1087, #768 and #1296. #1087 adds its v1.2.0 entry to docs/manuals/07-upgrade-manual.md after the other v1.2.0 entries of main, where this branch has its entry. That is the one conflict. The merge keeps both entries without change: the entry of #1087 first, then the entry of this branch, before the v1.1.0 entries. Git merged two other files with no conflict: - crates/storage-mongodb/src/data_engine.rs: #1087 computes the parallel Scan segment with scan_segment in scan_key_in_segment and in scan_impl. This branch changes the TransactWriteItems functions at other lines. - crates/storage/src/lib.rs: #1087 rewrites the doc comment of scan_key_in_segment, and this branch adds the transact exports.
Main is at 44a7b79, six commits past c8e66fb: #1446, #1531, #1466, #1087, #768 and #1296. In docs/manuals/07-upgrade-manual.md, #1446 and #1531 add v1.2.0 entries at the top of "Behavior Changes by Release", and git merged them with no conflict. #1087 adds its v1.2.0 entry after the other v1.2.0 entries of main, where this branch has its entry. That is the one conflict. The merge keeps both entries without change: the entry of #1087 first, then the entry of this branch, before the v1.1.0 entries. No other file has changes on both sides.
…-time The merge takes f583547, the last head of #1093 before main merged it as 1e2ebdd. The last merge took b8f73c4. Since then, #1093 merged main at 1174651, eight PRs past db8a90d: #1466, #1087, #768, #1296, #1485, #1228, #1325 and #1443. Git merged without a conflict. Two files of this branch have changes on both sides: - crates/storage/src/util/mod.rs: #1087 declares and exports scan_segment, and this branch declares and exports throughput. - docs/differences-from-dynamodb.md: #1443 changes the control_plane_delay_seconds default to 0.25 in two rows, and this branch adds the LastIncreaseDateTime row to the Control Plane table.
Main is at 1e2ebdd, ten commits past db8a90d: #1466, #1087, #768, #1296, #1485, #1228, #1325, #1443, #1269 and the squash commit of #1093. One file conflicted: docs/manuals/07-upgrade-manual.md. #1093 adds its v1.2.0 entry at the top of "Behavior Changes by Release", where this branch has its entry. The merge keeps both entries without change. The entry of this branch stays first. The entry of #1093 comes next, above the other v1.2.0 entries of main. #1087 adds its entry after the other v1.2.0 entries of main, and git merged it with no conflict. Git merged four other files with no conflict: - crates/core/src/validation/mod.rs: #1228 adds the pattern clause for an empty value in validate_name_member. This branch declares the table_name_length module near the top of the file. - crates/server/src/table_name_gate.rs: #1296 adds has_no_table_member and an arm of check_table_name_chars for the six operations that have no table member. This branch checks none of those operations. - crates/wasm-adapter/parity/corpus.json: #1087 adds a Scan case, and #1228 changes the text of a ListBackups case. This branch changes other cases. - docs/manuals/10-security-model.md: #1325 adds the Content-Security-Policy line of the console. This branch changes the line on the requests that get an answer before the IAM decision.
Changes since the last review
mainat c8e66fb. Two files conflicted. Incrates/storage-sqlite/src/data/query_scan.rs, fix(deps): move to sqlx 0.9.1 for the SQLite fix of RUSTSEC-2026-0459 #1166 (sqlx 0.9.1) changed the rowid query of the start-key check, which this PR deletes. The merge keeps the check of this PR. Indocs/manuals/07-upgrade-manual.md, chore(release): bump version to 1.1.0 #1514 moved theClientRequestTokenentry, and the entry of this PR sat after the old place. The merge keeps the entry ofmain. The entry of this PR becomes "v1.2.0: SQLite parallel Scan segments follow the partition key". It goes after the v1.2.0 entries ofmain, because the v1.1.0 release of 27 Nov 2026 does not include this change. Its text names 1.1.0 where it named 1.0.0.scan_segmentincrates/storage/src/util/scan_segment.rs, with fixed segments.k0,k1andk2with 3 segments give 0, 1 and 0, andk0with 1,000,000 segments gives 500,351. A count aboveu32::MAXgives the whole CRC32 ofk0, and a count of 1, 0 or -3 gives segment 0. With the hash changed tocrc32fast::hash(pk).wrapping_add(1) % total, the test fails atk0with 3 segments. Without the clamp to 1, it fails at the count of 0.cargo test -p extenddb-storage --libgives 290 passed. The 292 of the last body came from one run of five packages:cargo test -p extenddb-storage -p extenddb-storage-sqlite -p extenddb-storage-mongodb -p extenddb-storage-cassandra -p extenddb-wasm-adapter --lib. The backend crates turn on thetest-utilfeature ofextenddb-storagein their dev-dependencies, so that run compiled two more storage tests.Before that, since 7274a30:
mainat 5252eda, four commits after the last merge ofmain. None of the four changes a file of this PR, so the merge has no conflict.tests/test_scan_segments.pyfor the start-key check of a parallel Scan. The table holds the answers that DynamoDB gave in us-east-1 at 09:22 UTC on 17 Nov 2026, each request sent twice. A start key of an existing item from another segment gets 400ValidationException. The same key gets the same answer after the test deletes its item. A deleted start key from segment 0 gets 200. The test asserts the status, the error type and the full message by equality.docs/manuals/07-upgrade-manual.md, as v1.1.0. 8fe573f makes it a v1.2.0 entry.crates/storage-sqlite/Cargo.toml. The crate also registersextenddb_scan_segmentthroughlibsqlite3-sys, and on wasm32sqlite_util.rscalls the C ABI ofsqlite-wasm-rsto register it.scan_key_in_segmentdoc. It said that a backend whose segments depend on storage identity must accept a start key that it cannot resolve. The reason it gave was that DynamoDB accepts a start key that no longer exists. After this PR no backend assigns segments by storage identity, and DynamoDB refuses a deleted start key from another segment. The doc of the Cassandrascan_key_in_segment_implloses the clause that named the paragraph.scan_segment_tests.rsandtests/test_scan_segments.pyto the measurement withLimit1 on 17 Nov 2026.What
On SQLite, a parallel Scan now returns all items of a partition key from one segment, on a table and on a GSI. A row goes to segment
crc32(partition key text) % TotalSegments. The MongoDB backend already uses this rule.scan_implfilters with a SQL function,extenddb_scan_segment(pk, total), which each connection of the engine's pool registers inafter_connect. The function callsscan_segmentinextenddb_storage::util. sqlx has no API for a scalar function, so the registration callssqlite3_create_function_v2throughlibsqlite3-sys. The crate already useslibsqlite3-sysfor the backup API. On wasm32 the registration calls the same C function throughsqlite-wasm-rs, the SQLite that the crate'swasm_sqlxshim drives. The shim getslock_handleandas_raw_handle, the names sqlx gives them, so both targets register the function with the same code.composite_pk_to_text, the text that thepkcolumn stores. It no longer reads the row. So ExtendDB refuses a start key from another segment, also when its item no longer exists. It accepts a deleted start key from the same segment. DynamoDB gave both answers on 17 Nov 2026.scan_segment, so one function computes the segment on both backends. A unit test next toscan_segmentpins its segments for fixed keys and counts.pk. If SQLite cannot convert a value to text, the function reports an out of memory error.Why
DynamoDB returns all items of a partition key from one segment. It did so on a table and on a GSI in us-east-1 on 13 and 14 Nov 2026, and each Scan went out twice. SQLite put a row in a segment by its rowid, so the items of one partition key came back from two or more segments. PostgreSQL, MongoDB and Cassandra already keep each partition key in one segment.
Closes #1046
Other open PRs
crates/storage-sqlite/src/lib.rs, where both add module lines. The PR that merges second keeps both sets of lines.crates/storage-sqlite/src/sqlite_util.rs, where both add a function afterset_connection_pragmas. The PR that merges second keeps both functions.docs/manuals/07-upgrade-manual.md, fix(mongodb): retry an unconditional PutItem that conflicts on a GSI table #487, fix(core): send DynamoDB's text for a B value that does not decode #1260, fix(core): read a B value with its padding left out or cut short #1313, fix(core): read a B value with "=" or another character inside #1355, fix(core): give a set with duplicate members DynamoDB's text #1368, fix(engine): end a failed ImportTable as DynamoDB does #1370, fix(server): count a request refused in the authorization step in UserErrors and RequestCount #1427 and eliseong's fix(core): name the capacity member and value when it is below 1 #1442 each add a v1.2.0 entry after the v1.2.0 entries ofmain. This PR puts its entry at the same place, so each of them conflicts with this PR there. The PR that merges second keeps both entries.A Scan of a GSI with two HASH attributes stops after the first page of the Scan, or of each segment, on SQLite. That code is older than this PR, and #1083 tracks it.
Testing done
cargo test -p extenddb-storage --libgives 291 passed, the newscan_segmenttest among them. With--features test-utilit gives 295 passed.cargo test -p extenddb-storage-sqlite --libat fa15752: 336 passed, 2 failed, 1 ignored. The 2 failures arebackup_catalog::write_lock_tests, which fail the same way on main in the test environment, at a file owner check (storage-sqlite: the two write_lock_tests fail when an ancestor of the Cargo target directory is owned by another user #1414). The data-table test ofscan_segment_tests.rsscans 11 segment counts on a table, on a GSI and on a GSI with two HASH attributes.partition key p0 came back from segments 0 and 1. With the start-key check on the first HASH attribute only, the row of the GSI with two HASH attributes failed.cargo test -p extenddb-storage-cassandra --libgives 192 passed.cargo test -p extenddb-storage-mongodb --libgives 197 passed, and cargo ignored the 84 tests that need a server.tests/test_scan_segments.py(37 cases) andtests/test_read_paging.pypassed 52 tests against a SQLite server. They passed 52 tests against a MongoDB server on a one-node replica set of MongoDB 7.0.45. Both servers come from a build at fa15752.scan_segmentof b3baff0 compares them for everyTotalSegmentsfrom 1 to 1,000,000. All 592,000,000 sampled comparisons agree, and so do the 296,148,000 comparisons that cover every segment of 1 to 2,000 segments.cargo +1.97.0 fmt --all -- --checkis clean. Both clippy commands of.github/workflows/clippy.ymlwith-D warningsare clean onextenddb-storage,extenddb-storage-sqlite,extenddb-storage-mongodb,extenddb-storage-cassandraandextenddb-wasm-adapter, and so iscargo +1.94.0 check --all-targetson the same crates.--collect-onlycollects 7341 tests intests/and 820 intests/python, with no error.cargo test -p extenddb-wasm-adapter --lib --test paritypasses (4 tests). At 7274a30, with the registration call deleted fromafter_connect, the parity case failed withInternalServerError.cargo test -p extenddb-storage-postgres --test doc_version_literalspasses (3 tests)..github/workflows/wasm.ymlpasses. fix(core): read the latency segment clock through web_time #1482, now onmain, fixed the WebAssembly build that fix(metrics): bound latency segment memory by summing into fixed time buckets #398 broke. The wasm32 test suites needwasm-bindgen-test-runner, which the test host does not have, so they did not run locally. In CI the WebAssembly workflow runs them, and its corpus step runs the new case on wasm32.TotalSegments4 took 0.67 to 0.73 s together. Each set ran three times, with a host load average of 19 to 22.Line counts at fa15752: production +164 -122, tests +555 -21, docs +11 -1.
Checklist
cargo test --workspace)cargo fmt --check)cargo clippy -- -W clippy::pedantic)Storagetrait, auth model, on-diskformat, or public CLI surface, an RFC has been accepted or is linked
below. Otherwise, an ADR captures the decision (link below).
ADR / RFC: n/a
Breaking changes
On SQLite, the segment of an item in a parallel Scan changes from
rowid % TotalSegmentstocrc32(partition key text) % TotalSegments. A parallel Scan that pages across the upgrade sends start keys from the old rule. ExtendDB can refuse such a start key as one from another segment. The later pages use the new rule, so the client can miss items or get items twice. Start such a Scan again after the upgrade. A Scan that pages across a rollback to 1.1.0 can get the same answers.ExtendDB on SQLite also refuses a start key from another segment when its item no longer exists, as DynamoDB does. The MongoDB backend used the new rule before this change, so its segments stay the same. The upgrade manual describes the change in the entry "v1.2.0: SQLite parallel Scan segments follow the partition key".
By submitting this pull request, I confirm that my contribution is made under
the terms of the Apache License 2.0 and I agree to the Developer Certificate of
Origin (DCO). See CONTRIBUTING.md for details.