Skip to content

Commit

Permalink
cleanup
Browse files Browse the repository at this point in the history
Signed-off-by: Tim Vaillancourt <tim@timvaillancourt.com>
  • Loading branch information
timvaillancourt committed Jun 7, 2024
1 parent 15e9317 commit 396151d
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 24 deletions.
5 changes: 3 additions & 2 deletions go/vt/throttler/throttler.go
Original file line number Diff line number Diff line change
Expand Up @@ -229,12 +229,13 @@ func (t *Throttler) Throttle(threadID int) time.Duration {
// the provided type, excluding ignored tablets.
func (t *Throttler) MaxLag(tabletType topodata.TabletType) uint32 {
cache := t.maxReplicationLagModule.lagCacheByType(tabletType)

cache.mu.Lock()
defer cache.mu.Unlock()

var maxLag uint32
for key := range cache.entries {
cacheEntries := cache.entries

for key := range cacheEntries {
if cache.isIgnored(key) {
continue
}
Expand Down
46 changes: 24 additions & 22 deletions go/vt/throttler/throttler_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -429,30 +429,32 @@ func TestThrottlerMaxLag(t *testing.T) {
}(ctx, throttler)

go func(ctx context.Context, throttler *Throttler) {
select {
case <-ctx.Done():
return
default:
for _, tabletType := range []topodata.TabletType{
topodata.TabletType_REPLICA,
topodata.TabletType_RDONLY,
} {
cache := throttler.maxReplicationLagModule.lagCacheByType(tabletType)
cache.add(replicationLagRecord{
time: time.Now(),
TabletHealth: discovery.TabletHealth{
Serving: true,
Stats: &query.RealtimeStats{
ReplicationLagSeconds: 5,
},
Tablet: &topodata.Tablet{
Hostname: t.Name(),
PortMap: map[string]int32{
"test": 15999,
for {
select {
case <-ctx.Done():
return
default:
for _, tabletType := range []topodata.TabletType{
topodata.TabletType_REPLICA,
topodata.TabletType_RDONLY,
} {
cache := throttler.maxReplicationLagModule.lagCacheByType(tabletType)
cache.add(replicationLagRecord{
time: time.Now(),
TabletHealth: discovery.TabletHealth{
Serving: true,
Stats: &query.RealtimeStats{
ReplicationLagSeconds: 5,
},
Tablet: &topodata.Tablet{
Hostname: t.Name(),
PortMap: map[string]int32{
"test": 15999,
},
},
},
},
})
})
}
}
}
}(ctx, throttler)
Expand Down

0 comments on commit 396151d

Please sign in to comment.