Rotating the master key
Finish each rotation before starting the next, so rows are never under more than two keys.
- Set the new key as
BROKER_MASTER_KEYand the old one asBROKER_MASTER_KEY_PREVIOUS, and deploy. New writes use the new key; old rows still decrypt. - Wait a few minutes for Workers on the old version to finish, since they still write with the old key.
- On the admin page, re-encrypt. Rows move to the new key and keep their versions, and the result says how many remain on an older key. Repeat until none remain.
- Archive the old key by id (see Backups and recovery), then remove
BROKER_MASTER_KEY_PREVIOUSand deploy.
Re-encryption replaces a row only if its version, key id and IV are unchanged, so a change made at the same time is never overwritten.