Skip to content

Commit

Permalink
v2.0.11: add checkpoint update max try times, #323
Browse files Browse the repository at this point in the history
  • Loading branch information
vinllen committed Apr 8, 2020
1 parent aa42830 commit 06b5f27
Show file tree
Hide file tree
Showing 4 changed files with 21 additions and 6 deletions.
4 changes: 4 additions & 0 deletions ChangeLog
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
2020-04-08 Alibaba Cloud.
* version: 2.0.11
* BUGFIX: add checkpoint flush max try times to 10. see #323.

2020-03-27 Alibaba Cloud.
* version: 2.0.10
* BUGFIX: data may lost when using batch update meets duplicate error.
Expand Down
15 changes: 13 additions & 2 deletions src/mongoshake/collector/syncer.go
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ const (
DDLCheckpointInterval = 300 // unit: ms.
FilterCheckpointGap = 180 // unit: seconds. no checkpoint update, flush checkpoint mandatory
FilterCheckpointCheckInterval = 180 // unit: seconds.
CheckCheckpointUpdateTimes = 10 // at most times of time check
)

type OplogHandler interface {
Expand Down Expand Up @@ -263,8 +264,9 @@ func (sync *OplogSyncer) checkCheckpointUpdate(barrier bool, newestTs bson.Mongo
// if barrier == true, we should check whether the checkpoint is updated to `newestTs`.
if barrier && newestTs > 0 && conf.Options.WorkerNum > 1 {
LOG.Info("find barrier")
for {
checkpointTs := sync.ckptManager.Get().Timestamp
var checkpointTs bson.MongoTimestamp
for i := 0; i < CheckCheckpointUpdateTimes; i++ {
checkpointTs = sync.ckptManager.Get().Timestamp
LOG.Info("compare remote checkpoint[%v(%v)] to local newestTs[%v(%v)]",
checkpointTs, utils.ExtractMongoTimestamp(checkpointTs), newestTs, utils.ExtractMongoTimestamp(newestTs))
if checkpointTs >= newestTs {
Expand All @@ -276,6 +278,15 @@ func (sync *OplogSyncer) checkCheckpointUpdate(barrier bool, newestTs bson.Mongo
// re-flush
sync.checkpoint(true, 0)
}

/*
* if code hits here, it means the checkpoint has not been updated(usually DDL).
* it's ok because the checkpoint can still forward on the next time.
* However, if MongoShake crashes here and restarts, there maybe a conflict when the
* oplog is DDL that has been applied but checkpoint not updated.
*/
LOG.Warn("check checkpoint[%v] update[%v] failed, but do worry",
utils.ExtractTimestampForLog(checkpointTs), utils.ExtractTimestampForLog(newestTs))
}
}

Expand Down
2 changes: 1 addition & 1 deletion src/mongoshake/common/http.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,5 +9,5 @@ var (
)

func InitHttpApi(port int) {
HttpApi = nimo.NewHttpRestProvdier(port)
HttpApi = nimo.NewHttpRestProvider(port)
}
6 changes: 3 additions & 3 deletions src/vendor/vendor.json
Original file line number Diff line number Diff line change
Expand Up @@ -45,10 +45,10 @@
"revisionTime": "2019-09-04T06:34:54Z"
},
{
"checksumSHA1": "52vjznwP2OHubLvZkLCUCC9Gp5o=",
"checksumSHA1": "PA8OcnbR5oMK1TI+eA8CIuO7gLY=",
"path": "github.com/gugemichael/nimo4go",
"revision": "32795d80f83ab8c37b47589c5068dfbb14545c34",
"revisionTime": "2019-09-04T07:30:57Z"
"revision": "647883f3a053414d7dc4f3771c6c69b5c4a8ea11",
"revisionTime": "2020-04-03T10:17:49Z"
},
{
"checksumSHA1": "5AxXPtBqAKyFGcttFzxT5hp/3Tk=",
Expand Down

0 comments on commit 06b5f27

Please sign in to comment.