Created
December 1, 2014 19:40
-
-
Save Bowbaq/816890ec72681b0c8855 to your computer and use it in GitHub Desktop.
Use the LogReplay optimization, sort is already "$natural" by default
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
diff --git a/logreplayer.go b/logreplayer.go | |
index 4660651..817f644 100644 | |
--- a/logreplayer.go | |
+++ b/logreplayer.go | |
@@ -76,7 +76,7 @@ func (l *logReplayer) playLog() (err error) { | |
// set up initial query to the oplog | |
logger.Info("Replaying oplog from %s to %s", l.from, l.to) | |
- iter := sourceOplog.Find(bson.M{"ts": bson.M{"$gt": bson.MongoTimestamp(l.from)}}).Sort("$natural").Tail(1 * time.Second) | |
+ iter := sourceOplog.Find(bson.M{"ts": bson.M{"$gt": bson.MongoTimestamp(l.from)}}).LogReplay().Tail(1 * time.Second) | |
// loop over the oplog | |
outer: | |
@@ -175,7 +175,7 @@ outer: | |
logger.Critical("too many errors reading from oplog, bailing.") | |
os.Exit(1) | |
} | |
- iter = sourceOplog.Find(bson.M{"ts": bson.M{"$gt": lastTimestamp}}).Sort("$natural").Tail(1 * time.Second) | |
+ iter = sourceOplog.Find(bson.M{"ts": bson.M{"$gt": lastTimestamp}}).LogReplay().Tail(1 * time.Second) | |
} | |
for count > 0 { |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Nice, yeah
that's a good idea, I missed that first time around
Thanks