Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 5 additions & 9 deletions pkg/eventservice/dispatcher_stat.go
Original file line number Diff line number Diff line change
Expand Up @@ -431,21 +431,17 @@ type changefeedStatus struct {
minSentTs atomic.Uint64
scanInterval atomic.Int64

lastAdjustTime atomic.Time
lastTrendAdjustTime atomic.Time
usageWindow *memoryUsageWindow
syncPointInterval time.Duration
scanWindowController *adaptiveScanWindowController
syncPointInterval time.Duration
}

func newChangefeedStatus(changefeedID common.ChangeFeedID, syncPointInterval time.Duration) *changefeedStatus {
status := &changefeedStatus{
changefeedID: changefeedID,
usageWindow: newMemoryUsageWindow(memoryUsageWindowDuration),
syncPointInterval: syncPointInterval,
changefeedID: changefeedID,
scanWindowController: newAdaptiveScanWindowController(time.Now()),
syncPointInterval: syncPointInterval,
}
status.scanInterval.Store(int64(defaultScanInterval))
status.lastAdjustTime.Store(time.Now())
status.lastTrendAdjustTime.Store(time.Now())

return status
}
Expand Down
7 changes: 2 additions & 5 deletions pkg/eventservice/event_broker.go
Original file line number Diff line number Diff line change
Expand Up @@ -1142,9 +1142,7 @@ func (c *eventBroker) removeChangefeedStatus(status *changefeedStatus) {
}

filter.GetSharedFilterStorage().RemoveFilter(changefeedID)
metrics.EventServiceAvailableMemoryQuotaGaugeVec.DeleteLabelValues(changefeedID.String())
metrics.EventServiceScanWindowBaseTsGaugeVec.DeleteLabelValues(changefeedID.String())
metrics.EventServiceScanWindowIntervalGaugeVec.DeleteLabelValues(changefeedID.String())
deleteScanWindowMetrics(changefeedID.String())
}

func (c *eventBroker) resetDispatcher(dispatcherInfo DispatcherInfo) error {
Expand Down Expand Up @@ -1263,8 +1261,7 @@ func (c *eventBroker) getOrSetChangefeedStatus(info DispatcherInfo) *changefeedS
return actual.(*changefeedStatus)
}
log.Info("new changefeed status", zap.Stringer("changefeedID", changefeedID))
metrics.EventServiceScanWindowBaseTsGaugeVec.WithLabelValues(changefeedID.String()).Set(0)
metrics.EventServiceScanWindowIntervalGaugeVec.WithLabelValues(changefeedID.String()).Set(defaultScanInterval.Seconds())
initializeScanWindowMetrics(changefeedID.String())
return status
}

Expand Down
6 changes: 2 additions & 4 deletions pkg/eventservice/event_broker_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -373,7 +373,6 @@ func TestHandleCongestionControlV2AdjustsScanInterval(t *testing.T) {
status := addChangefeedStatusToBrokerForTest(t, broker, changefeedID, time.Second*10)

status.scanInterval.Store(int64(40 * time.Second))
status.lastAdjustTime.Store(time.Now())

control := event.NewCongestionControlWithVersion(event.CongestionControlVersion2)
control.AddAvailableMemoryWithDispatchersAndUsage(changefeedID.ID(), 0, 1, nil)
Expand All @@ -382,7 +381,7 @@ func TestHandleCongestionControlV2AdjustsScanInterval(t *testing.T) {
require.Equal(t, int64(10*time.Second), status.scanInterval.Load())
}

func TestHandleCongestionControlV2ResetsScanIntervalOnMemoryRelease(t *testing.T) {
func TestHandleCongestionControlV2DoesNotResetScanIntervalOnMemoryRelease(t *testing.T) {
broker, _, _, _ := newEventBrokerForTest()
defer broker.close()

Expand All @@ -395,7 +394,7 @@ func TestHandleCongestionControlV2ResetsScanIntervalOnMemoryRelease(t *testing.T
control.AddAvailableMemoryWithDispatchersAndUsageAndReleaseCount(changefeedID.ID(), 0, 0.5, nil, 1)
broker.handleCongestionControl(node.ID("event-collector-1"), control)

require.Equal(t, int64(defaultScanInterval), status.scanInterval.Load())
require.Equal(t, int64(40*time.Second), status.scanInterval.Load())
}

func TestHandleCongestionControlV1DoesNotAdjustScanInterval(t *testing.T) {
Expand All @@ -406,7 +405,6 @@ func TestHandleCongestionControlV1DoesNotAdjustScanInterval(t *testing.T) {
status := addChangefeedStatusToBrokerForTest(t, broker, changefeedID, time.Second*10)

status.scanInterval.Store(int64(40 * time.Second))
status.lastAdjustTime.Store(time.Now())

control := event.NewCongestionControl()
control.AddAvailableMemoryWithDispatchers(changefeedID.ID(), 0, nil)
Expand Down
Loading
Loading