38
38
#include " mongo/bson/timestamp.h"
39
39
#include " mongo/db/repl/oplog_entry.h"
40
40
#include " mongo/db/repl/roll_back_local_operations.h"
41
+ #include " mongo/db/storage/remove_saver.h"
41
42
#include " mongo/logv2/log.h"
42
43
#include " mongo/logv2/log_attr.h"
43
44
#include " mongo/logv2/log_component.h"
@@ -76,6 +77,9 @@ long long getTerm(const OplogInterface::Iterator::Value& oplogValue) {
76
77
}
77
78
} // namespace
78
79
80
+ static constexpr auto kRollbackRemoveSaverType = " rollback" ;
81
+ static constexpr auto kRollbackRemoveSaverWhy = " removed" ;
82
+
79
83
RollBackLocalOperations::RollBackLocalOperations (const OplogInterface& localOplog,
80
84
const RollbackOperationFn& rollbackOperation)
81
85
@@ -99,7 +103,7 @@ RollBackLocalOperations::RollbackCommonPoint::RollbackCommonPoint(BSONObj oplogB
99
103
}
100
104
101
105
StatusWith<RollBackLocalOperations::RollbackCommonPoint> RollBackLocalOperations::onRemoteOperation (
102
- const BSONObj& operation) {
106
+ const BSONObj& operation, RemoveSaver& removeSaver, bool shouldCreateDataFiles ) {
103
107
if (_scanned == 0 ) {
104
108
auto result = _localOplogIterator->next ();
105
109
if (!result.isOK ()) {
@@ -118,6 +122,9 @@ StatusWith<RollBackLocalOperations::RollbackCommonPoint> RollBackLocalOperations
118
122
2 ,
119
123
" Local oplog entry to roll back" ,
120
124
" oplogEntry" _attr = redact (_localOplogValue.first ));
125
+ if (shouldCreateDataFiles) {
126
+ fassert (9777500 , removeSaver.goingToDelete (_localOplogValue.first ));
127
+ }
121
128
auto status = _rollbackOperation (_localOplogValue.first );
122
129
if (!status.isOK ()) {
123
130
invariant (ErrorCodes::NoSuchKey != status.code ());
@@ -163,7 +170,8 @@ StatusWith<RollBackLocalOperations::RollbackCommonPoint> RollBackLocalOperations
163
170
StatusWith<RollBackLocalOperations::RollbackCommonPoint> syncRollBackLocalOperations (
164
171
const OplogInterface& localOplog,
165
172
const OplogInterface& remoteOplog,
166
- const RollBackLocalOperations::RollbackOperationFn& rollbackOperation) {
173
+ const RollBackLocalOperations::RollbackOperationFn& rollbackOperation,
174
+ bool shouldCreateDataFiles) {
167
175
168
176
std::unique_ptr<OplogInterface::Iterator> remoteIterator;
169
177
@@ -187,10 +195,12 @@ StatusWith<RollBackLocalOperations::RollbackCommonPoint> syncRollBackLocalOperat
187
195
188
196
RollBackLocalOperations finder (localOplog, rollbackOperation);
189
197
Timestamp theirTime;
198
+ RemoveSaver removeSaver (kRollbackRemoveSaverType , " local.oplog.rs" , kRollbackRemoveSaverWhy );
190
199
while (remoteResult.isOK ()) {
191
200
BSONObj theirObj = remoteResult.getValue ().first ;
192
201
theirTime = theirObj[" ts" ].timestamp ();
193
- auto result = finder.onRemoteOperation (theirObj);
202
+
203
+ auto result = finder.onRemoteOperation (theirObj, removeSaver, shouldCreateDataFiles);
194
204
if (result.isOK ()) {
195
205
return result.getValue ();
196
206
} else if (result.getStatus ().code () != ErrorCodes::NoSuchKey) {
0 commit comments