Skip to content

Commit

Permalink
add a check that the refresh <= the ttl duration
Browse files Browse the repository at this point in the history
The logic depends on the refresh being smaller than or equal to the
TTL so add a startup assertion that it is configured that way.

Also update all test cases that override the ttl to also override
the refresh interval to avoid hitting this assertion.
  • Loading branch information
demmer committed Feb 5, 2018
1 parent d115d46 commit 7389692
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 1 deletion.
3 changes: 2 additions & 1 deletion go/vt/discovery/tablet_stats_cache_wait_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,8 @@ func (a TargetArray) Less(i, j int) bool {
func TestFindAllKeyspaceShards(t *testing.T) {
ctx := context.Background()
ts := memorytopo.NewServer("cell1", "cell2")
flag.Set("srv_topo_cache_ttl", "0s") // No caching values
flag.Set("srv_topo_cache_ttl", "0s") // No caching values
flag.Set("srv_topo_cache_refresh", "0s") // No caching values
rs := srvtopo.NewResilientServer(ts, "TestFindAllKeyspaceShards")

// No keyspace / shards.
Expand Down
4 changes: 4 additions & 0 deletions go/vt/srvtopo/resilient_server.go
Original file line number Diff line number Diff line change
Expand Up @@ -164,6 +164,10 @@ type srvKeyspaceEntry struct {
// NewResilientServer creates a new ResilientServer
// based on the provided topo.Server.
func NewResilientServer(base *topo.Server, counterPrefix string) *ResilientServer {
if *srvTopoCacheRefresh > *srvTopoCacheTTL {
log.Fatalf("srv_topo_cache_refresh must be less than or equal to srv_topo_cache_ttl")
}

return &ResilientServer{
topoServer: base,
cacheTTL: *srvTopoCacheTTL,
Expand Down
2 changes: 2 additions & 0 deletions test/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -550,6 +550,7 @@ def start(self, cell='test_nj', retry_count=2,
'-retry-count', str(retry_count),
'-log_dir', environment.vtlogroot,
'-srv_topo_cache_ttl', cache_ttl,
'-srv_topo_cache_refresh', cache_ttl,
'-tablet_protocol', protocols_flavor().tabletconn_protocol(),
'-stderrthreshold', get_log_level(),
'-normalize_queries',
Expand Down Expand Up @@ -799,6 +800,7 @@ def start(self, cell='test_nj', retry_count=2,
'-retry-count', str(retry_count),
'-log_dir', environment.vtlogroot,
'-srv_topo_cache_ttl', cache_ttl,
'-srv_topo_cache_refresh', cache_ttl,
'-tablet_protocol', protocols_flavor().tabletconn_protocol(),
'-gateway_implementation', vtgate_gateway_flavor().flavor(),
]
Expand Down

0 comments on commit 7389692

Please sign in to comment.