# The bridge release arrived

> Kafka 3.5 deprecated ZooKeeper and shipped the migration as early access. Eight months ago the answer for an existing cluster was "wait"; what arrived is a dual-write mode with a way back.

- Author: Deyan Peev (https://deyanpeev.com)
- Published: 2023-08-12
- Tags: Apache Kafka, Apache ZooKeeper, Distributed Systems, Migration
- URL: https://deyanpeev.com/posts/the-bridge-release-arrived

When I wrote about
[KRaft being marked production ready](https://deyanpeev.com/posts/kafka-without-zookeeper-for-new-clusters-only)
last December, the conclusion was an awkward one. Excellent news for new
clusters, and nothing you could act on if you already ran one. There was no
migration path, and the plan said one would come in a later 3.x release.

Kafka 3.5 shipped in June and it is that release. ZooKeeper is now formally
deprecated and the ZooKeeper-to-KRaft migration exists, as early access, and I'd
read that label literally.

# Why the migration is hard at all

The reason it's hard explains the design of the answer. The topics never lived
in ZooKeeper. What has to move is the cluster's metadata (topics, partitions,
in-sync replica sets, configuration overrides, ACLs), out of a store that a
running cluster is actively reading and writing and into a completely different
one, without stopping the cluster and without a window where the two disagree.

And stopping is not on the table. A Kafka cluster is usually sitting underneath
everything else, so "brief downtime while we migrate metadata" means brief
downtime for every service that publishes or consumes.

# Dual write, and the way back

Instead of cutting over, the migration enters a mode where both systems are
written.

A KRaft controller quorum is provisioned alongside the existing cluster and put
into migration mode. It takes ownership of metadata, and while the migration is in
progress it writes every change to both the KRaft metadata log and to ZooKeeper.
Brokers are restarted one at a time into KRaft mode. When every broker has moved
and the metadata is confirmed consistent, the migration is finalised and the
ZooKeeper writes stop.

While dual write is active, ZooKeeper still holds a current copy of the
metadata, and I think that's what makes this something an operations team would
agree to. The migration has a way back. If something is wrong three brokers into
a rolling restart you can fall back, you don't have to finish a cutover you have
lost confidence in.

This is the design decision I find most instructive. Migrating a live system is
rarely difficult because of the mechanism. It's difficult because a one-way door
forces you to be certain in advance, and you seldom are. Dual write buys back
the ability to change your mind, and it pays for that with a period of extra
writes and a more complicated system while it lasts. It's the same trade as
writing to the old and the new database at once during a cutover. That pattern
keeps getting reinvented, because the extra writes cost little next to being
able to stop halfway.

# What early access means here

It is not production ready. The documentation and the release notes both say so,
and when it's a metadata migration of a system everything else depends on, I'd
give that label more respect than usual.

The published plan from here is that the migration becomes generally available
in 3.6, 3.7 is the final bridge release, and 4.0 removes ZooKeeper support
entirely. So there is a deadline. Anyone still on ZooKeeper when 4.0 lands has
to migrate through a 3.x bridge first, because 4.0 won't know how to talk to
ZooKeeper at all.

# If this were my cluster

Nothing in production yet, and quite a lot of preparation. The migration is
early access, so running it against production this quarter is volunteering to
find its bugs. But the deprecation notice is what I'd pay attention to. The
clock started in June, the removal is already scheduled, and a cluster that
hasn't moved by 4.0 is a cluster that cannot upgrade.

So the work to do now is whatever doesn't depend on the migration being ready.
Find out whether anything in the deployment uses the features KRaft did not
support (JBOD with multiple storage directories, delegation tokens). Rehearse
the migration on a staging cluster with production-shaped metadata, because the
interesting failures scale with partition count. And write down which tools talk
to ZooKeeper directly. There are always one or two scripts that do.

The removal schedule was published two years out, more notice than most
deprecations give, so it is possible to be ready without hurrying. It isn't
urgent yet. But all of it will be later, at the least convenient version bump.
