@@ -310,6 +310,27 @@ func (o *OplogRestore) isOpSelected(oe *Record) bool {
310
310
return false
311
311
}
312
312
313
+ func (o * OplogRestore ) isOpExcluded (oe * Record ) bool {
314
+ if o .excludeNS == nil {
315
+ return false
316
+ }
317
+ db , coll , _ := strings .Cut (oe .Namespace , "." )
318
+ if coll != "$cmd" {
319
+ return o .excludeNS .Has (oe .Namespace )
320
+ }
321
+
322
+ cmd := oe .Object [0 ].Key
323
+ if cmd == "applyOps" {
324
+ return false // internal ops of applyOps are checked one by one later
325
+ }
326
+ if _ , ok := selectedNSSupportedCommands [cmd ]; ok {
327
+ coll , _ = oe .Object [0 ].Value .(string )
328
+ return o .excludeNS .Has (db + "." + coll )
329
+ }
330
+
331
+ return false
332
+ }
333
+
313
334
func (o * OplogRestore ) LastOpTS () uint32 {
314
335
return atomic .LoadUint32 (& o .lastOpT )
315
336
}
@@ -325,11 +346,7 @@ func (o *OplogRestore) handleOp(oe db.Oplog) error {
325
346
return nil
326
347
}
327
348
328
- if o .excludeNS .Has (oe .Namespace ) {
329
- return nil
330
- }
331
-
332
- if ! isOpAllowed (& oe ) || ! o .isOpSelected (& oe ) {
349
+ if o .isOpExcluded (& oe ) || ! isOpAllowed (& oe ) || ! o .isOpSelected (& oe ) {
333
350
return nil
334
351
}
335
352
@@ -648,11 +665,7 @@ func (o *OplogRestore) HandleUncommittedTxn(
648
665
func (o * OplogRestore ) handleNonTxnOp (op db.Oplog ) error {
649
666
// have to handle it here one more time because before the op gets thru
650
667
// txnBuffer its namespace is `collection.$cmd` instead of the real one
651
- if o .excludeNS .Has (op .Namespace ) {
652
- return nil
653
- }
654
-
655
- if ! isOpAllowed (& op ) || ! o .isOpSelected (& op ) {
668
+ if o .isOpExcluded (& op ) || ! isOpAllowed (& op ) || ! o .isOpSelected (& op ) {
656
669
return nil
657
670
}
658
671
0 commit comments