Skip to content

Commit

Permalink
[#25326] YSQL: Fix YsqlMajorUpgradeRpcsTest.MasterCrashDuringUpgrade
Browse files Browse the repository at this point in the history
Summary:
`YsqlCatalogConfig::SetConfig` was incorrectly reading the non dirty state of the COW object which is not yet initialized.
Switching to use the dirty state which has the valid data.
Jira: DB-14532

Test Plan: YsqlMajorUpgradeRpcsTest.MasterCrashDuringUpgrade

Reviewers: telgersma

Reviewed By: telgersma

Subscribers: ybase

Differential Revision: https://phorge.dev.yugabyte.com/D40730
  • Loading branch information
hari90 committed Dec 17, 2024
1 parent 3c8a0c5 commit 0a4116b
Showing 1 changed file with 15 additions and 19 deletions.
34 changes: 15 additions & 19 deletions src/yb/master/ysql/ysql_catalog_config.cc
Original file line number Diff line number Diff line change
Expand Up @@ -71,25 +71,21 @@ Status YsqlCatalogConfig::PrepareDefaultIfNeeded(const LeaderEpoch& epoch) {
}

void YsqlCatalogConfig::SetConfig(scoped_refptr<SysConfigInfo> config) {
{
auto l = config->LockForRead();
auto& ysql_catalog_config = l->pb.ysql_catalog_config();
if (ysql_catalog_config.has_ysql_major_catalog_upgrade_info()) {
const auto persisted_version =
ysql_catalog_config.ysql_major_catalog_upgrade_info().catalog_version();
LOG_IF(FATAL, persisted_version > GetMajorVersionOfCurrentBuild())
<< "Persisted major version in YSQL catalog config is not supported. Restart "
"the process in the correct version. Min required major version: "
<< persisted_version
<< ", Current major version: " << VersionInfo::GetShortVersionString();

// A new yb-master leader has started. If we were in the middle of the ysql major catalog
// upgrade (initdb, pg_upgrade, or rollback) then mark the major upgrade as failed. No action
// is taken if we are in the monitoring phase.
// We cannot update the config right now, so do so after the sys_catalog is loaded.
restarted_during_major_upgrade_ = IsYsqlMajorCatalogOperationRunning(
ysql_catalog_config.ysql_major_catalog_upgrade_info().state());
}
auto& ysql_catalog_config = config->mutable_metadata()->mutable_dirty()->pb.ysql_catalog_config();
if (ysql_catalog_config.has_ysql_major_catalog_upgrade_info()) {
const auto persisted_version =
ysql_catalog_config.ysql_major_catalog_upgrade_info().catalog_version();
LOG_IF(FATAL, persisted_version > GetMajorVersionOfCurrentBuild())
<< "Persisted major version in YSQL catalog config is not supported. Restart "
"the process in the correct version. Min required major version: "
<< persisted_version << ", Current major version: " << VersionInfo::GetShortVersionString();

// A new yb-master leader has started. If we were in the middle of the ysql major catalog
// upgrade (initdb, pg_upgrade, or rollback) then mark the major upgrade as failed. No action
// is taken if we are in the monitoring phase.
// We cannot update the config right now, so do so after the sys_catalog is loaded.
restarted_during_major_upgrade_ = IsYsqlMajorCatalogOperationRunning(
ysql_catalog_config.ysql_major_catalog_upgrade_info().state());
}

std::lock_guard m_lock(mutex_);
Expand Down

0 comments on commit 0a4116b

Please sign in to comment.