Skip to content

Commit a193ad0

Browse files
committed
Add searcher metastore read replica setting
1 parent e699180 commit a193ad0

8 files changed

Lines changed: 25 additions & 9 deletions

File tree

config/quickwit.yaml

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -105,10 +105,8 @@ version: 0.8
105105
#
106106
# Optional PostgreSQL read replica URI. Nodes started with the
107107
# `metastore_read_replica` service connect to it over a read-only connection and
108-
# serve stale-tolerant read-only metastore requests (e.g. from searchers).
109-
# When set, nodes that issue stale-tolerant read-only metastore requests require
110-
# a `metastore_read_replica` node at startup and do not fall back to the primary
111-
# metastore. Defaults to unset.
108+
# serve stale-tolerant read-only metastore requests. Searchers use those nodes
109+
# only when `searcher.use_metastore_read_replica` is enabled. Defaults to unset.
112110
#
113111
# metastore_read_replica_uri: postgres://username:password@read-replica-host:port/db
114112
#
@@ -177,6 +175,11 @@ indexer:
177175
# https://quickwit.io/docs/configuration/node-config#searcher-configuration
178176
#
179177
# searcher:
178+
# # If true, routes read-only metastore requests from searchers, including
179+
# # DataFusion when enabled, to nodes running the `metastore_read_replica`
180+
# # service. Searchers require at least one `metastore_read_replica` node at
181+
# # startup and do not fall back to the primary metastore.
182+
# use_metastore_read_replica: false
180183
# fast_field_cache_capacity: 1G
181184
# split_footer_cache_capacity: 500M
182185
# partial_request_cache_capacity: 64M

docs/configuration/node-config.md

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,15 +22,15 @@ A commented example is available here: [quickwit.yaml](https://github.com/quickw
2222
| `version` | Config file version. `0.7` is the only available value with a retro compatibility on `0.5` and `0.4`. | | |
2323
| `cluster_id` | Unique identifier of the cluster the node will be joining. Clusters sharing the same network should use distinct cluster IDs.| `QW_CLUSTER_ID` | `quickwit-default-cluster` |
2424
| `node_id` | Unique identifier of the node. It must be distinct from the node IDs of its cluster peers. Defaults to the instance's short hostname if not set. | `QW_NODE_ID` | short hostname |
25-
| `enabled_services` | Enabled services (control_plane, indexer, janitor, metastore, searcher) | `QW_ENABLED_SERVICES` | all services |
25+
| `enabled_services` | Enabled services (control_plane, indexer, janitor, metastore, metastore_read_replica, searcher) | `QW_ENABLED_SERVICES` | all services except metastore_read_replica |
2626
| `listen_address` | The IP address or hostname that Quickwit service binds to for starting REST and GRPC server and connecting this node to other nodes. By default, Quickwit binds itself to 127.0.0.1 (localhost). This default is not valid when trying to form a cluster. | `QW_LISTEN_ADDRESS` | `127.0.0.1` |
2727
| `advertise_address` | IP address advertised by the node, i.e. the IP address that peer nodes should use to connect to the node for RPCs. | `QW_ADVERTISE_ADDRESS` | `listen_address` |
2828
| `gossip_listen_port` | The port which to listen for the Gossip cluster membership service (UDP). | `QW_GOSSIP_LISTEN_PORT` | `rest.listen_port` |
2929
| `grpc_listen_port` | The port on which gRPC services listen for traffic. | `QW_GRPC_LISTEN_PORT` | `rest.listen_port + 1` |
3030
| `peer_seeds` | List of IP addresses or hostnames used to bootstrap the cluster and discover the complete set of nodes. This list may contain the current node address and does not need to be exhaustive. If the list of peer seeds contains a host name, Quickwit will resolve it by querying the DNS every minute. On kubernetes for instance, it is a good practise to set it to a [headless service](https://kubernetes.io/docs/concepts/services-networking/service/#headless-services). | `QW_PEER_SEEDS` | |
3131
| `data_dir` | Path to directory where data (tmp data, splits kept for caching purpose) is persisted. This is mostly used in indexing. | `QW_DATA_DIR` | `./qwdata` |
3232
| `metastore_uri` | Metastore URI. Can be a local directory or `s3://my-bucket/indexes` or `postgres://username:password@localhost:5432/metastore`. [Learn more about the metastore configuration](metastore-config.md). | `QW_METASTORE_URI` | `{data_dir}/indexes` |
33-
| `metastore_read_replica_uri` | Optional PostgreSQL read replica URI. Nodes running the `metastore_read_replica` service connect to it over a read-only connection and serve stale-tolerant read-only metastore requests (e.g. from searchers). When set, nodes that issue those requests require a `metastore_read_replica` node at startup and do not fall back to the primary metastore. | `QW_METASTORE_READ_REPLICA_URI` | |
33+
| `metastore_read_replica_uri` | Optional PostgreSQL read replica URI. Nodes running the `metastore_read_replica` service connect to it over a read-only connection and serve stale-tolerant read-only metastore requests. Searchers use those nodes only when `searcher.use_metastore_read_replica` is enabled. | `QW_METASTORE_READ_REPLICA_URI` | |
3434
| `default_index_root_uri` | Default index root URI that defines the location where index data (splits) is stored. The index URI is built following the scheme: `{default_index_root_uri}/{index-id}` | `QW_DEFAULT_INDEX_ROOT_URI` | `{data_dir}/indexes` |
3535
| environment variable only | Log level of Quickwit. Can be a direct log level, or a comma separated list of `module_name=level` | `RUST_LOG` | `info` |
3636

@@ -286,6 +286,7 @@ This section contains the configuration options for a Searcher.
286286
| `max_num_concurrent_split_searches` | Maximum number of concurrent split search requests running on a Searcher. | `100` |
287287
| `split_cache` | Searcher split cache configuration options defined in the section below. Cache disabled if unspecified. | |
288288
| `request_timeout_secs` | The time before a search request is cancelled. This should match the timeout of the stack calling into quickwit if there is one set. | `30` |
289+
| `use_metastore_read_replica` | If true, routes read-only metastore requests from searchers, including DataFusion when enabled, to nodes running the `metastore_read_replica` service. Searchers require at least one `metastore_read_replica` node at startup and do not fall back to the primary metastore. | `false` |
289290

290291
### Searcher split cache configuration
291292

@@ -302,6 +303,7 @@ Example:
302303

303304
```yaml
304305
searcher:
306+
use_metastore_read_replica: false
305307
fast_field_cache_capacity: 1G
306308
split_footer_cache_capacity: 500M
307309
partial_request_cache_capacity: 64M

quickwit/quickwit-config/resources/tests/node_config/quickwit.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -65,6 +65,7 @@
6565
"replication_factor": 2
6666
},
6767
"searcher": {
68+
"use_metastore_read_replica": true,
6869
"aggregation_memory_limit": "1G",
6970
"aggregation_bucket_limit": 500000,
7071
"fast_field_cache_capacity": "10G",

quickwit/quickwit-config/resources/tests/node_config/quickwit.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,7 @@ parquet_merge_use_streaming_engine = true
5555
replication_factor = 2
5656

5757
[searcher]
58+
use_metastore_read_replica = true
5859
aggregation_memory_limit = "1G"
5960
aggregation_bucket_limit = 500_000
6061
fast_field_cache_capacity = "10G"

quickwit/quickwit-config/resources/tests/node_config/quickwit.yaml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,7 @@ ingest_api:
5959
replication_factor: 2
6060

6161
searcher:
62+
use_metastore_read_replica: true
6263
aggregation_memory_limit: 1G
6364
aggregation_bucket_limit: 500000
6465
fast_field_cache_capacity: 10G

quickwit/quickwit-config/src/node_config/mod.rs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -343,6 +343,9 @@ pub struct SearcherConfig {
343343
#[serde(default)]
344344
#[serde(skip_serializing_if = "Option::is_none")]
345345
pub storage_timeout_policy: Option<StorageTimeoutPolicy>,
346+
/// Routes read-only metastore requests from searchers, including DataFusion when enabled, to
347+
/// nodes running the `metastore_read_replica` service.
348+
pub use_metastore_read_replica: bool,
346349
pub warmup_memory_budget: ByteSize,
347350
pub warmup_single_split_initial_allocation: ByteSize,
348351
/// Lambda configuration for serverless leaf search execution.
@@ -566,6 +569,7 @@ impl Default for SearcherConfig {
566569
request_timeout_secs: Self::default_request_timeout_secs(),
567570
leaf_request_timeout_secs: Self::default_request_timeout_secs(),
568571
storage_timeout_policy: None,
572+
use_metastore_read_replica: false,
569573
warmup_memory_budget: ByteSize::gb(100),
570574
warmup_single_split_initial_allocation: ByteSize::mb(300),
571575
lambda: None,

quickwit/quickwit-config/src/node_config/serialize.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -794,6 +794,7 @@ mod tests {
794794
timeout_millis: 2_000,
795795
max_num_retries: 2
796796
}),
797+
use_metastore_read_replica: true,
797798
warmup_memory_budget: ByteSize::gb(100),
798799
warmup_single_split_initial_allocation: ByteSize::mb(300),
799800
lambda: Some(LambdaConfig {

quickwit/quickwit-serve/src/lib.rs

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -728,10 +728,13 @@ pub async fn serve_quickwit(
728728
};
729729

730730
// Searchers and the DataFusion analytics path use the primary metastore by default. When
731-
// `metastore_read_replica_uri` is configured, they require `metastore_read_replica` nodes and
732-
// do not fall back to the primary if none are available.
731+
// `searcher.use_metastore_read_replica` is enabled, searcher nodes require
732+
// `metastore_read_replica` nodes and do not fall back to the primary if none are available.
733+
let use_metastore_read_replica_for_search = node_config
734+
.is_service_enabled(QuickwitService::Searcher)
735+
&& node_config.searcher_config.use_metastore_read_replica;
733736
let search_metastore_client: MetastoreReadServiceClient =
734-
if node_config.metastore_read_replica_uri.is_some() {
737+
if use_metastore_read_replica_for_search {
735738
let read_replica_metastore = build_metastore_client(
736739
&cluster,
737740
QuickwitService::MetastoreReadReplica,

0 commit comments

Comments
 (0)