Monedula

Scenario 07.1.2 · Inkless: PostgreSQL goes down

Aiven Inkless: what a PostgreSQL outage does to Kafka

Diskless · Advanced · about 3 min · Apache Kafka 4.4 · Aiven Inkless 0.51

Aiven Inkless 0.51 · stop the PostgreSQL batch coordinator: diskless produce and fetch fail with KafkaStorageException while a classic topic in the same cluster keeps working; start it and the retries commit.

Run this scenario in the playground

PostgreSQL is back, retries commit. t+6.100s

PostgreSQL started at 4400 ms. p-clicks' next retries went through: both records were buffered, uploaded as wal-0003 and committed at 5570 ms, and the consumer read them. clicks ends at offset 3; in this run nothing was lost, because the outage was shorter than the producer's retries. wal-0002 was deleted and never got offsets.

Open at this step: step 6, PostgreSQL is back, retries commit

What you start with

In Inkless, PostgreSQL orders every diskless batch and assigns its offsets. Its docs say that while PostgreSQL is unavailable, diskless produce and fetch fail with KAFKA_STORAGE_ERROR, which clients retry, and classic topics keep working. A classic topic, orders, and an Inkless diskless topic, clicks, take writes side by side; PostgreSQL stops while a clicks object is still being uploaded, before it can be committed. Watch the PostgreSQL lane, the object storage lane and both producers.

Step by step

  1. Both topics flowing t+1.400s orders is a classic topic (replication factor 3) and clicks an Inkless diskless topic (replication factor 1). One record each: orders was acked at 450 ms after replicating to its followers; clicks was acked at 1310 ms, when PostgreSQL committed its object, wal-0001. Both producers and the clicks consumer sit in az-b, served by broker-2. Open at this step: step 1, Both topics flowing
  2. PostgreSQL stops t+2.450s PostgreSQL, the Inkless batch coordinator, stopped at 2400 ms. A second clicks record is on its way to object storage as wal-0002: its upload started at 2150 ms and takes 600 ms, and PostgreSQL must commit it after that. Nothing has failed yet. Open at this step: step 2, PostgreSQL stops
  3. Consumers of clicks get KafkaStorageException t+2.550s The clicks consumer polled at 2500 ms and got KafkaStorageException: a diskless fetch needs PostgreSQL to find the batches, so it fails while the database is down (Inkless docs). In this simulator it fails even when broker-2 has the data cached. Open at this step: step 3, Consumers of clicks get KafkaStorageException
  4. The uploaded object fails its commit and is deleted t+2.850s wal-0002 finished uploading and its commit came due at 2810 ms with PostgreSQL down, so it failed. No batch can point at it, so the broker deletes the object from storage, as Inkless's code does, and p-clicks got KafkaStorageException, a retriable error, for its record. Open at this step: step 4, The uploaded object fails its commit and is deleted
  5. Diskless refused, classic acked t+3.600s At 3200 ms both producers wrote again. p-clicks was refused at once with KafkaStorageException and keeps retrying; p-orders was acked at 3550 ms, as before: classic topics do not use PostgreSQL and keep working. Open at this step: step 5, Diskless refused, classic acked
  6. PostgreSQL is back, retries commit t+6.100s PostgreSQL started at 4400 ms. p-clicks' next retries went through: both records were buffered, uploaded as wal-0003 and committed at 5570 ms, and the consumer read them. clicks ends at offset 3; in this run nothing was lost, because the outage was shorter than the producer's retries. wal-0002 was deleted and never got offsets. Open at this step: step 6, PostgreSQL is back, retries commit

The takeaway

orders kept being acked the whole time: classic topics do not use PostgreSQL. clicks writes and reads failed with KafkaStorageException until PostgreSQL returned, then the retried records were committed in a new object; in this run nothing was lost. The object that was in flight when PostgreSQL stopped never got offsets, and the broker deleted it from storage, as Inkless's code does when the control plane is unavailable. Simulator choices: brokers refuse diskless produce at once while PostgreSQL is down, and fetches fail even when the broker has the data cached.

Embed this scenario

Paste this into a blog post, a course page or your team's docs. The scenario plays inside your page, and the link under it points readers to this walkthrough.

<iframe src="https://monedula.dev/kafka-simulator/embed/?scenario=07.1.2" title="Kafka Simulator: Inkless: PostgreSQL goes down" width="100%" height="520" style="border:1px solid #d0d0d0;border-radius:8px" loading="lazy" referrerpolicy="no-referrer-when-downgrade"></iframe>
<p><a href="https://monedula.dev/kafka-simulator/scenarios/inkless-postgresql-outage/">Aiven Inkless: what a PostgreSQL outage does to Kafka</a></p>

Further reading

Aiven Inkless source on GitHub (inkless-release-0.51)

Troubleshooting

More in Diskless

All scenarios