grid2: adjust rollback duration to twice

This commit is contained in:
c9s 2022-12-26 18:05:35 +08:00
parent a66cee9130
commit a4f5d15334
No known key found for this signature in database
GPG Key ID: 7385E7E464CB0A54

View File

@ -1055,6 +1055,7 @@ func (s *Strategy) recoverGrid(ctx context.Context, historyService types.Exchang
startTime := firstOrderTime startTime := firstOrderTime
endTime := now endTime := now
maxTries := 3 maxTries := 3
localHistoryRollbackDuration := historyRollbackDuration
for maxTries > 0 { for maxTries > 0 {
maxTries-- maxTries--
if err := s.replayOrderHistory(ctx, grid, orderBook, historyService, startTime, endTime, lastOrderID); err != nil { if err := s.replayOrderHistory(ctx, grid, orderBook, historyService, startTime, endTime, lastOrderID); err != nil {
@ -1069,12 +1070,13 @@ func (s *Strategy) recoverGrid(ctx context.Context, historyService types.Exchang
} }
// history rollback range // history rollback range
startTime = startTime.Add(-historyRollbackDuration) startTime = startTime.Add(-localHistoryRollbackDuration)
if newFromOrderID := lastOrderID - historyRollbackOrderIdRange; newFromOrderID > 1 { if newFromOrderID := lastOrderID - historyRollbackOrderIdRange; newFromOrderID > 1 {
lastOrderID = newFromOrderID lastOrderID = newFromOrderID
} }
s.logger.Infof("GRID RECOVER: there are still more than two missing orders, rolling back query start time to earlier time point %s, fromID %d", startTime.String(), lastOrderID) s.logger.Infof("GRID RECOVER: there are still more than two missing orders, rolling back query start time to earlier time point %s, fromID %d", startTime.String(), lastOrderID)
localHistoryRollbackDuration = localHistoryRollbackDuration * 2
} }
} }