Skip to content

armgit / macro

Public Imported from GitHub
0

Macro is a unified workspace for teams: email, chat, docs, tasks, agents, calls, and CRM — @-linked together with shared AI memory.

fix(calendar): read the GraphQL calendar feed from the primary (#8666)

gbirmana699634d0662
diff --git a/services/document_storage_service/AGENTS.md b/services/document_storage_service/AGENTS.md
index 7972bbfe92..2054652e0a 100644
--- a/services/document_storage_service/AGENTS.md
+++ b/services/document_storage_service/AGENTS.md
@@ -64,6 +64,9 @@ threads, pins, recents, notifications, folders, activity.
- Soup GraphQL reads a replica with multi-second lag; a read immediately after
a write through the same request needs the primary-reading loader, not the
default one — see `crates/graphql_soup`.
+- The GraphQL calendar feed (occurrence ranges and `calendarChanges`) reads the
+ primary, like the REST calendar routes: a `refresh_calendar` poke goes out as
+ a write commits, so a replica-backed delta misses the change it announces.
## Related
diff --git a/services/document_storage_service/src/server.rs b/services/document_storage_service/src/server.rs
index a653c0f642..1fefe51042 100644
--- a/services/document_storage_service/src/server.rs
+++ b/services/document_storage_service/src/server.rs
@@ -1883,20 +1883,24 @@ pub async fn run() -> anyhow::Result<()> {
let user_api_key_service = Arc::new(UserApiKeyServiceImpl::new(PgUserApiKeysRepo::new(
db.clone(),
)));
+ // The GraphQL own-calendar feed reads the primary, like the REST calendar
+ // routes: a `refresh_calendar` poke goes out as the write commits, and the
+ // delta it triggers would find nothing on a lagging replica, leaving the
+ // change unseen until some later poke. Range reads share the pool so a
+ // page cannot overwrite what a delta already applied with older rows.
let calendar_read_service = Arc::new(calendar_events::domain::service::CalendarService::new(
- calendar_events::outbound::pg::PgCalendarRepository::new(readonly_db.clone()),
+ calendar_events::outbound::pg::PgCalendarRepository::new(db.clone()),
));
let graphql_calendar_context = graphql_calendar::CalendarGraphqlContext::new(
calendar_read_service.clone(),
Arc::new(
calendar_events::domain::changes::CalendarChangeService::new(
- calendar_events::outbound::pg::PgCalendarRepository::new(readonly_db.clone()),
+ calendar_events::outbound::pg::PgCalendarRepository::new(db.clone()),
),
),
);
// Team policy reads use the primary so a sharing downgrade cannot be
- // served from a lagging replica. The GraphQL own-calendar feed retains
- // its existing readonly-pool routing.
+ // served from a lagging replica.
let calendar_state = CalendarRouterState::new(
Arc::new(
calendar_events::domain::service::CalendarService::new(