Skip to content

perf: spanner mutation limit increase to 80000 max_total_records#2327

Merged
taddes merged 7 commits into
masterfrom
perf/spanner-mutation-limit-STOR-190
Jun 16, 2026
Merged

perf: spanner mutation limit increase to 80000 max_total_records#2327
taddes merged 7 commits into
masterfrom
perf/spanner-mutation-limit-STOR-190

Conversation

@taddes

@taddes taddes commented May 21, 2026

Copy link
Copy Markdown
Collaborator

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_records

Some 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_collections upsert, 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.

  • Add docs/src/syncstorage/syncstorage-spanner-db.md as the canonical reference for the Spanner backend with schema, full configuration option, and per-commit mutation budget.
  • Bumped dev max_total_records in config/local.example.toml from 1666 to 6656 to match the value to Spanner's 80,000-mutation-per-commit ceiling.

To Check

  • make doc-prev renders the new page cleanly (mermaid diagram + internal links)
  • /info/configuration returns max_total_records: 6656 against the bumped dev config
  • Ensure things look good in stage when we roll out update

Issue(s)

Helm Chart update here
Closes STOR-190.

@taddes taddes self-assigned this May 21, 2026
@taddes taddes force-pushed the perf/spanner-mutation-limit-STOR-190 branch 2 times, most recently from 13101bf to 30a52ea Compare May 21, 2026 19:59
@taddes taddes changed the title perf: spanner mutation limit stor 190 perf: spanner mutation limit increase to 80000 May 21, 2026
@taddes taddes changed the title perf: spanner mutation limit increase to 80000 perf: spanner mutation limit increase to 80000 max_total_records May 21, 2026
@taddes taddes marked this pull request as ready for review May 21, 2026 20:00
@taddes taddes force-pushed the perf/spanner-mutation-limit-STOR-190 branch from 30a52ea to 3693933 Compare May 21, 2026 20:09
@taddes taddes requested review from chenba and pjenvey May 22, 2026 00:31
| 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`. |

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Suggested change
| `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.

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Suggested change
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.

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

no redeploy required to change it

I'm having trouble picturing how this works. How does the running process get the new value?

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

Sry, this was in the local context when working with the config.local.toml which I altered to reflect the new value. Good catch

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

When working locally, one needs to restart the service when the settings changed no?

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

Yup, and often just a fresh cargo build (or more scoped command depending on which db)

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

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?

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

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

@chenba chenba May 26, 2026

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

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.

@taddes taddes requested a review from chenba May 22, 2026 20:26
@taddes

taddes commented May 26, 2026

Copy link
Copy Markdown
Collaborator Author

@pjenvey @chenba Changes made in Webservices infra. Lmk if anything remains or needs to be added to the context here

@taddes taddes force-pushed the perf/spanner-mutation-limit-STOR-190 branch 2 times, most recently from 508d769 to fbfa8bd Compare May 26, 2026 22:18
@chenba

chenba commented May 27, 2026

Copy link
Copy Markdown
Collaborator

Since we are about to drop the secondary indexes, can the patch be updated accordingly?

@taddes taddes force-pushed the perf/spanner-mutation-limit-STOR-190 branch from fbfa8bd to 7f2dfd8 Compare June 1, 2026 14:01
@taddes

taddes commented Jun 1, 2026

Copy link
Copy Markdown
Collaborator Author

We can merge this in,but will land final update for the higher limit once we finally get rid of last secondary index.

@pjenvey

pjenvey commented Jun 4, 2026

Copy link
Copy Markdown
Member

@taddes We'll go ahead and drop BsoExpiry early next week, so we can apply that to this doc now. LGTM otherwise

@taddes

taddes commented Jun 5, 2026

Copy link
Copy Markdown
Collaborator Author

@taddes We'll go ahead and drop BsoExpiry early next week, so we can apply that to this doc now. LGTM otherwise

Sounds good, just drop the approve next wk and I'll land it 👍

@taddes taddes force-pushed the perf/spanner-mutation-limit-STOR-190 branch from 7f2dfd8 to fe65f21 Compare June 5, 2026 02:25
pjenvey
pjenvey previously approved these changes Jun 12, 2026

@pjenvey pjenvey left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

can land this as is now but I figured you'd drop the secondary indices paragraph/numbers first

@taddes taddes force-pushed the perf/spanner-mutation-limit-STOR-190 branch from fe65f21 to e95e9c4 Compare June 15, 2026 14:57
Comment thread config/local.example.toml Outdated
# 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

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Either remove it or mention what #2382 is. Or make it an url?

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

good call

@taddes taddes force-pushed the perf/spanner-mutation-limit-STOR-190 branch 2 times, most recently from c7bcaf3 to ca87d88 Compare June 16, 2026 16:50
@taddes taddes merged commit a70ca64 into master Jun 16, 2026
24 checks passed
@taddes taddes deleted the perf/spanner-mutation-limit-STOR-190 branch June 16, 2026 23:54
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.

3 participants