Commit 5930abd 简游
committed
1 parent c81e3ab commit 5930abd Copy full SHA for 5930abd
File tree 1 file changed +9
-0
lines changed
1 file changed +9
-0
lines changed Original file line number Diff line number Diff line change @@ -3,6 +3,7 @@ package executor
3
3
import (
4
4
"fmt"
5
5
"go.mongodb.org/mongo-driver/bson"
6
+ "sort"
6
7
"strings"
7
8
"sync"
8
9
"sync/atomic"
@@ -234,6 +235,14 @@ func (exec *Executor) doSync(logs []*OplogRecord) error {
234
235
235
236
transLogs := transformLogs (logs , exec .batchExecutor .NsTrans , conf .Options .IncrSyncDBRef )
236
237
238
+ // eventual consistency
239
+ // only sort CURD now for effective bulk insert
240
+ if len (logs ) > 0 && logs [0 ].original .partialLog .Operation != "c" {
241
+ sort .SliceStable (transLogs , func (i , j int ) bool {
242
+ return transLogs [i ].original .partialLog .Namespace < transLogs [j ].original .partialLog .Namespace
243
+ })
244
+ }
245
+
237
246
// split batched oplogRecords into (ns, op) groups. individual group
238
247
// can be accomplished in single MongoDB request. groups
239
248
// in this executor will be sequential
You can’t perform that action at this time.
0 commit comments