Macro is a unified workspace for teams: email, chat, docs, tasks, agents, calls, and CRM — @-linked together with shared AI memory.
TypeScript agentaiai-agentsall-in-onecrmcrm-systememaillinearmcpmessagingnotesnotionofficerustslackslack-alternativestartupstartup-toolstypescriptworkspace
fix(macrodb): bound dev replica connections and add memory (#8684)
gbirmanedeafb36dc92
diff --git a/docs/development/infrastructure.md b/docs/development/infrastructure.mdindex 6e595eea29..85ced8da0a 100644--- a/docs/development/infrastructure.md+++ b/docs/development/infrastructure.md@@ -166,6 +166,14 @@ local resources.- Only stacks listed in `services-config.json` deploy automatically. `gateway`,`macrodb`, `doppler-projects`, `monitoring`, and a few others are manual.+- Dev MacroDB's primary and replica are both configured as `db.t4g.large`+ (8 GiB). Replica resizing requires a separate `macrodb` deployment; dev's+ `applyImmediately` setting makes that resize interrupt replica connections.+ Resize the replica before deploying the DSS pool change through the service+ stack, and verify that old DSS tasks have drained before relying on the new+ cap. Three dev tasks permit 60 replica connections after rollout, or 120+ during a full overlap on later rollouts. The first rollout can permit 360:+ three old tasks at 100 connections each plus three new tasks at 20 each.- Services marked `bootstrap_pending` or `deploy_enabled: false` are skipped.- **Migrations deploy before services** and must work with the code alreadyrunning ([database guide](database.md)).diff --git a/infra/stacks/macrodb/Pulumi.dev.yaml b/infra/stacks/macrodb/Pulumi.dev.yamlindex c355870dc2..a398b8aacb 100644--- a/infra/stacks/macrodb/Pulumi.dev.yaml+++ b/infra/stacks/macrodb/Pulumi.dev.yaml@@ -17,4 +17,4 @@ config:macrodb:monitoring_interval: 60macrodb:rds_monitoring_role_arn: arn:aws:iam::569036502058:role/rds-monitoring-rolemacrodb:backup_retention_days: 1- macrodb:read_replica_instance_size: db.t4g.medium+ macrodb:read_replica_instance_size: db.t4g.largediff --git a/services/document_storage_service/AGENTS.md b/services/document_storage_service/AGENTS.mdindex 2054652e0a..0a519115b2 100644--- a/services/document_storage_service/AGENTS.md+++ b/services/document_storage_service/AGENTS.md@@ -64,6 +64,11 @@ threads, pins, recents, notifications, folders, activity.- Soup GraphQL reads a replica with multi-second lag; a read immediately aftera write through the same request needs the primary-reading loader, not thedefault one — see `crates/graphql_soup`.+- Dev's readonly pool keeps 2–20 connections per task, independently of the+ primary pool's 25–100. Once all tasks use this cap, three dev tasks allow 60+ sessions, or 120 while a rolling deployment overlaps all three. Old tasks+ retain their previous cap until they drain during the initial rollout.+ Production and local pools retain their existing primary/readonly limits.- The GraphQL calendar feed (occurrence ranges and `calendarChanges`) reads theprimary, like the REST calendar routes: a `refresh_calendar` poke goes out asa write commits, so a replica-backed delta misses the change it announces.diff --git a/services/document_storage_service/src/server.rs b/services/document_storage_service/src/server.rsindex f20e82d2bf..8e8eac57af 100644--- a/services/document_storage_service/src/server.rs+++ b/services/document_storage_service/src/server.rs@@ -247,14 +247,26 @@ pub async fn run() -> anyhow::Result<()> {"initialized db connection");+ let (readonly_min_connections, readonly_max_connections) = match config.environment {+ // Once all tasks use this cap, three dev tasks allow 60 replica sessions,+ // or 120 during a full rolling overlap.+ // Keep excess reads queued in the service instead of exhausting replica memory.+ Environment::Develop => (2, 20),+ Environment::Production | Environment::Local => (min_connections, max_connections),+ };+let readonly_db = match PgPoolOptions::new()- .min_connections(min_connections)- .max_connections(max_connections)+ .min_connections(readonly_min_connections)+ .max_connections(readonly_max_connections).connect(&config.database_url_readonly).await{Ok(pool) => {- tracing::trace!("initialized readonly db connection");+ tracing::trace!(+ min_connections = readonly_min_connections,+ max_connections = readonly_max_connections,+ "initialized readonly db connection"+ );pool}Err(e) => {