Skip to content

Commit

Permalink
sorter: correct wrong metric about next duration (#11577) (#11581)
Browse files Browse the repository at this point in the history
close #11576
  • Loading branch information
ti-chi-bot authored Sep 24, 2024
1 parent 8ae1396 commit 4d8c969
Showing 1 changed file with 9 additions and 6 deletions.
15 changes: 9 additions & 6 deletions cdc/processor/sourcemanager/engine/pebble/event_sorter.go
Original file line number Diff line number Diff line change
Expand Up @@ -319,17 +319,20 @@ func (s *EventSorter) SlotsAndHasher() (slotCount int, hasher func(tablepb.Span,
// Next implements sorter.EventIterator.
func (s *EventIter) Next() (event *model.PolymorphicEvent, pos engine.Position, err error) {
valid := s.iter != nil && s.iter.Valid()
var value []byte
for valid {
nextStart := time.Now()
value = s.iter.Value()
s.nextDuration.Observe(time.Since(nextStart).Seconds())

// We need to decide whether the current event is the last event in this transactions
// If the current event is the last one, we need to set txnFinished
// Thus, we need to fetch the next event and compare the commitTs and startTs with it
for valid {
event = &model.PolymorphicEvent{}
if _, err = s.serde.Unmarshal(event, value); err != nil {
if _, err = s.serde.Unmarshal(event, s.iter.Value()); err != nil {
return
}

nextStart := time.Now()
valid = s.iter.Next()
s.nextDuration.Observe(time.Since(nextStart).Seconds())

if s.headItem != nil {
break
}
Expand Down

0 comments on commit 4d8c969

Please sign in to comment.