perf: spanner mutation limit increase to 80000 max_total_records#2327
Conversation
13101bf to
30a52ea
Compare
30a52ea to
3693933
Compare
| | Table | Description | | ||
| | ------------------ | ------------------------------------------------------------------------------------------------------------ | | ||
| | `user_collections` | Per-user metadata about each collection (modified time, record count, total bytes). Parent of `bsos`/`batches` via `INTERLEAVE IN PARENT`. | | ||
| | `bsos` | Stores Basic Storage Objects (BSOs) the synced records. Interleaved in `user_collections`. | |
There was a problem hiding this comment.
| | `bsos` | Stores Basic Storage Objects (BSOs) the synced records. Interleaved in `user_collections`. | | |
| | `bsos` | Stores Basic Storage Objects (BSOs), the synced records. Interleaved in `user_collections`. | |
| | `batches` | Temporary staging row per in-progress batch upload. Interleaved in `user_collections`. | | ||
| | `batch_bsos` | BSOs belonging to a batch, pending commit. Interleaved in `batches`. | | ||
|
|
||
| All `bsos` and `batches` rows are physically co-located with their `user_collections` parent Spanner's interleaving puts a user's collection metadata, BSOs, and pending batches on the same split. `ON DELETE CASCADE` from `batches` to `batch_bsos` and `user_collections` `bsos`/`batches` means parent deletes wipe descendants atomically. |
There was a problem hiding this comment.
| All `bsos` and `batches` rows are physically co-located with their `user_collections` parent Spanner's interleaving puts a user's collection metadata, BSOs, and pending batches on the same split. `ON DELETE CASCADE` from `batches` to `batch_bsos` and `user_collections` `bsos`/`batches` means parent deletes wipe descendants atomically. | |
| All `bsos` and `batches` rows are physically co-located with their `user_collections` parent. Spanner's interleaving puts a user's collection metadata, BSOs, and pending batches on the same split. `ON DELETE CASCADE` from `batches` to `batch_bsos` and `user_collections` `bsos`/`batches` means parent deletes wipe descendants atomically. |
|
|
||
| ### Env var | ||
|
|
||
| `max_total_records` is set in production via the `SYNC_SYNCSTORAGE__LIMITS__MAX_TOTAL_RECORDS` environment variable with no redeploy required to change it. The standalone-server default in `syncstorage-settings/src/lib.rs` is 10,000 and applies to non-Spanner backends; the Spanner production deployment always overrides it. |
There was a problem hiding this comment.
no redeploy required to change it
I'm having trouble picturing how this works. How does the running process get the new value?
There was a problem hiding this comment.
Sry, this was in the local context when working with the config.local.toml which I altered to reflect the new value. Good catch
There was a problem hiding this comment.
When working locally, one needs to restart the service when the settings changed no?
There was a problem hiding this comment.
Yup, and often just a fresh cargo build (or more scoped command depending on which db)
There was a problem hiding this comment.
I'm more confused. Assuming that "Yup" is "yup the service needs to be restarted when changing settings", then I don't understand how that led to "no redeploy required".
I don't get the relevance of cargo build. That compounds my confusion.
Are we talking about different things?
There was a problem hiding this comment.
Haha, yeah maybe so. It's really not relevant anymore since its gone now. I just meant for local development: cargo build just means having to recompile the project after changing an env variable
There was a problem hiding this comment.
having to recompile the project after changing an env variable
I don't see why that'd be necessary since SYNC_SYNCSTORAGE__LIMITS__MAX_TOTAL_RECORDS is an existing setting.
|
@pjenvey @chenba Changes made in Webservices infra. Lmk if anything remains or needs to be added to the context here |
508d769 to
fbfa8bd
Compare
|
Since we are about to drop the secondary indexes, can the patch be updated accordingly? |
fbfa8bd to
7f2dfd8
Compare
|
We can merge this in,but will land final update for the higher limit once we finally get rid of last secondary index. |
|
@taddes We'll go ahead and drop |
Sounds good, just drop the approve next wk and I'll land it 👍 |
7f2dfd8 to
fe65f21
Compare
pjenvey
left a comment
There was a problem hiding this comment.
can land this as is now but I figured you'd drop the secondary indices paragraph/numbers first
fe65f21 to
e95e9c4
Compare
| # max_quota_limit = 200000000 | ||
| syncstorage.enabled = true | ||
| syncstorage.limits.max_total_records = 1666 # See issues #298/#333 | ||
| syncstorage.limits.max_total_records = 9984 # Post-#2382 (no `bsos` secondary indexes); see docs/src/syncstorage/syncstorage-spanner-db.md |
There was a problem hiding this comment.
Either remove it or mention what #2382 is. Or make it an url?
c7bcaf3 to
ca87d88
Compare
Description
Much of this was understanding the underlying mechanics of mutations and updating the proper math to reflect the mutation limit capacity ok 80,000 in relation to
max_total_recordsSome details on ths: Spanner caps mutations at 80,000 per commit, and each BSO row in the batch commit costs up to 12 mutations in the worst case (4 primary-key columns + 4 non-PK columns + a delete-and-insert on each of the two secondary indexes). On top of that, the commit pays a fixed 13 mutations of overhead: 6 for the parent
user_collectionsupsert, 1 for the batch delete, and 6 to refresh quota counts. Solving 12N + 13 <= 80,000 gives a ceiling of 6,665 records, so we pick 6,656 (= 1,664 × 4) to preserve the same propotion the legacy 1,664/20,000 cap had, leaving 115 mutations of margin for breathing room.docs/src/syncstorage/syncstorage-spanner-db.mdas the canonical reference for the Spanner backend with schema, full configuration option, and per-commit mutation budget.max_total_recordsinconfig/local.example.tomlfrom 1666 to 6656 to match the value to Spanner's 80,000-mutation-per-commit ceiling.To Check
make doc-prevrenders the new page cleanly (mermaid diagram + internal links)/info/configurationreturnsmax_total_records: 6656against the bumped dev configIssue(s)
Helm Chart update here
Closes STOR-190.