dekaf: Migration E2E testing #2625
Draft
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This PR adds test coverage for Dekaf's handling of cross-dataplane migrations.
Previously, the convention was that Dekaf addresses live at
dekaf.{plane_fqdn}:9092. In order to test migration locally, I had to manually and temporarily change this logic. In order to support automated testing of migrations, we needed a first-class way to represent the address of a data-plane's Dekaf instance. We already havereactor_addressandbroker_addressin thedata_planestable, so I addeddekaf_addressanddekaf_registry_address.One wrinkle is that unlike reactors and brokers, data planes do not always run Dekaf. In order to handle this properly, I updated data-plane-controller to actively manage the
dekaf_addressanddekaf_registry_addresscolumns, such that they're only set if Dekaf is actually deployed in that plane, otherwise they're null. Dekaf will now emit a helpful error message when attempting to serve a redirect to a data-plane that does not have an instance deployed.Note: As it turns out, our mapping of redirects onto the Kafka protocol isn't perfect. Specifically, since we reuse the same broker ID for the redirect target:
flow/crates/dekaf/src/session.rs
Lines 249 to 262 in 71da382
librdkafka gets confused and shuts down its session rather than smoothly connecting to the newly advertised broker. The subsequent connection only sees the new broker and connects to it properly, but I believe this is the source of the periodic error logging we've been seeing. Fixing it is out of scope here, but it involves a mechanism for assigning each data-plane's Dekaf instance(s) a stable numeric identifier that we can use as the broker ID.
Note: I discovered a race condition in Gazette while working on these tests that causes them to have an unfortunately high upper bound on runtime: about 8 minutes.
Briefly, when a journal is migrated, one of the steps is suspending it in the source data-plane. When a journal is suspended, two things happen: its un-persisted fragments are scheduled for immediate upload, and its replication factor is reduced from 3 to 1. The race condition is: if the broker that was the primary for the journal being suspended ends up being picked as the sole remaining broker in the topology, the fragment persistence happens promptly. Otherwise, it falls back to the backup fragment upload pathway which takes up to 3 minutes.
If all of the necessary fragments aren't present when the journal is then published to the destination data-plane, we have to wait out the 5 minute default fragment refresh interval before they get picked up. Hence the 8 minute upper bound on runtime.
The following output is with a temporarily modified faster fragment refresh interval: