summaryrefslogtreecommitdiff
path: root/src/mongo/db/repl/oplog.h
diff options
context:
space:
mode:
authorEric Milkie <milkie@10gen.com>2017-08-29 13:51:15 -0400
committerEric Milkie <milkie@10gen.com>2017-09-12 16:04:57 -0400
commit6264d36ac6002b296aa41b8dc79400fcc2cbdd74 (patch)
treef1c0971779064bbf6c3fde535b7666d8738f236d /src/mongo/db/repl/oplog.h
parent978521eb3926867b30903781fd89d4acd931f0c4 (diff)
downloadmongo-6264d36ac6002b296aa41b8dc79400fcc2cbdd74.tar.gz
SERVER-30827 SERVER-30639 Timestamp bulk writes via changes to optime generator
Diffstat (limited to 'src/mongo/db/repl/oplog.h')
-rw-r--r--src/mongo/db/repl/oplog.h40
1 files changed, 38 insertions, 2 deletions
diff --git a/src/mongo/db/repl/oplog.h b/src/mongo/db/repl/oplog.h
index 812efb81310..2198bb86c7e 100644
--- a/src/mongo/db/repl/oplog.h
+++ b/src/mongo/db/repl/oplog.h
@@ -34,10 +34,11 @@
#include "mongo/base/status.h"
#include "mongo/bson/bsonobj.h"
#include "mongo/bson/timestamp.h"
-#include "mongo/db/catalog/collection.h"
#include "mongo/db/catalog/collection_options.h"
+#include "mongo/db/logical_session_id.h"
#include "mongo/db/repl/optime.h"
#include "mongo/db/repl/replication_coordinator.h"
+#include "mongo/db/storage/snapshot_name.h"
#include "mongo/stdx/functional.h"
namespace mongo {
@@ -48,6 +49,30 @@ class OperationContext;
class OperationSessionInfo;
class Session;
+struct OplogSlot {
+ OplogSlot() {}
+ OplogSlot(repl::OpTime opTime, std::int64_t hash) : opTime(opTime), hash(hash) {}
+ repl::OpTime opTime;
+ std::int64_t hash = 0;
+};
+
+struct InsertStatement {
+public:
+ InsertStatement() = default;
+ explicit InsertStatement(BSONObj toInsert) : doc(toInsert) {}
+
+ InsertStatement(StmtId statementId, BSONObj toInsert) : stmtId(statementId), doc(toInsert) {}
+ InsertStatement(StmtId statementId, BSONObj toInsert, OplogSlot os)
+ : stmtId(statementId), oplogSlot(os), doc(toInsert) {}
+ InsertStatement(BSONObj toInsert, SnapshotName ts)
+ : oplogSlot(repl::OpTime(Timestamp(ts.asU64()), repl::OpTime::kUninitializedTerm), 0),
+ doc(toInsert) {}
+
+ StmtId stmtId = kUninitializedStmtId;
+ OplogSlot oplogSlot;
+ BSONObj doc;
+};
+
namespace repl {
class ReplSettings;
@@ -118,10 +143,15 @@ OpTime logOp(OperationContext* opCtx,
StmtId stmtId,
const OplogLink& oplogLink);
-// Flush out the cached pointers to the local database and oplog.
+// Flush out the cached pointer to the oplog.
// Used by the closeDatabase command to ensure we don't cache closed things.
void oplogCheckCloseDatabase(OperationContext* opCtx, Database* db);
+/**
+ * Establish the cached pointer to the local oplog.
+ */
+void acquireOplogCollectionForLogging(OperationContext* opCtx);
+
using IncrementOpsAppliedStatsFn = stdx::function<void()>;
/**
* Take the object field of a BSONObj, the BSONObj, and the namespace of
@@ -184,5 +214,11 @@ void createIndexForApplyOps(OperationContext* opCtx,
const NamespaceString& indexNss,
IncrementOpsAppliedStatsFn incrementOpsAppliedStats);
+/**
+ * Allocates optimes for new entries in the oplog. Returns an array of OplogSlots, which contain
+ * the new optimes along with their terms and newly calculated hash fields.
+ */
+void getNextOpTimes(OperationContext* opCtx, std::size_t count, OplogSlot* slotsOut);
+
} // namespace repl
} // namespace mongo