Check if _any_ global_state entries show initialized=t when checking if a site has been initialized
Created by: dadlerj
Reported by https://app.hubspot.com/contacts/2762526/company/814799425
Interesting thread from $CUSTOMER on migration from one K8s cluster to another: https://sourcegraph.slack.com/archives/CKMSNT9C0/p1594856578000100?thread_ts=1592521757.020100&cid=CKMSNT9C0
He dumped the PG db, and reloaded it into the new cluster, and confirmed all of data was loaded. However, he was still landing on the site init page (as if it was a brand new instance).
I pointed him to the global_state
table, and he saw that one of the rows in that table had initialized
set to false
. When he deleted it, everything worked as expected.
Looking at our global state code, it looks like we’re just selecting a single row from the table: https://sourcegraph.com/github.com/sourcegraph/sourcegraph@1c2aee517524aa1d8f7447a923b817309ae588c1/-/blob/internal/db/globalstatedb/globalstatedb.go#L77:23. I’m not sure what’s ideal here, but instead checking if any rows shows initialized=t would be more correct?
===
As an alternative, we should be explicit in our docs about how to migrate to a new deployment that customers MUST reload the PG dump before starting up the new deployment, as a new row (with initialized=false) will be inserted into the global_state table on startup.