Use initialized flag

This commit is contained in:
Antonio Andelic 2022-11-28 08:44:46 +00:00
parent 599f381217
commit e91314d57f
2 changed files with 5 additions and 1 deletions

View File

@ -431,6 +431,8 @@ void Changelog::readChangelogAndInitWriter(uint64_t last_commited_log_index, uin
/// Start new log if we don't initialize writer from previous log. All logs can be "complete".
if (!current_writer)
rotate(max_log_id + 1);
initialized = true;
}
@ -589,7 +591,7 @@ void Changelog::writeThread()
void Changelog::appendEntry(uint64_t index, const LogEntryPtr & log_entry)
{
if (!current_writer)
if (!initialized)
throw Exception(ErrorCodes::LOGICAL_ERROR, "Changelog must be initialized before appending records");
if (logs.empty())

View File

@ -210,6 +210,8 @@ private:
uint64_t last_durable_idx{0};
nuraft::wptr<nuraft::raft_server> raft_server;
bool initialized = false;
};
}