Skip to content
Source
Sign inSign up
samwillis/neon-durable-streams
Open History to see the last commit

operator-runbook.md

65 lines11.7 KB

Consumer operations

The application owns admission, credentials, ingress protection, monitoring, and the Neon resources. Keep management/recovery operations on a trusted operator path with a separate direct Postgres pool. Library imports and public stream requests never provision infrastructure, migrate schemas, enable collection, or activate a restored installation.

Supported and tested configuration

ComponentCurrent qualification
Node.jsNode 24; Linux ARM64 Neon Function runtime 24.22.1, Node 24.22.2 test coordinator. Package engines exclude other majors.
Postgres/clientActual Neon Postgres 18; pg 8.23.1. The declared pg peer API range begins at 8.16.3; other versions in that range require consumer qualification.
Realtime@neon/realtime 0.2.1, raw append windows, SDK-decoded bytea, bounded subscriptions and fallback.
Object StorageNeon S3 endpoint with @aws-sdk/client-s3 3.1169.0; private bucket, immutable v1 chunk keys.
Functions@neon/functions 0.11.0, Node 24, native HTTPS ingress and authenticated schedule triggers.
ProtocolPinned upstream 0.3.7 / commit 461b40267aabd644558f9b19dbb9507dd5f691cf; all 338 cases, subscriptions enabled.
SchemaFour-file fresh baseline; earlier development histories require a fresh schema. Historical rolling results concern archived schema-0005 binaries only. See the upgrade contract.
RegionsFinal replay qualification uses US-east-1 with a remote coordinator; earlier reports also cover Frankfurt. Other regions and combinations need their own deployment evidence.

Sealing publishes a packed block directory and deletes the exact append rows. Postgres retains O(chunks) manifest/index rows and O(blocks) directory entries, with no per-append sealed offset/length array. Hot/frozen payloads, producers and subscriptions have separate costs. Defaults seal at 4 MiB, 8,192 frames, or one hour. Normal cron preserves younger small tails. Cache retention defaults to 32 MiB; pending immutable fetches and replay/response admission have separate 128 MiB and 256 MiB budgets. See compact storage for bounds and sizing limits.

The checked-in lockfile pins the complete dependency graph used by CI. Dependency updates rerun packed-consumer, actual Function, Neon, recovery, and full conformance gates. A peer range describes the accepted client API; it does not claim every historical driver/provider combination has passed the matrix. The package is unpublished and remains marked private.

Use the qualification reports for exact workload, source, deployment bundle, clocks, reader mappings, and test counts. The previous schema-0006 long-running collection profile combines four closed-loop 1 KiB writers, four streams, 16 receiving SSE readers, one sealed 64 KiB source/fork lifecycle every ten seconds, cron recovery, and append hints. Default example pools have five connections per module. Routed health samples describe one observed instance/process, rather than total fleet memory or pool use. Measurements establish the stated profile; they do not establish an arrival-rate ceiling or an end-to-end availability SLA.

Application-specific request rates, per-tenant fairness, and storage budgets remain consumer policies. Enforce them using a trusted admission wrapper and the identity/authorization hooks, backed by shared state when several Function instances serve a tenant. The library supplies installation-wide live leases and finite per-request/adapter bounds; those do not implement a tenant billing or traffic policy. In particular, a prolonged Object Storage outage retains acknowledged payloads in Postgres. Set staging-backlog/disk alarms and throttle new appends before exhausting the database's provisioned budget. Durable storage backlogs are distinct from bounded Function memory and queues.

First response by symptom

SymptomAction
Append response lost or connection breaks during commitPreserve the original producer ID/epoch/sequence and exact payload. Retry that tuple. A completed transaction deduplicates it; a rolled-back transaction accepts it once. Without a producer identity, the application must resolve an unknown outcome before blindly repeating side effects.
Repeated SQL timeouts or STORAGE_BUSYInspect pool waiting/active counts, database locks/load, adapter queue bounds, and maintenance backlog. Reduce concurrent work or scale within the measured envelope. Keep finite connection, transaction, and object I/O deadlines; do not replace bounded queues with unbounded retries.
429 live-reader admissionRespect Retry-After, close idle readers, and check installation-wide live leases. Cancellation releases slots; process-loss leases expire on the DB clock. Increase limits only with Function/account and database headroom. Limits from all deployments share platform constraints.
Realtime disconnect, silent lag, or repeated rotationsExpect durable gap replay and bounded fallback. Check notifier errors and observed live latency. Keep raw query windows simple and unordered. Order/deduplicate by contiguous durable offsets in the Function; do not advance cursors using notification arrival order.
Frozen chunks or pending outbox keep growingConfirm the correct branch's schedule trigger is invoking its authenticated endpoint. Inspect failed maintenance and oldest-work age. Append hints improve normal progress; cron remains the durable recovery mechanism. Tune bounded work/time budgets and rerun sustained load before relying on a higher input rate.
Subscription delivery is lateInspect durable retry time, lease expiry, pending links, quota, and wake state. A failed delivery backs off persistently. Do not reset acknowledgment cursors or mark pending fan-out complete to clear a queue. Cron cadence is not a one-second delivery guarantee.
Scoped token returns 409 FENCEDStop using that wake identity. Claim or process the current generation through the subscription workflow. Restored epochs, completed/expired wakes, deletion, and recreation intentionally fence old work.
Scoped token returns 401Check the exact route/name, token transport, key ID, and current verification keyring. Tokens authorize scoped operations only. Never place them in query strings or logs. A deliberately revoked key makes its tokens unauthenticatable.
INSTALLATION_FENCED, binding mismatch, or unsupported migrationKeep ingress stopped. Inspect installation/schema identity against the intended branch and configured storage. Follow the baseline installation or explicit recovery procedure; do not change database bindings to make a stale process pass readiness.
Missing/corrupt sealed objectStop exposing affected data and keep recovery quiesced. Restore the exact key/bytes from a trusted retained source, validate the full envelope/hash, and resume verification. Never fabricate a shorter stream, skip a frame, or mark verification complete manually.
Object retirement is deferredInspect enablement, valid replay pins, fork/subscription references, pending fan-out, retry claims, and maintenance progress. There is no application PITR hold.
Quarantined orphanInspect the immutable object/key and original upload provenance on an operator path. The collector never automatically deletes invalid envelopes. Repair an exact trusted object or resolve the foreign/corrupt object explicitly; do not clear quarantine merely to force deletion.
Slow reader or canceled requestReconnect using the last durable checkpoint. The server bounds replay pages, live buffers, SQL/object queues, and live lifetimes. A late object download cannot emit after its replay deadline or expired pin.

Monitoring and thresholds

Export onEvent counters and durations, response status rates, onError exception classes, and the example's authenticated runtime snapshots. Redact infrastructure exceptions before logging. Hooks are observation paths and cannot change committed results. An SSE request's time to response headers does not measure its delivery lag or total lifetime.

Collect backlog and oldest-work age independently from request latency: local HOT/FROZEN bytes, frozen chunks, pending/total outbox, subscription next-work/retry times, expired claims, valid live leases/pins, oldest uncollected retirement age, and quarantined objects. inspectReclamation(pool, { schema }) reads collection status; optional includeBacklog: true scans retained ledger metadata and belongs on an operator pool at a measured cadence. Alert when backlog age/size grows across several normal maintenance periods rather than using a single routed health sample as a fleet total. Set numeric alarms from the exact deployment profile and application objectives.

Verify schedule recovery by stopping hints/workers in an isolated environment and leaving durable pending work. Required CI has separate hints-without-cron and cron-without-hints checks. Do not disable both mechanisms in production while expecting unattended progress. Detailed provider metrics complement application counters; neither a successful cron sample nor a platform quota establishes availability for the complete stack.

Keys and credentials

Persist subscription wrapping/verification keys outside the database restore timeline and include them in backup policy. All instances must share the same keyring. Rotate wrapping keys in two stages: first deploy every instance with both old and new keys while keeping the old current key, then switch the current key. This prevents a new token/ciphertext from reaching a still-serving instance that lacks its key. Retain old keys for supported recovery and authentic stale-token fencing; explicit trust revocation changes that contract to 401. Rotate the Ed25519 webhook signing key through initializeSubscriptions({ rotateSigningKey: true, ... }) and retain historical public keys for receiver verification.

Rotate Postgres, Realtime, S3, and application credentials through the consumer's secret manager. Deploy/warm the replacement configuration, verify readiness and representative protocol operations, then revoke the old credential. Never fall back to anonymous access or a different bucket after authentication failures. The library has no dependency on a Neon management API key at runtime.

Upgrade, recovery, and collection

Follow installation/recovery, in-place restore, the upgrade matrix, and the reclamation contract. Stop ingress, cold-starting instances, timers, scheduled workers, and object work before DDL or rollback. Epoch fencing supplements that stop; rolling an epoch backward cannot invalidate a process that still remembers it.

Historical recovery must restore the object bytes referenced by the restored database, including subsequently deleted keys. The current baseline delegates this to Neon or matching backups and has no application recovery-window or safety-margin settings. Current public Neon documentation says database PITR leaves Object Storage unchanged; keep collection disabled for a deployment promising historical restore until matching object recovery is available and verified. Branch/reset inheritance alone does not certify historical recovery. Verification skips retired unreachable manifests and requires every reachable sealed object. Missing objects or keys keep the installation quiesced.

After verification, activate a new epoch, deploy fresh instances, require repeated authenticated readiness, replay representative binary/JSON/fork streams, verify producer retry and live final-byte/EOF behavior, then reopen ingress. Restores can intentionally discard externally observed writes and acknowledgments; downstream applications must reconcile their checkpoints and side effects.