File tree Expand file tree Collapse file tree 1 file changed +7
-3
lines changed Expand file tree Collapse file tree 1 file changed +7
-3
lines changed Original file line number Diff line number Diff line change @@ -661,6 +661,7 @@ func (o *OplogRestore) handleNonTxnOp(op db.Oplog) error {
661
661
return errors .Wrap (err , "filtering UUIDs from oplog" )
662
662
}
663
663
664
+ dbName , collName , _ := strings .Cut (op .Namespace , "." )
664
665
if op .Operation == "c" {
665
666
if len (op .Object ) == 0 {
666
667
return errors .Errorf ("empty object value for op: %v" , op )
@@ -671,9 +672,6 @@ func (o *OplogRestore) handleNonTxnOp(op db.Oplog) error {
671
672
return errors .Errorf ("unknown oplog command name %v: %v" , cmdName , op )
672
673
}
673
674
674
- ns := strings .Split (op .Namespace , "." )
675
- dbName := ns [0 ]
676
-
677
675
switch cmdName {
678
676
case "commitIndexBuild" :
679
677
// commitIndexBuild was introduced in 4.4, one "commitIndexBuild" command can contain several
@@ -793,6 +791,12 @@ func (o *OplogRestore) handleNonTxnOp(op db.Oplog) error {
793
791
return errors .Wrap (err , "oplog: drop collection before create" )
794
792
}
795
793
}
794
+ } else if op .Operation == "i" && collName == "system.views" {
795
+ // PBM-921: ensure the collection exists before "creating" views or timeseries
796
+ err := o .dst .Database (dbName ).CreateCollection (context .TODO (), "system.views" )
797
+ if err != nil {
798
+ return errors .Wrapf (err , "ensure %s.system.views collection" , dbName )
799
+ }
796
800
}
797
801
798
802
err = o .applyOps ([]interface {}{op })
You can’t perform that action at this time.
0 commit comments