Commit 43bf564f authored by Georgios Bitzes's avatar Georgios Bitzes
Browse files

Restore ability to create bulkload nodes

parent 9ee5a7cb
Pipeline #778010 passed with stages
in 40 minutes
# Changelog
All notable changes to this project will be documented in this file.
## Unreleased
- Fixed regression introduced in 0.3.6, which made it impossible to create new
bulkload nodes. (Note: to workaround, delete directory ``/path/to/bulkload/current/state-machine``
right after running ``quarkdb-create``)
## 0.3.6 (2019-03-21)
- Improved memory management and recycling, putting less pressure on the global
memory allocator.
......
......@@ -130,31 +130,71 @@ std::string ShardDirectory::raftJournalPath() {
return pathJoin(currentPath(), "raft-journal");
}
//------------------------------------------------------------------------------
// Wipe out StateMachine contents.
//------------------------------------------------------------------------------
void ShardDirectory::wipeoutStateMachineContents() {
if(smptr) {
//--------------------------------------------------------------------------
// We have the state machine open already.. wipe contents through reset
//--------------------------------------------------------------------------
getStateMachine()->reset();
}
else {
//--------------------------------------------------------------------------
// Not open, simply delete the entire folder
//--------------------------------------------------------------------------
qdb_assert(system(SSTR("rm -rf '" << stateMachinePath() << "'").c_str()) == 0);
}
}
//------------------------------------------------------------------------------
// Initialize our StateMachine with the given source, if any.
// If no source is given, create a brand new one.
//------------------------------------------------------------------------------
void ShardDirectory::initializeStateMachine(std::unique_ptr<StateMachine> sm, LogIndex initialLastApplied) {
if(!sm && initialLastApplied == 0) {
//--------------------------------------------------------------------------
// Simplest case: No seed machine, and starting from 0.
// Just ensure SM is wiped out.
//--------------------------------------------------------------------------
wipeoutStateMachineContents();
return;
}
if(!sm) {
// Easy case, no existing contents. Wipe out any existing contents, if any.
getStateMachine()->reset();
//--------------------------------------------------------------------------
// No seed machine, but starting from non-zero.
//--------------------------------------------------------------------------
wipeoutStateMachineContents();
getStateMachine()->forceResetLastApplied(initialLastApplied);
}
else {
// We reset the contents of this ShardDirectory using a pre-existing
// StateMachine. First, get the target filename..
std::string sourceStateMahchine = sm->getPhysicalLocation();
// Shut it down - we don't want to be moving files of a live SM..
sm.reset();
//----------------------------------------------------------------------------
// We have to reset any old contents with those of the pre-existing seed
// StateMachine. First, get the target filename..
//----------------------------------------------------------------------------
std::string sourceStateMahchine = sm->getPhysicalLocation();
// Shut down any existing, to-be-deleted SMs we own
detach();
//----------------------------------------------------------------------------
// Shut it down - we don't want to be moving files of a live SM..
//----------------------------------------------------------------------------
sm.reset();
// Do the actual move
qdb_assert(system(SSTR("mv " << quotes(sourceStateMahchine) << " " << quotes(stateMachinePath()) ).c_str()) == 0);
}
//----------------------------------------------------------------------------
// Shut down and wipe out any existing, to-be-deleted SMs we own
//----------------------------------------------------------------------------
detach();
wipeoutStateMachineContents();
//----------------------------------------------------------------------------
// Do the actual move
//----------------------------------------------------------------------------
qdb_assert(system(SSTR("mv " << quotes(sourceStateMahchine) << " " << quotes(stateMachinePath()) ).c_str()) == 0);
//----------------------------------------------------------------------------
// Force reset lastApplied.
//----------------------------------------------------------------------------
getStateMachine()->forceResetLastApplied(initialLastApplied);
}
......
......@@ -89,6 +89,11 @@ public:
//----------------------------------------------------------------------------
void initializeStateMachine(std::unique_ptr<StateMachine> sm, LogIndex initialLastApplied);
//----------------------------------------------------------------------------
// Wipe out StateMachine contents.
//----------------------------------------------------------------------------
void wipeoutStateMachineContents();
private:
void parseResilveringHistory();
void storeResilveringHistory();
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment