diff --git a/server/src/crate_server.gleam b/server/src/crate_server.gleam index ff1e698..f0498d5 100644 --- a/server/src/crate_server.gleam +++ b/server/src/crate_server.gleam @@ -1,6 +1,7 @@ import atproto/xrpc.{type Client} import crate_server/atproto_client import crate_server/catalog_index +import crate_server/clock import crate_server/config_env import crate_server/follow_index import crate_server/identity_cache @@ -124,6 +125,9 @@ fn backfill_catalog_index( shelf_index: shelf_index.Store, follow_index: follow_index.Store, ) -> Nil { + // The HTTP listener waits on this, so the duration is the deploy's + // startup budget: probe timeouts are derived from what gets logged here. + let started = clock.now_seconds() let users = known_users.list() users |> list.each(user_backfill.backfill_user( @@ -136,6 +140,8 @@ fn backfill_catalog_index( wisp.log_info( "catalog_index: backfilled from " <> int.to_string(list.length(users)) - <> " known users", + <> " known users in " + <> int.to_string(clock.now_seconds() - started) + <> "s", ) } diff --git a/server/src/crate_server/config_env.gleam b/server/src/crate_server/config_env.gleam index ca4bdda..4d1c1bc 100644 --- a/server/src/crate_server/config_env.gleam +++ b/server/src/crate_server/config_env.gleam @@ -167,12 +167,13 @@ fn raw_stores() -> #( Ok(url) -> case postgres_stores(url) { Ok(stores) -> stores - Error(e) -> { - wisp.log_error( - "Postgres stores unavailable (" <> e <> "); using in-memory", - ) - memory_stores() - } + // A set-but-unusable DATABASE_URL is a deploy bug, not a degraded + // mode: the in-memory fallback boots healthy and serves an empty + // appview with non-persistent sessions, invisible to k8s probes. + Error(e) -> + panic as { + "DATABASE_URL set but Postgres stores are unavailable: " <> e + } } Error(Nil) -> { wisp.log_warning( diff --git a/server/src/crate_server/oauth/sessions_postgres.gleam b/server/src/crate_server/oauth/sessions_postgres.gleam index 0b7c9f1..3e433f4 100644 --- a/server/src/crate_server/oauth/sessions_postgres.gleam +++ b/server/src/crate_server/oauth/sessions_postgres.gleam @@ -16,8 +16,10 @@ pub fn connect_pool(database_url: String) -> Result(pog.Connection, String) { pog.url_config(name, database_url) |> result.replace_error("invalid DATABASE_URL"), ) + // pog defaults to 10; the shared managed cluster has ~25 backends across + // five tenants plus monitoring, so stay a small neighbour. use started <- result.map( - pog.start(pog.rows_as_map(config, True)) + pog.start(pog.rows_as_map(pog.pool_size(config, 4), True)) |> result.replace_error("could not start the Postgres pool"), ) started.data