Skip to content

Commit

Permalink
slack-15.0: support consul topo stale reads (#558)
Browse files Browse the repository at this point in the history
* `slack-15.0`: support consul topo stale reads

Signed-off-by: Tim Vaillancourt <[email protected]>

* update e2e tests

Signed-off-by: Tim Vaillancourt <[email protected]>

---------

Signed-off-by: Tim Vaillancourt <[email protected]>
  • Loading branch information
timvaillancourt authored Nov 15, 2024
1 parent d1c6d4b commit db638ff
Show file tree
Hide file tree
Showing 9 changed files with 15 additions and 2 deletions.
1 change: 1 addition & 0 deletions go/flags/endtoend/vtbackup.txt
Original file line number Diff line number Diff line change
Expand Up @@ -161,6 +161,7 @@ Usage of vtbackup:
--tablet_manager_grpc_key string the key to use to connect
--tablet_manager_grpc_server_name string the server name to use to validate server certificate
--tablet_manager_protocol string Protocol to use to make tabletmanager RPCs to vttablets. (default "grpc")
--topo_consul_allow_stale_reads Allow stale reads from consul servers
--topo_consul_idle_conn_timeout duration Maximum amount of time to pool idle connections. (default 1m30s)
--topo_consul_lock_delay duration LockDelay for consul session. (default 15s)
--topo_consul_lock_session_checks string List of checks for consul session. (default "serfHealth")
Expand Down
1 change: 1 addition & 0 deletions go/flags/endtoend/vtctld.txt
Original file line number Diff line number Diff line change
Expand Up @@ -124,6 +124,7 @@ Usage of vtctld:
--tablet_refresh_interval duration Tablet refresh interval. (default 1m0s)
--tablet_refresh_known_tablets Whether to reload the tablet's address/port map from topo in case they change. (default true)
--tablet_url_template string Format string describing debug tablet url formatting. See getTabletDebugURL() for how to customize this. (default "http://{{.GetTabletHostPort}}")
--topo_consul_allow_stale_reads Allow stale reads from consul servers
--topo_consul_idle_conn_timeout duration Maximum amount of time to pool idle connections. (default 1m30s)
--topo_consul_lock_delay duration LockDelay for consul session. (default 15s)
--topo_consul_lock_session_checks string List of checks for consul session. (default "serfHealth")
Expand Down
1 change: 1 addition & 0 deletions go/flags/endtoend/vtgate.txt
Original file line number Diff line number Diff line change
Expand Up @@ -177,6 +177,7 @@ Usage of vtgate:
--tablet_refresh_known_tablets Whether to reload the tablet's address/port map from topo in case they change. (default true)
--tablet_types_to_wait strings Wait till connected for specified tablet types during Gateway initialization. Should be provided as a comma-separated set of tablet types.
--tablet_url_template string Format string describing debug tablet url formatting. See getTabletDebugURL() for how to customize this. (default "http://{{.GetTabletHostPort}}")
--topo_consul_allow_stale_reads Allow stale reads from consul servers
--topo_consul_idle_conn_timeout duration Maximum amount of time to pool idle connections. (default 1m30s)
--topo_consul_lock_delay duration LockDelay for consul session. (default 15s)
--topo_consul_lock_session_checks string List of checks for consul session. (default "serfHealth")
Expand Down
1 change: 1 addition & 0 deletions go/flags/endtoend/vtgr.txt
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,7 @@ Usage of vtgr:
--tablet_manager_grpc_key string the key to use to connect
--tablet_manager_grpc_server_name string the server name to use to validate server certificate
--tablet_manager_protocol string Protocol to use to make tabletmanager RPCs to vttablets. (default "grpc")
--topo_consul_allow_stale_reads Allow stale reads from consul servers
--topo_consul_idle_conn_timeout duration Maximum amount of time to pool idle connections. (default 1m30s)
--topo_consul_lock_delay duration LockDelay for consul session. (default 15s)
--topo_consul_lock_session_checks string List of checks for consul session. (default "serfHealth")
Expand Down
1 change: 1 addition & 0 deletions go/flags/endtoend/vtorc.txt
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,7 @@ Usage of vtorc:
--tablet_manager_grpc_server_name string the server name to use to validate server certificate
--tablet_manager_protocol string Protocol to use to make tabletmanager RPCs to vttablets. (default "grpc")
--topo-information-refresh-duration duration Timer duration on which VTOrc refreshes the keyspace and vttablet records from the topology server (default 15s)
--topo_consul_allow_stale_reads Allow stale reads from consul servers
--topo_consul_idle_conn_timeout duration Maximum amount of time to pool idle connections. (default 1m30s)
--topo_consul_lock_delay duration LockDelay for consul session. (default 15s)
--topo_consul_lock_session_checks string List of checks for consul session. (default "serfHealth")
Expand Down
1 change: 1 addition & 0 deletions go/flags/endtoend/vttablet.txt
Original file line number Diff line number Diff line change
Expand Up @@ -316,6 +316,7 @@ Usage of vttablet:
--throttle_metrics_threshold float Override default throttle threshold, respective to -throttle_metrics_query (default 1.7976931348623157e+308)
--throttle_tablet_types string Comma separated VTTablet types to be considered by the throttler. default: 'replica'. example: 'replica,rdonly'. 'replica' aways implicitly included (default "replica")
--throttle_threshold duration Replication lag threshold for default lag throttling (default 1s)
--topo_consul_allow_stale_reads Allow stale reads from consul servers
--topo_consul_idle_conn_timeout duration Maximum amount of time to pool idle connections. (default 1m30s)
--topo_consul_lock_delay duration LockDelay for consul session. (default 15s)
--topo_consul_lock_session_checks string List of checks for consul session. (default "serfHealth")
Expand Down
1 change: 1 addition & 0 deletions go/flags/endtoend/vttestserver.txt
Original file line number Diff line number Diff line change
Expand Up @@ -118,6 +118,7 @@ Usage of vttestserver:
--tablet_manager_grpc_key string the key to use to connect
--tablet_manager_grpc_server_name string the server name to use to validate server certificate
--tablet_manager_protocol string Protocol to use to make tabletmanager RPCs to vttablets. (default "grpc")
--topo_consul_allow_stale_reads Allow stale reads from consul servers
--topo_consul_idle_conn_timeout duration Maximum amount of time to pool idle connections. (default 1m30s)
--topo_consul_lock_delay duration LockDelay for consul session. (default 15s)
--topo_consul_lock_session_checks string List of checks for consul session. (default "serfHealth")
Expand Down
8 changes: 6 additions & 2 deletions go/vt/topo/consultopo/file.go
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,9 @@ func (s *Server) Update(ctx context.Context, filePath string, contents []byte, v
func (s *Server) Get(ctx context.Context, filePath string) ([]byte, topo.Version, error) {
nodePath := path.Join(s.root, filePath)

pair, _, err := s.kv.Get(nodePath, nil)
pair, _, err := s.kv.Get(nodePath, &api.QueryOptions{
AllowStale: consulAllowStaleReads,
})
if err != nil {
return nil, nil, err
}
Expand All @@ -102,7 +104,9 @@ func (s *Server) Get(ctx context.Context, filePath string) ([]byte, topo.Version
func (s *Server) List(ctx context.Context, filePathPrefix string) ([]topo.KVInfo, error) {
nodePathPrefix := path.Join(s.root, filePathPrefix)

pairs, _, err := s.kv.List(nodePathPrefix, nil)
pairs, _, err := s.kv.List(nodePathPrefix, &api.QueryOptions{
AllowStale: consulAllowStaleReads,
})
if err != nil {
return []topo.KVInfo{}, err
}
Expand Down
2 changes: 2 additions & 0 deletions go/vt/topo/consultopo/server.go
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@ var (
consulMaxConnsPerHost int = 250 // do not use client default of 0/unlimited
consulMaxIdleConns int
consulIdleConnTimeout time.Duration
consulAllowStaleReads bool
)

func init() {
Expand All @@ -65,6 +66,7 @@ func registerServerFlags(fs *pflag.FlagSet) {
fs.IntVar(&consulMaxConnsPerHost, "topo_consul_max_conns_per_host", consulMaxConnsPerHost, "Maximum number of consul connections per host.")
fs.IntVar(&consulMaxIdleConns, "topo_consul_max_idle_conns", defaultConsulPooledTransport.MaxIdleConns, "Maximum number of idle consul connections.")
fs.DurationVar(&consulIdleConnTimeout, "topo_consul_idle_conn_timeout", defaultConsulPooledTransport.IdleConnTimeout, "Maximum amount of time to pool idle connections.")
fs.BoolVar(&consulAllowStaleReads, "topo_consul_allow_stale_reads", consulAllowStaleReads, "Allow stale reads from consul servers")
}

// ClientAuthCred credential to use for consul clusters
Expand Down

0 comments on commit db638ff

Please sign in to comment.