47
47
#include " mongo/db/repl/replication_coordinator_mock.h"
48
48
#include " mongo/db/s/op_observer_sharding_impl.h"
49
49
#include " mongo/dbtests/dbtests.h"
50
+ #include " mongo/logger/logger.h"
50
51
#include " mongo/transport/transport_layer_asio.h"
51
52
#include " mongo/util/log.h"
52
53
53
54
using namespace mongo ::repl;
54
55
55
56
namespace ReplTests {
56
57
58
+ using mongo::logger::globalLogDomain;
59
+ using mongo::logger::LogComponent;
60
+ using mongo::logger::LogSeverity;
57
61
using std::endl;
58
62
using std::string;
59
63
using std::stringstream;
@@ -258,25 +262,6 @@ class Base {
258
262
}
259
263
}
260
264
}
261
- void printAll (const char * ns) {
262
- Lock::GlobalWrite lk (&_opCtx);
263
- OldClientContext ctx (&_opCtx, ns);
264
- NamespaceString nss (ns);
265
-
266
- Database* db = ctx.db ();
267
- Collection* coll = CollectionCatalog::get (&_opCtx).lookupCollectionByNamespace (nss);
268
- if (!coll) {
269
- WriteUnitOfWork wunit (&_opCtx);
270
- coll = db->createCollection (&_opCtx, nss);
271
- wunit.commit ();
272
- }
273
-
274
- auto cursor = coll->getCursor (&_opCtx);
275
- ::mongo::log () << "all for " << ns << endl;
276
- while (auto record = cursor->next ()) {
277
- ::mongo::log () << record->data.releaseToBson() << endl;
278
- }
279
- }
280
265
// These deletes don't get logged.
281
266
void deleteAll (const char * ns) const {
282
267
::mongo::writeConflictRetry (&_opCtx, " deleteAll" , ns, [&] {
@@ -1312,11 +1297,22 @@ class ReplayArrayFieldNotAppended : public Base {
1312
1297
1313
1298
class DeleteOpIsIdBased : public Base {
1314
1299
public:
1300
+ DeleteOpIsIdBased () : _oldSeverity(globalLogDomain()->getMinimumLogSeverity ()) {
1301
+ // TODO (SERVER-43399): This is temporary to help diagnose a rare failure.
1302
+ globalLogDomain ()->setMinimumLoggedSeverity (LogComponent::kDefault , LogSeverity::Debug (2 ));
1303
+ }
1304
+
1305
+ ~DeleteOpIsIdBased () {
1306
+ globalLogDomain ()->setMinimumLoggedSeverity (LogComponent::kDefault , _oldSeverity);
1307
+ }
1308
+
1315
1309
void run () {
1316
1310
// Replication is not supported by mobile SE.
1317
1311
if (mongo::storageGlobalParams.engine == " mobile" ) {
1318
1312
return ;
1319
1313
}
1314
+
1315
+ // These inserts don't write oplog entries.
1320
1316
insert (BSON (" _id" << 0 << " a" << 10 ));
1321
1317
insert (BSON (" _id" << 1 << " a" << 11 ));
1322
1318
insert (BSON (" _id" << 3 << " a" << 10 ));
@@ -1325,12 +1321,16 @@ class DeleteOpIsIdBased : public Base {
1325
1321
insert (BSON (" _id" << 0 << " a" << 11 ));
1326
1322
insert (BSON (" _id" << 2 << " a" << 10 ));
1327
1323
insert (BSON (" _id" << 3 << " a" << 10 ));
1328
-
1324
+ // Now the collection has _ids 0, 1, 2, 3. Apply the delete oplog entries for _id 0 and 3.
1329
1325
applyAllOperations ();
1326
+ // _id 1 and 2 remain.
1330
1327
ASSERT_EQUALS (2U , _client.count (nss (), BSONObj ()));
1331
1328
ASSERT (!one (BSON (" _id" << 1 )).isEmpty ());
1332
1329
ASSERT (!one (BSON (" _id" << 2 )).isEmpty ());
1333
1330
}
1331
+
1332
+ private:
1333
+ LogSeverity _oldSeverity;
1334
1334
};
1335
1335
1336
1336
class All : public OldStyleSuiteSpecification {
0 commit comments