summaryrefslogtreecommitdiff
path: root/src/mongo/db/repl/bgsync.h
diff options
context:
space:
mode:
Diffstat (limited to 'src/mongo/db/repl/bgsync.h')
-rw-r--r--src/mongo/db/repl/bgsync.h42
1 files changed, 29 insertions, 13 deletions
diff --git a/src/mongo/db/repl/bgsync.h b/src/mongo/db/repl/bgsync.h
index ead036c79d2..6d068967723 100644
--- a/src/mongo/db/repl/bgsync.h
+++ b/src/mongo/db/repl/bgsync.h
@@ -174,31 +174,47 @@ private:
// A pointer to the replication coordinator external state.
ReplicationCoordinatorExternalState* _replicationCoordinatorExternalState;
- // _mutex protects all of the class variables declared below.
- //
- // Never hold bgsync mutex when trying to acquire the ReplicationCoordinator mutex.
- mutable stdx::mutex _mutex;
+ /**
+ * All member variables are labeled with one of the following codes indicating the
+ * synchronization rules for accessing them:
+ *
+ * (PR) Completely private to BackgroundSync. Can be read or written to from within the main
+ * BackgroundSync thread without synchronization. Shouldn't be accessed outside of this
+ * thread.
+ *
+ * (S) Self-synchronizing; access in any way from any context.
+ *
+ * (M) Reads and writes guarded by _mutex
+ *
+ */
- OpTime _lastOpTimeFetched;
+ // Protects member data of BackgroundSync.
+ // Never hold the BackgroundSync mutex when trying to acquire the ReplicationCoordinator mutex.
+ mutable stdx::mutex _mutex; // (S)
- // lastFetchedHash is used to match ops to determine if we need to rollback, when
- // a secondary.
- long long _lastFetchedHash = 0LL;
+ OpTime _lastOpTimeFetched; // (M)
+
+ // lastFetchedHash is used to match ops to determine if we need to rollback, when a secondary.
+ long long _lastFetchedHash = 0LL; // (M)
// Thread running producerThread().
- std::unique_ptr<stdx::thread> _producerThread;
+ std::unique_ptr<stdx::thread> _producerThread; // (M)
// Set to true if shutdown() has been called.
- bool _inShutdown = false;
+ bool _inShutdown = false; // (M)
+
+ // Flag that marks whether a node's oplog has no common point with any
+ // potential sync sources.
+ bool _tooStale = false; // (PR)
- ProducerState _state = ProducerState::Starting;
+ ProducerState _state = ProducerState::Starting; // (M)
- HostAndPort _syncSourceHost;
+ HostAndPort _syncSourceHost; // (M)
// Current sync source resolver validating sync source candidates.
// Pointer may be read on any thread that locks _mutex or unlocked on the BGSync thread. It can
// only be written to by the BGSync thread while holding _mutex.
- std::unique_ptr<SyncSourceResolver> _syncSourceResolver;
+ std::unique_ptr<SyncSourceResolver> _syncSourceResolver; // (M)
// Current oplog fetcher tailing the oplog on the sync source.
std::unique_ptr<OplogFetcher> _oplogFetcher;