Skip to content

docs: restart staging Keycloak after cloning the prod DB - #889

Open
corneliusroemer wants to merge 2 commits into
mainfrom
readme-restart-keycloak-after-clone
Open

corneliusroemer wants to merge 2 commits into
mainfrom
readme-restart-keycloak-after-clone

Conversation

@corneliusroemer

Copy link
Copy Markdown
Contributor

The clone script (clone-prod-to-staging.sh on the bastion) ends with "Please restart staging Keycloak (or clear its caches) to apply changes." It loads the prod realm data and the fixed staging signing key into the staging Keycloak DB while Keycloak is running, so Keycloak keeps serving its cached realm data until restarted. The README only restarted the backend.

🤖 Generated with Claude Code

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@corneliusroemer
corneliusroemer marked this pull request as ready for review November 10, 2026 20:31
@corneliusroemer

corneliusroemer commented Nov 10, 2026 •

Copy link
Copy Markdown
Contributor Author

I didn't make the changes to the clone script - so would be good if you (@anna-parker) could confirm that my reading is right that we should also restart keycloak. Probably not super important but now might not harm to restart? Or does this have some negative side effects? I remember we discussed that it would be good to keep keycloak functioning throughout rollouts so maybe not restarting is entirely intentional but the script output and README/SOPs should match one way or another.

@anna-parker

anna-parker commented Nov 16, 2026 •

Copy link
Copy Markdown
Contributor

@corneliusroemer a manual restart of keycloak should not be required (we use the same signing key) but can be done safely

probably the wording is a bit too severe on pathoplexus atm only these things can become stale:

What can be stale until Keycloak restarts or the cache is cleared:

  • Users it has already cached: for example, a role, group or password change made on prod since the last clone won't show up on staging for a user Keycloak looked up recently.
  • Accounts created only on staging: these are deleted from the database by the clone but can stay in the cache. Using one can cause odd errors.
  • Realm settings: if someone changed a client or role on prod, staging keeps using the old version.
  • The other keys (the refresh-token key and other keys that don't sign access tokens): these are left out of the clone and recreated by Keycloak. Until then, the running instance keeps using its old cached ones. Since refresh tokens don't survive a clone anyway, the only effect is that some logins end at a slightly different time.

On the other hand restarting keycloak should have no risks so this is safe to do, so I will approve this :-)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants