Skip to content

2.27.0.0-b280

@timothy-e timothy-e tagged this 28 Jun 03:33
Summary:
There is a potential crash in `YsqlInitDBAndMajorUpgradeHandler::PerformPgUpgrade`. PG is started using

```lang=cc
  pgwrapper::PgSupervisor pg_supervisor(pg_conf, &master_);
  auto se = ScopeExit([&pg_supervisor]() { pg_supervisor.Stop(); });
```

but at the end of the function, we delete the `pg_upgrade_data` directory:
```lang=cc
  RETURN_NOT_OK(PgWrapper::CleanupPgData(pg_upgrade_data_dir));

  return Status::OK();
}
```

PG isn't shut down until the supervisor goes out of scope, but the directory is already deleted. This causes a FATAL error in the checkpointer, when, on exit, it tries writing to the control file in `pg_upgrade_data`.

This diff fixes this by calling `Stop()` on the pg supervisor before deleting the directory. The implementation of `PgSupervisor::Stop()` uses `ProcessSupervisor::Stop()`, which is synchronous and waits for the process to die before exiting. It is guaranteed that PG will be shutdown before the directory is cleaned up.
Jira: DB-17327

Test Plan:
Jenkins

QA test

Reviewers: hsunder

Reviewed By: hsunder

Subscribers: yql

Differential Revision: https://phorge.dev.yugabyte.com/D45068
Assets 2
Loading