On this page
Kafka troubleshooting
KafkaStorageException (KAFKA_STORAGE_ERROR)
org.
A broker answered KAFKA_STORAGE_ERROR (error code 56) because it could not use the storage behind the request. In Apache Kafka that is a failed log directory, a disk the broker can no longer read or write. In Aiven Inkless it is also what diskless produce and fetch get while PostgreSQL, the batch coordinator, is unavailable. The client refreshes metadata and retries.
Reproduce it in the playground2 steps beforeBoth topics flowing. t+2.050s
orders is a classic topic: order-1 was replicated from broker-1 to the other two brokers and acked at 450 ms. clicks is diskless (KIP-1163 draft): broker-1 buffered click-1, uploaded it as the WAL object wal-0001, the coordinator on broker-3 committed it and p-clicks was acked at 1450 ms. c1 in az-b read click-1 at 1500 ms and committed its offset at 2000 ms.
Open at this step: step 1, Both topics flowing1 step beforeObject storage stops; orders is still acked. t+3.100s
The bucket stopped at 2500 ms. order-2 was acked at 3050 ms, 300 ms after it was sent, as before: a classic topic replicates between brokers and never touches object storage. click-2 sits in broker-1's WAL buffer as wal-0002, and its upload started at 3250 ms. The draft says nothing about back-pressure, so here the broker keeps buffering (simulator choice).
Open at this step: step 2, Object storage stops; orders is still ackedThe moment it happensThe upload fails: KAFKA_STORAGE_ERROR. t+4.100s
wal-0002's upload failed: no object was written, the coordinator committed nothing and click-2 got no offset. At 4050 ms p-clicks got KAFKA_STORAGE_ERROR. The draft says only that the pending produce requests receive errors and that produce fails retriably; the error code is the simulator's choice. It is retriable, so p-clicks sends click-2 again after its 500 ms backoff.
Open at this step: step 3, The upload fails: KAFKA_STORAGE_ERRORRight afterThe retry fails too. t+5.900s
The retry went into wal-0003 at 4550 ms; its upload started at 5050 ms and failed at 5850 ms with the same error, so p-clicks backs off and tries again. Object storage still holds only wal-0001, and the high watermark of clicks is still 1. c1 kept polling and found nothing new; with nothing past its offset, its fetch never needed object storage, so it got no error.
Open at this step: step 4, The retry fails tooWhat it means
The Kafka protocol describes KAFKA_STORAGE_ERROR as "Disk error when trying to access log file on the disk", and the KafkaStorageException javadoc calls it a disk-related IOException met while handling a request, after which the client should request a metadata update and retry. A broker with several log directories (JBOD) does not stop when one of them fails, unless that directory holds the cluster metadata log in KRaft: it marks that directory offline, the partitions stored there stop being served by that broker, and their leadership moves to other in-sync replicas, while partitions in the other directories carry on. A client that was talking to the old leader gets KAFKA_STORAGE_ERROR, refreshes its metadata and finds the new leader. Aiven Inkless, a fork of Apache Kafka that runs diskless topics, keeps the order and offsets of diskless batches in PostgreSQL; its documentation says that while that control plane is unavailable, diskless produce and fetch fail with KAFKA_STORAGE_ERROR, a retriable error, and classic topics in the same cluster keep working. Nisshi (formerly Tansu), a Kafka-compatible broker that keeps no data itself, answers it too while its storage engine is unavailable: on its PostgreSQL engine a produce request is one transaction, and when PostgreSQL cannot be reached the transaction stores nothing and the producer gets KAFKA_STORAGE_ERROR, which is retriable (the storage layer of Nisshi 0.8.2). Nothing was taken, so the retry leaves no gap. Scenario 12.1.6 shows it. Inkless returns the same error when object storage fails a write: a broker uploads the diskless batches it buffered as one file, tries it max.upload.attempts times (3 by default), and if every attempt fails it answers every produce request in that file with KAFKA_STORAGE_ERROR, before anything reaches PostgreSQL (Inkless's code at inkless-release-0.51). Its S3 client gives each attempt 1 second and each call 2 seconds, so a bucket that is only slow fails the same way as one that is down. Scenario 07.1.4 shows it. The diskless topics proposal (KIP-1163, a draft) says that when a WAL upload to object storage fails, the pending produce requests get errors, and its test plan (KIP-1165) that produce fails retriably; it names no error code. Scenario 06.1.4 uses KAFKA_STORAGE_ERROR for it, which is the simulator's choice. KafScale, a Kafka-protocol broker that keeps every topic in S3, returns it too in KafScale, while the broker's S3 health monitor reports S3 unavailable: 60% or more of the S3 calls in its last 60 seconds failed. Between 20% and 60% it reports S3 degraded and answers REQUEST_TIMED_OUT instead; both are retriable. Offsets move on only after the upload and the etcd write both succeed, so the retry writes the records at the same offsets and leaves no gap. Scenario 08.2.3 shows both codes.
Likely causes, most common first
- A broker disk or log directory failed. An I/O error on one of the directories in log.dirs, a full or read-only filesystem, or a disk that went away makes the broker take that directory offline. Every partition replica stored there is offline on that broker until it is restarted with the directory repaired or removed.
- The broker has only one log directory. With a single directory a log directory failure takes all of the broker's storage with it, and the broker shuts down. Clients get KAFKA_STORAGE_ERROR or connection errors until the partitions move to other brokers.
- Aiven Inkless: PostgreSQL is unavailable. On an Inkless cluster, diskless topics need PostgreSQL to commit and to find batches. While it is down or unreachable, diskless produce and fetch fail with KAFKA_STORAGE_ERROR; classic topics are unaffected. Clients keep retrying until it is back.
- Nisshi: its storage engine is unavailable. On a Nisshi cluster every record, watermark, group and offset is in the storage engine (PostgreSQL, or S3 on its experimental engine). While it is down every produce request fails with KAFKA_STORAGE_ERROR and the producer retries; no broker change helps, since no broker holds the data. Once the engine is back the next retry commits.
- Aiven Inkless: object storage down or too slow. On an Inkless cluster, a diskless upload that fails all its attempts, because the bucket is unreachable or answers slower than the S3 client timeouts, fails every produce request in that file with KAFKA_STORAGE_ERROR. The records got no offsets, so the producer's retry writes them once; Inkless 0.51 has no back-pressure, so the broker keeps accepting produce requests while the attempts run.
- KafScale: S3 unavailable or an upload failed. On a KafScale cluster (not Apache Kafka), every produce and fetch gets KAFKA_STORAGE_ERROR while the S3 health monitor reports S3 unavailable (60% or more of the S3 calls in the last 60 seconds failed), and so does a failed segment upload that leaves the monitor below 20% (a busy broker with many good calls). Between 20% and 60% the answer is REQUEST_TIMED_OUT. The monitor does not probe S3: it reports healthy again only when its 60 second window holds no failed call, so the refusals go on for up to a minute after S3 is back, and on a quiet broker the code can change from REQUEST_TIMED_OUT to KAFKA_STORAGE_ERROR as the good calls from before the outage leave the window first. A segment upload also gets it when another broker's upload created the same segment first: segment uploads are conditional (If-None-Match), so nothing acked is overwritten, and the broker whose upload lost drops its partition log, restores the winning segment and writes on after it (PR #353). The conflict does not count as an S3 failure (PR #345). Scenario 08.2.6 shows a new owner's upload losing to the segment of the owner that stopped before it.
How to fix it
- Check the broker log for the failed directory: the broker logs the I/O error and that it marked the directory offline, so the log names the disk to look at.
- Replace or repair the disk, or remove the failed path from log.dirs, then restart the broker so its replicas come back and catch up from the leaders.
- Make sure the topics on it have a replication factor of at least 3 and a min.insync.replicas below it, so another replica can lead while the disk is replaced.
- On Aiven Inkless, bring PostgreSQL back; the clients retry on their own and diskless traffic resumes.
- On Nisshi, bring the storage engine back (PostgreSQL, or the bucket on the S3 engine) and let the producers retry: a failed write stored nothing.
- On Aiven Inkless, check the object storage the brokers write to, including its latency: a bucket slower than the S3 client timeouts fails uploads as if it were down.
- On KafScale, bring S3 back and let the clients retry: expect refusals for up to 60 seconds after the last failed S3 call, then the records land at the offsets they first took.
What not to do
- Raising retries alone to hide a failed disk: the replicas on it stay offline and the partition runs on fewer copies until the disk is dealt with.
Does the client retry it?
Yes, the client retries. KAFKA_STORAGE_ERROR (error code 56) is a retriable protocol error, and KafkaStorageException extends InvalidMetadataException: the client refreshes its metadata and tries again, so it finds the partition's new leader after a disk failure, or succeeds once Inkless's PostgreSQL is back. It surfaces to the application only when retries or delivery.timeout.ms run out first.
Reproduce it in the simulator
- Diskless Kafka (KIP-1163): when object storage goes down (Diskless: object storage goes down) Open at the moment it happens: Diskless Kafka (KIP-1163): when object storage goes down
- Aiven Inkless: what a PostgreSQL outage does to Kafka (Inkless: PostgreSQL goes down) Open at the moment it happens: Aiven Inkless: what a PostgreSQL outage does to Kafka
- Aiven Inkless: a slow S3 bucket fails Kafka produce (Inkless: object storage turns slow) Open at the moment it happens: Aiven Inkless: a slow S3 bucket fails Kafka produce
- KafScale 2.1 diskless Kafka: when S3 goes down (KafScale: S3 goes down) Open at the moment it happens: KafScale 2.1 diskless Kafka: when S3 goes down
- KafScale 2.1 diskless Kafka: lease handover, no overwrite (KafScale: a lease handover without an overwrite) Open at the moment it happens: KafScale 2.1 diskless Kafka: lease handover, no overwrite
- Nisshi diskless Kafka: when PostgreSQL goes down (Nisshi: PostgreSQL unavailable) Open at the moment it happens: Nisshi diskless Kafka: when PostgreSQL goes down
Sources
- Apache Kafka 4.4 javadoc: KafkaStorageException
- Apache Kafka 4.4.0 source: Errors.java (KAFKA_STORAGE_ERROR, code 56)
- KIP-112: Handle disk failure for JBOD
- KIP-858: Handle JBOD broker disk failure in KRaft
- Aiven Inkless 0.51: architecture (control plane unavailable)
- Nisshi v0.8.2: storage engines
- Nisshi v0.8.2 source: produce.rs (storage errors answer KAFKA_STORAGE_ERROR)
- Aiven Inkless 0.51 source: AppendCompleter.java (a failed file gives every request KAFKA_STORAGE_ERROR)
- Aiven Inkless 0.51 source: InklessConfig.java (max.upload.attempts, upload.backoff.ms)
- KafScale v2.1.0: broker main.go (degraded answers REQUEST_TIMED_OUT, unavailable or a failed call KAFKA_STORAGE_ERROR)
- KafScale v2.1.0: s3_health.go (60 s window; 20% failed calls degraded, 60% unavailable)
- KafScale v2.1.0: log.go (offsets move on after the upload and the etcd write)
- KafScale v2.1.0: s3_aws.go (If-None-Match on segment uploads)
- KafScale PR #272: a retriable storage error when S3 is unavailable
- KafScale PR #254: append multi-batch Produce requests atomically
- KafScale PR #345: keep fencing conflicts out of S3 health errors
- KafScale PR #353: recover partition writes after upload conflicts