summaryrefslogtreecommitdiff
path: root/src/mongo/db/repl/databases_cloner.h
diff options
context:
space:
mode:
authorBenety Goh <benety@mongodb.com>2016-11-28 21:30:41 -0500
committerBenety Goh <benety@mongodb.com>2016-11-28 21:30:41 -0500
commit19a7178e9b457d75b0431f384b85d69d7309a563 (patch)
treef70c0cc8acc09c89a39d651068fceb1d4af89874 /src/mongo/db/repl/databases_cloner.h
parent06da357873b3500f39832dee914c06b1968d05ca (diff)
downloadmongo-19a7178e9b457d75b0431f384b85d69d7309a563.tar.gz
SERVER-27052 clarified DatabasesCloner's startup and shutdown contract.
DatabasesCloner::startup() does not invoke completion callback on failing to schedule first remote command DatabasesCloner::shutdown() leaves _active state unchanged DatabasesCloner clears DatabasesCloner::_finishFn on completion to release any resources that might be held by function object make DatabasesCloner single-use only - cannot be restarted once completed
Diffstat (limited to 'src/mongo/db/repl/databases_cloner.h')
-rw-r--r--src/mongo/db/repl/databases_cloner.h15
1 files changed, 12 insertions, 3 deletions
diff --git a/src/mongo/db/repl/databases_cloner.h b/src/mongo/db/repl/databases_cloner.h
index 99748af768f..53cced9ee4f 100644
--- a/src/mongo/db/repl/databases_cloner.h
+++ b/src/mongo/db/repl/databases_cloner.h
@@ -83,7 +83,7 @@ public:
~DatabasesCloner();
- Status startup();
+ Status startup() noexcept;
bool isActive();
void join();
void shutdown();
@@ -105,6 +105,8 @@ public:
void setScheduleDbWorkFn_forTest(const CollectionCloner::ScheduleDbWorkFn& scheduleDbWorkFn);
private:
+ bool _isActive_inlock() const;
+
/**
* Returns a copy of the database cloners.
*/
@@ -146,16 +148,23 @@ private:
executor::TaskExecutor* _exec; // (R) executor to schedule things with
OldThreadPool* _dbWorkThreadPool; // (R) db worker thread pool for collection cloning.
const HostAndPort _source; // (R) The source to use.
- bool _active = false; // (M) false until we start, and true until finished.
CollectionCloner::ScheduleDbWorkFn _scheduleDbWorkFn; // (M)
const IncludeDbFilterFn _includeDbFn; // (R) function which decides which dbs are cloned.
- const OnFinishFn _finishFn; // (R) function called when finished.
+ OnFinishFn _finishFn; // (M) function called when finished.
StorageInterface* _storage; // (R)
std::unique_ptr<RemoteCommandRetryScheduler> _listDBsScheduler; // (M) scheduler for listDBs.
std::vector<std::shared_ptr<DatabaseCloner>> _databaseCloners; // (M) database cloners by name
Stats _stats; // (M)
+
+ // State transitions:
+ // PreStart --> Running --> ShuttingDown --> Complete
+ // It is possible to skip intermediate states. For example,
+ // Calling shutdown() when the cloner has not started will transition from PreStart directly
+ // to Complete.
+ enum class State { kPreStart, kRunning, kShuttingDown, kComplete };
+ State _state = State::kPreStart;
};