Skip to content

dekaf: keep connection open on document validation error - #3359

Merged
danielnelson merged 3 commits into
masterfrom
dbn/dekaf-schema-leader-not-available
Aug 19, 2026
Merged

dekaf: keep connection open on document validation error#3359
danielnelson merged 3 commits into
masterfrom
dbn/dekaf-schema-leader-not-available

Conversation

@danielnelson

@danielnelson danielnelson commented Aug 14, 2026

Copy link
Copy Markdown
Contributor

Description:

Collection schemas are refreshed every spec_ttl. Currently if a document does not validate against its collection schema the session would log an error and close the connection. This would interrupt all partitions on this connection and the client would need to reconnect. If the error is corrected by the inferred schema you it should be updated on the next spec_ttl refresh, but if the client reconnects before then it would result in further disconnections.

With this change, when a partition fails to validate against the schema, it is placed into "cooldown". LEADER_NOT_AVAILABLE will be reported for this partition. This will indicate to the client that it should retry, but will not affect the ability for other partitions to make progress. The partition remains in cooldown until the collection schema is updated where on the next fetch a new Read is created, or until a timeout (4m default, 2x the spec_ttl) where the connection will be closed with an error like before.

closes: #3338

Workflow steps:

No changes

Documentation links affected:

None

Notes for reviewers:

I've tested this with rdkafka/kcat and tinybird

@danielnelson danielnelson changed the title Dbn/dekaf schema leader not available dekaf: don't close connection immediately on invalid schema Aug 14, 2026
@danielnelson danielnelson changed the title dekaf: don't close connection immediately on invalid schema dekaf: keep connection open on document validation error Aug 14, 2026
@danielnelson
danielnelson force-pushed the dbn/dekaf-schema-leader-not-available branch from 1521000 to 5bffb38 Compare August 14, 2026 16:09
@danielnelson
danielnelson marked this pull request as ready for review August 14, 2026 16:20
@danielnelson
danielnelson requested review from a team August 14, 2026 16:20
Collection schemas are refreshed every spec_ttl.  Currently if a
document does not validate against its collection schema the session
would log an error and close the connection.  This would interrupt all
partitions on this connection and the client would need to reconnect.
If the error is corrected by the inferred schema you it should be
updated on the next spec_ttl refresh, but if the client reconnects
before then it would result in further disconnections.

With this change, when a partition fails to validate against the schema,
it is placed into "cooldown".  LEADER_NOT_AVAILABLE will be reported for
this partition.  This will indicate to the client that it should retry,
but will not affect the ability for other partitions to make progress.
The partition remains in cooldown until the collection schema is updated
where on the next fetch a new Read is created, or until a timeout (4m
default, 2x the spec_ttl) where the connection will be closed with an
error like before.
@danielnelson
danielnelson force-pushed the dbn/dekaf-schema-leader-not-available branch from 5bffb38 to d5d4c74 Compare August 14, 2026 16:59
Comment thread crates/dekaf/src/lib.rs
Comment on lines +265 to +275
// Content-addresses the derived key/value schemas so callers can
// cheaply detect when a binding's effective schema has changed,
// without a network round trip (unlike `registered_schema_id`'s
// `avro_schema_md5`, which addresses the same schemas against the
// control plane's schema registry table).
let schema_hash = {
let key_json = serde_json::to_value(&key_schema).unwrap().to_string();
let value_json = serde_json::to_value(&value_schema).unwrap().to_string();
format!("{:x}", md5::compute(format!("{key_json}{value_json}")))
};

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

AFAIK the value_schema here depends on field selections, which means if two bindings of the same collection have different field selections, we will have two schema hashes for the same collection.

In one iteration of the loop, one of those bindings sets the cooldown for the journal, the other one detects a change in hash and removes it, so there is an edge case where if multiple bindings of the same journal have different field selections, then they end up in this constant loop of setting a hash, then detecting a change in the hash, so on and so forth

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This seems like an issue, I'll look into it.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The CooldownEntry is now keyed on (topic, partition).

Comment thread crates/dekaf/src/session.rs
This avoids and issue if you have two topics using the same collection.
@danielnelson
danielnelson force-pushed the dbn/dekaf-schema-leader-not-available branch from 742d225 to 835cae0 Compare August 18, 2026 22:37
@danielnelson
danielnelson requested a review from mdibaiee August 18, 2026 23:03
@danielnelson
danielnelson merged commit 2107518 into master Aug 19, 2026
11 checks passed
@danielnelson
danielnelson deleted the dbn/dekaf-schema-leader-not-available branch August 19, 2026 19:25
@GregorShear GregorShear added pending:agent-api Merged, ships via Deploy agent-api, and not yet deployed pending:agent Merged, in the control-plane-agent image, and not yet rolled to flow-agent labels Aug 27, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

pending:agent Merged, in the control-plane-agent image, and not yet rolled to flow-agent pending:agent-api Merged, ships via Deploy agent-api, and not yet deployed

Projects

None yet

Development

Successfully merging this pull request may close these issues.

dekaf: incompatible field schema closes session until spec refresh

3 participants