Skip to content

Commit

Permalink
fix leader will try to send snapshot by mistake (vesoft-inc#2150)
Browse files Browse the repository at this point in the history
only clean wal after part started
rebased

Co-authored-by: bright-starry-sky <[email protected]>
  • Loading branch information
critical27 and bright-starry-sky authored Jun 4, 2020
1 parent 6cf1cbc commit 9384dee
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 2 deletions.
6 changes: 6 additions & 0 deletions src/kvstore/NebulaStore.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
#include "fs/FileUtils.h"
#include "kvstore/RocksEngine.h"
#include "kvstore/SnapshotManagerImpl.h"
#include <folly/ScopeGuard.h>

DEFINE_string(engine_type, "rocksdb", "rocksdb, memory...");
DEFINE_int32(custom_filter_interval_secs, 24 * 3600, "interval to trigger custom compaction");
Expand Down Expand Up @@ -824,6 +825,11 @@ bool NebulaStore::checkLeader(std::shared_ptr<Part> part) const {
}

void NebulaStore::cleanWAL() {
SCOPE_EXIT {
bgWorkers_->addDelayTask(FLAGS_clean_wal_interval_secs * 1000,
&NebulaStore::cleanWAL,
this);
};
for (const auto& spaceEntry : spaces_) {
for (const auto& engine : spaceEntry.second->engines_) {
engine->flush();
Expand Down
1 change: 0 additions & 1 deletion src/kvstore/raftex/Host.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -119,7 +119,6 @@ folly::Future<cpp2::AppendLogResponse> Host::appendLogs(

if (requestOnGoing_ && res == cpp2::ErrorCode::SUCCEEDED) {
if (cachingPromise_.size() <= FLAGS_max_outstanding_requests) {
logIdToSend_ = logId;
pendingReq_ = std::make_tuple(term,
logId,
committedLogId);
Expand Down
2 changes: 1 addition & 1 deletion src/kvstore/raftex/RaftPart.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1254,7 +1254,7 @@ void RaftPart::cleanupSnapshot() {

bool RaftPart::needToCleanWal() {
std::lock_guard<std::mutex> g(raftLock_);
if (status_ == Status::WAITING_SNAPSHOT) {
if (status_ == Status::STARTING || status_ == Status::WAITING_SNAPSHOT) {
return false;
}
for (auto& host : hosts_) {
Expand Down

0 comments on commit 9384dee

Please sign in to comment.