Marten.ScaleTesting: daemonload over pooled sharded databases — O(databases) connection gate (#4882, epic jasperfx#486 WS6)#4890
Merged
Conversation
--databases N pools the tenants across N scaletest_dl_shard_* databases via MultiTenantedWithShardedDatabases (explicit round-robin placement, one daemon per shard). ShardConnectionSampler groups pg_stat_activity by datname so the --max-connections gate is enforced PER DATABASE, plus per-tenant catch-up verification on every shard and a database-affine placement check (per-tenant sequence in exactly the home shard). Local-scale result (25 tenants x 2 shards x 2 projections, 60s): shard peaks 16/11, all 25 tenants caught up, zero placement violations. Single-database path (--databases 1, the default) unchanged. Addresses #4882 Co-Authored-By: Claude Fable 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01XNfeNz73Q3EdiTgSeDbo96
jeremydmiller
force-pushed
the
feat/4882-sharded-daemonload
branch
from
July 7, 2026 19:36
f8d8f7a to
b76029b
Compare
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.
Closes #4882 (epic #486 WS6). Stacked on #4887 (
feat/4684-batch-instrumentation) — review/merge that first; this PR's own diff is the top two commits.What's here
Extends
daemonload(#4875) from single-database to sharded multi-tenancy with database pooling:--databases Ncreatesscaletest_dl_shard_0..N-1on the same server (--wipedrops themWITH (FORCE)first), builds the store withMultiTenantedWithShardedDatabases(registry in the master DB'sscaletest_daemonloadschema,UseExplicitAssignment), assigns tenants round-robin with explicit placement, and runs one projection daemon per shard (sharded tenancy has oneMartenDatabaseper shard; the default-tenant daemon overload is invalid there)pg_stat_activitysampling — newShardConnectionSamplerpolls once per interval on the maintenance DB and groups the store's Application-Name-attributed backends bydatname(ShardedTenancyOptions.ApplicationNamestamps every pooled connection string). Master/registry DB reported separately--max-connectionsenforced per shard database (the O(databases) gate)mt_events_sequence_{tenant}must exist in exactly its assigned shard; foreign-shard or missing-at-home sequences fail the run as cross-shard bleed--databases 1(default) is the untouched original single-DB WS2 scenario (regression-verified).Measured (local reduced scale — sibling agents share this Postgres; full scale is a CLI-knob rerun)
daemonload --databases 2 --tenants 25 --projections 2 --duration-seconds 60 --wipe --max-connections 16scaletest_dl_shard_0peak / meanscaletest_dl_shard_1peak / meanPer-shard peaks sit at the single-DB governor plateau (12–14 baseline from the #494 measurement record; 16 here with 4 appender writers steering into 2 DBs), i.e. connections scale O(databases), not O(agents) — 50 agents produced a summed peak of 27, not 50+.
Full-scale rerun for the epic record:
--databases 4 --tenants 100 --projections 2 --duration-seconds 120 --max-connections 16.🤖 Generated with Claude Code
https://claude.ai/code/session_01XNfeNz73Q3EdiTgSeDbo96