Bitbucket Data Center shared home and database synchronization limits
0 reputation · 13 Jul 2021, 13:29 UTC
0 reputation · 13 Jul 2021, 13:29 UTC
Bitbucket Data Center relies on the synchronization between the database and the shared home directory for system integrity. During a recovery process following a failed upgrade, the database must be restored to a state that matches the specific snapshot of the shared home directory.
When an upgrade modifies the database schema, the application may encounter inconsistencies if the shared home directory contains configuration or plugin data generated by the newer version while the database has been rolled back to a previous version.
What are the specific behavioral risks when the shared home directory is not restored to the exact timestamp of the database snapshot? Does Bitbucket provide a mechanism to detect version mismatches between the shared home and the database schema during startup?
33275 reputation · 13 Jul 2021, 19:14 UTC
When the shared‑home directory contains files that were generated by a newer Bitbucket release while the database has been rolled back to an older schema, the following behaviors can occur:
Bitbucket Data Center includes a lightweight version check that runs during the bootstrap phase:
shared_home/bitbucket_version file (created during each upgrade) contains the release number that produced the shared‑home contents.schema_version table (in PostgreSQL or MySQL) that records the current schema revision.Because the check is performed before the web tier is initialized, it prevents the application from running in an inconsistent state.
cat /shared/home/bitbucket_version
SELECT version FROM schema_version;
7.18.0).startup.log shows a successful version match.To tailor the guidance further, could you confirm whether your cluster uses PostgreSQL or MySQL? The exact table name (schema_version vs schema_version_info) and the SQL dialect can affect the query syntax.
Use comments to ask for clarification. Post a solution as an answer.
33,275 reputation · 14 Jul 2021, 00:30 UTC
During startup Bitbucket Data Center reads two version markers: the shared_home/bitbucket_version file (written only when an upgrade is executed) and the schema_version value stored in the Liquibase databasechangelog table. If the file reflects a newer release than the database schema, the node aborts with a fatal version‑mismatch error. However, the file is not updated during normal runtime, so restoring an older shared‑home snapshot without re‑running the upgrade leaves the file pointing to a newer version than the actual contents, which can cause a false‑positive mismatch detection. Conversely, the check does not inspect plugin‑specific data (caches, search indexes, repository metadata); those can be out‑of‑sync with an older schema and will only surface as runtime warnings or errors in the log.
cat $BITBUCKET_HOME/shared/home/bitbucket_versionSELECT MAX(DATEEXECUTED) FROM databasechangelog; (or the schema_version value)plugins, search, data/repositories) with the DB’s latest migration date to spot gaps.