What should block a Kafka consumer release?
Block releases on repeatable real-broker checks for lost records and unsafe replay, and run wider crash and timing tests on a schedule.
Not every crash test belongs in CI. Two do. My view: block releases on repeatable real-broker checks for lost records and unsafe replay, and run wider crash and timing tests on a schedule.
Context
A consumer can restart without reporting an error and still leave a record unfinished. It can also process a record twice and leave the right result. A release gate, the CI checks that must pass before shipping, needs to tell these cases apart. In streamjack, the loss experiment runs in about two minutes as part of mvn verify; the full build with all crash suites takes about 21 minutes.
Options
I could block on the whole crash suite, which would check more failure paths before each release. I could keep every crash test on a schedule, which would shorten the release job but leave it without a crash check. I chose to split the suite. Use Testcontainers to run a real Kafka broker in the gate. Keep the crash point and expected result fixed, so the verdict comes from what happened to the record rather than a guess about timing.
What I chose and why
I'd start with two release checks where the service uses the relevant paths and schedule the other four.
| Failure | Where | Why |
|---|---|---|
| Delayed-retry loss | Gate | A record went missing after restart. |
| PostgreSQL replay | Gate | Replay must not add another row. |
| Lock expiry | Scheduled | Lock duration and renewal need testing. |
| Stale decision | Scheduled | The result depends on write order. |
| Silent acknowledgement | Scheduled | What gets reported depends on commit mode. |
| Ordered-by-key recovery | Scheduled | Check recovery and per-key order together. |
The gate gets deterministic, cheap checks for failures that lose or duplicate data; cases that depend on timing or configuration variants go on the schedule.
- Delayed retry. Check that every record finishes after restart, including the unfinished retry. In the concurrent run, only three of four finished. With the proposed SmallRye fix, all four finished but one already-finished record ran again. The author confirmed that the duplicate is intended under at-least-once delivery: a record can run more than once. Don't fail the gate for a duplicate delivery alone. Make retry handlers idempotent, meaning a rerun doesn't repeat the side effect, and fail if it does.
- PostgreSQL replay. Crash after commit but before acknowledgement. Check that the replacement gets the same record and the database still holds one row for that message. The unique key prevented a second row in the test; that doesn't prove the handler ran only once.
- Lock expiry. One record reached five deliveries. Preventing repeated side effects didn't stop the work from running again. Test with the service's own configuration.
- Stale decision. Every tested case left one row. Run both write orders and check which decision survived, not just how many rows remain.
- Silent acknowledgement. The default synchronous path logged nothing when the commit reported a partition failure. Check the expected log or callback.
- Ordered-by-key recovery. Recovery and per-key order held in all 40 scheduled attempts. A final count can't show whether the next record for the same key started too early.
What it cost
Running the short check still costs time, and the two-minute figure is for the loss experiment, not the combined gate. The split also means a scheduled failure may be found after a release. I'd give each scheduled failure an owner and decide whether it should block the next release rather than treating that suite as optional.
When I'd decide differently
For a small team releasing often, I'd start with the shortest reliable checks for the guarantees its service actually makes. If losing a record is especially costly or releases are infrequent, I'd run more of the crash suite before shipping. If the wrong stored decision is as damaging as a lost record, I'd promote the stale-decision check once both write orders can be tested reliably. I'd do the same for acknowledgement failures if the team relies on those logs or callbacks to detect them.
What to do
- Check which records completed after restart, not just the total.
- Replay a committed record and verify that the side effect doesn't happen again.
- Keep timing and configuration variants in a scheduled suite, and give failures an owner.