Skip to content

Commit 63f6754

Browse files
committed
switch to always getting new cluster time
1 parent 313b1fe commit 63f6754

File tree

1 file changed

+13
-12
lines changed

1 file changed

+13
-12
lines changed

internal/verifier/clustertime.go

Lines changed: 13 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ func GetNewClusterTime(
3535
logger,
3636
func(_ *retry.Info) error {
3737
var err error
38-
clusterTime, err = fetchClusterTime(ctx, client)
38+
clusterTime, err = fetchNewClusterTime(ctx, client)
3939
return err
4040
},
4141
)
@@ -67,15 +67,14 @@ func GetNewClusterTime(
6767

6868
// Use this when we just need the correct cluster time without
6969
// actually changing any shards’ oplogs.
70-
func fetchClusterTime(
70+
func fetchNewClusterTime(
7171
ctx context.Context,
7272
client *mongo.Client,
7373
) (primitive.Timestamp, error) {
7474
cmd, rawResponse, err := runAppendOplogNote(
7575
ctx,
7676
client,
7777
"expect StaleClusterTime error",
78-
primitive.Timestamp{1, 0},
7978
)
8079

8180
// We expect an error here; if we didn't get one then something is
@@ -103,7 +102,7 @@ func syncClusterTimeAcrossShards(
103102
ctx,
104103
client,
105104
"syncing cluster time",
106-
maxTime,
105+
bson.E{"maxClusterTime", maxTime},
107106
)
108107

109108
if err != nil {
@@ -120,15 +119,17 @@ func runAppendOplogNote(
120119
ctx context.Context,
121120
client *mongo.Client,
122121
note string,
123-
maxClusterTime primitive.Timestamp,
122+
extra ...bson.E,
124123
) (bson.D, bson.Raw, error) {
125-
cmd := bson.D{
126-
{"appendOplogNote", 1},
127-
{"maxClusterTime", maxClusterTime},
128-
{"data", bson.D{
129-
{"migration-verifier", note},
130-
}},
131-
}
124+
cmd := append(
125+
bson.D{
126+
{"appendOplogNote", 1},
127+
{"data", bson.D{
128+
{"migration-verifier", note},
129+
}},
130+
},
131+
extra...,
132+
)
132133

133134
resp := client.
134135
Database(

0 commit comments

Comments
 (0)