diff --git a/go/flags/endtoend/vtbackup.txt b/go/flags/endtoend/vtbackup.txt index 25730ab892f..e11f8e5c745 100644 --- a/go/flags/endtoend/vtbackup.txt +++ b/go/flags/endtoend/vtbackup.txt @@ -221,6 +221,7 @@ Flags: --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") diff --git a/go/flags/endtoend/vtcombo.txt b/go/flags/endtoend/vtcombo.txt index 126b073c6b5..bf15065a1cc 100644 --- a/go/flags/endtoend/vtcombo.txt +++ b/go/flags/endtoend/vtcombo.txt @@ -365,6 +365,7 @@ Flags: --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}}" }}") --throttle_tablet_types string Comma separated VTTablet types to be considered by the throttler. default: 'replica'. example: 'replica,rdonly'. 'replica' always implicitly included (default "replica") + --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") diff --git a/go/flags/endtoend/vtctld.txt b/go/flags/endtoend/vtctld.txt index 325c4ae30cd..ddbcb397025 100644 --- a/go/flags/endtoend/vtctld.txt +++ b/go/flags/endtoend/vtctld.txt @@ -155,6 +155,7 @@ Flags: --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") diff --git a/go/flags/endtoend/vtgate.txt b/go/flags/endtoend/vtgate.txt index 07353a0beaa..dc98cb0e0ac 100644 --- a/go/flags/endtoend/vtgate.txt +++ b/go/flags/endtoend/vtgate.txt @@ -213,6 +213,7 @@ Flags: --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") diff --git a/go/flags/endtoend/vtorc.txt b/go/flags/endtoend/vtorc.txt index e36c35924b1..876768ed667 100644 --- a/go/flags/endtoend/vtorc.txt +++ b/go/flags/endtoend/vtorc.txt @@ -93,6 +93,7 @@ Flags: --tablet_manager_protocol string Protocol to use to make tabletmanager RPCs to vttablets. (default "grpc") --tolerable-replication-lag duration Amount of replication lag that is considered acceptable for a tablet to be eligible for promotion when Vitess makes the choice of a new primary in PRS --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") diff --git a/go/flags/endtoend/vttablet.txt b/go/flags/endtoend/vttablet.txt index 502b81f1f6a..4537ac36d92 100644 --- a/go/flags/endtoend/vttablet.txt +++ b/go/flags/endtoend/vttablet.txt @@ -367,6 +367,7 @@ Flags: --tablet_manager_protocol string Protocol to use to make tabletmanager RPCs to vttablets. (default "grpc") --tablet_protocol string Protocol to use to make queryservice RPCs to vttablets. (default "grpc") --throttle_tablet_types string Comma separated VTTablet types to be considered by the throttler. default: 'replica'. example: 'replica,rdonly'. 'replica' always implicitly included (default "replica") + --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") diff --git a/go/flags/endtoend/vttestserver.txt b/go/flags/endtoend/vttestserver.txt index 205cd8aee3d..d63229392f1 100644 --- a/go/flags/endtoend/vttestserver.txt +++ b/go/flags/endtoend/vttestserver.txt @@ -137,6 +137,7 @@ Flags: --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") --tablet_refresh_interval duration Interval at which vtgate refreshes tablet information from topology server. (default 10s) + --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") diff --git a/go/vt/topo/consultopo/file.go b/go/vt/topo/consultopo/file.go index 2c08a675a79..e9d8dfbccd1 100644 --- a/go/vt/topo/consultopo/file.go +++ b/go/vt/topo/consultopo/file.go @@ -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 } @@ -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 } diff --git a/go/vt/topo/consultopo/server.go b/go/vt/topo/consultopo/server.go index 0a059b12f65..08da24cc6fe 100644 --- a/go/vt/topo/consultopo/server.go +++ b/go/vt/topo/consultopo/server.go @@ -45,6 +45,7 @@ var ( consulMaxConnsPerHost int = 250 // do not use client default of 0/unlimited consulMaxIdleConns int consulIdleConnTimeout time.Duration + consulAllowStaleReads bool ) func init() { @@ -64,6 +65,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