@@ -40,7 +40,9 @@ type CDC struct {
40
40
// sentTs is the timestamp till which we have send the event of txns.
41
41
// There will be no event below this timestamp for which we need to send the events
42
42
sentTs uint64
43
- maxTs uint64
43
+ // maxSentTs is the maximum timestamp till which we have sent the events of txns.
44
+ // this is helpful to maintain the state of the CDC till which we can clear the raft logs
45
+ maxSentTs uint64
44
46
}
45
47
46
48
func newCDC () * CDC {
@@ -76,7 +78,6 @@ func (cdc *CDC) updateTs(newTs uint64) {
76
78
if ts >= newTs {
77
79
return
78
80
}
79
- glog .Infoln ("ts updated to " , newTs )
80
81
atomic .CompareAndSwapUint64 (& cdc .sentTs , ts , newTs )
81
82
}
82
83
@@ -139,7 +140,7 @@ func (cdc *CDC) processCDCEvents() {
139
140
// skip ahead the index to prevent uncontrolled growth of raft logs.
140
141
if uint64 (len (cdc .pendingTxnEvents )) > cdc .maxRecoveryEntries {
141
142
glog .Info ("too many pending cdc events. Skipping for now." )
142
- cdc .updateTs (cdc . maxTs )
143
+ cdc .updateTs (posting . Oracle (). MaxAssigned () )
143
144
cdc .index = last
144
145
cdc .pendingTxnEvents = make (map [uint64 ][]CDCEvent )
145
146
return
@@ -191,7 +192,6 @@ func (cdc *CDC) processCDCEvents() {
191
192
192
193
if proposal .Delta != nil {
193
194
for _ , ts := range proposal .Delta .Txns {
194
- cdc .maxTs = x .Max (cdc .maxTs , ts .StartTs )
195
195
pending := cdc .pendingTxnEvents [ts .StartTs ]
196
196
if ts .CommitTs > 0 && len (pending ) > 0 {
197
197
if err := sendEvents (ts , pending ); err != nil {
@@ -201,6 +201,7 @@ func (cdc *CDC) processCDCEvents() {
201
201
}
202
202
// delete from pending events once events are sent
203
203
delete (cdc .pendingTxnEvents , ts .StartTs )
204
+ cdc .maxSentTs = x .Max (cdc .maxSentTs , ts .StartTs )
204
205
cdc .evaluateAndSetTs ()
205
206
}
206
207
}
@@ -244,8 +245,7 @@ func (cdc *CDC) evaluateAndSetTs() {
244
245
if cdc == nil || x .WorkerConfig .LudicrousMode {
245
246
return
246
247
}
247
- min := cdc .maxTs
248
- glog .Infoln (min , cdc .pendingTxnEvents )
248
+ min := cdc .maxSentTs
249
249
for ts := range cdc .pendingTxnEvents {
250
250
if ts < min {
251
251
min = ts
0 commit comments