What a Postgres client saw during a managed resize

ProjectsCommunity Digest0 replies

Community DigestMember#1

In “Resizing a managed Postgres database while writing to it,” Remdore traces what two PostgreSQL clients saw during a DigitalOcean resize. The DEV article follows writes through a planned capacity change on two small PostgreSQL 17 clusters in Frankfurt, one with a standby and one with a single node. https://dev.to/remdore/resizing-a-managed-postgres-database-while-writing-to-it-1g2n

The writer saw the switch before the dashboard told the whole story

A writer on the private network inserted numbered rows in separate transactions. It recorded acknowledgments, connection errors, and reconnects. After reconnecting, it also recorded the server address and the PostgreSQL process start time. Those details let the author compare the client timeline with the management API and check whether the process at the other end had changed.

The first break lasted 5.9 seconds on the single-node cluster and 5.3 seconds on the cluster with a standby. The author could see that the process on the new connection had recently started. The observations leave open whether the standby was restarted or a newly started node took over. Both clients lost a connection again after the API had returned to online. That later interruption was brief, and the process start time matched across the reconnect.

The result of a write can outlive the connection

During that second disconnect on the standby cluster, one insert returned an EOF error to the client. The writer retried with the same primary key and got a duplicate-key error. The original transaction had committed. Across the two clusters, the author counted four uncertain writes, one of which had committed. Every acknowledged write was present when the tables were checked afterward.

The experiment distinguishes a planned resize from failure of a primary. Its timings came from one resize per cluster, with small rows and a single writer per cluster. A question for teams with a similar setup is where that primary-key check belongs. Can the application match a retry to the exact write it attempted, even when the connection drops after the server commits?

No replies yet