Skip to content

Commit 19c46c3

Browse files
committed
Document the metastore read replica and test read-only resolution
- Document `metastore_read_replica_uri` in the node config reference and the example `quickwit.yaml`. - Add a PostgreSQL-gated test that resolves a read-only metastore against a real database and verifies it serves read RPCs.
1 parent c782895 commit 19c46c3

3 files changed

Lines changed: 35 additions & 0 deletions

File tree

config/quickwit.yaml

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -103,6 +103,13 @@ version: 0.8
103103
# metastore_uri: s3://your-bucket/indexes
104104
# metastore_uri: postgres://username:password@host:port/db
105105
#
106+
# Optional PostgreSQL read replica URI. Nodes started with the
107+
# `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). When
109+
# unset, those requests are served by the primary metastore. Defaults to unset.
110+
#
111+
# metastore_read_replica_uri: postgres://username:password@read-replica-host:port/db
112+
#
106113
# When using a file-backed metastore, the state of the metastore will be cached forever.
107114
# If you are indexing and searching from different processes, it is possible to periodically
108115
# refresh the state of the metastore on the searcher using the `polling_interval` hashtag.

docs/configuration/node-config.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@ A commented example is available here: [quickwit.yaml](https://github.com/quickw
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). | `QW_METASTORE_READ_REPLICA_URI` | |
3334
| `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` |
3435
| 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` |
3536

quickwit/quickwit-metastore/src/metastore_resolver.rs

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -240,4 +240,31 @@ mod tests {
240240
metastore_resolver.resolve(&postgres_uri).await.unwrap();
241241
}
242242
}
243+
244+
#[cfg(feature = "postgres")]
245+
#[tokio::test]
246+
async fn test_metastore_resolver_resolve_read_only_postgres() {
247+
use std::env;
248+
249+
use quickwit_proto::metastore::{ListIndexesMetadataRequest, MetastoreService};
250+
251+
let metastore_resolver = MetastoreResolver::unconfigured();
252+
let test_database_url = env::var("QW_TEST_DATABASE_URL").unwrap_or_else(|_| {
253+
"postgres://quickwit-dev:quickwit-dev@localhost/quickwit-metastore-dev".to_string()
254+
});
255+
let postgres_uri = Uri::from_str(&test_database_url).unwrap();
256+
// The read replica skips migrations, so ensure the schema exists by resolving the
257+
// read-write metastore first.
258+
metastore_resolver.resolve(&postgres_uri).await.unwrap();
259+
260+
let read_only_metastore = metastore_resolver
261+
.resolve_read_only(&postgres_uri)
262+
.await
263+
.unwrap();
264+
// A read-only connection must still serve read RPCs.
265+
read_only_metastore
266+
.list_indexes_metadata(ListIndexesMetadataRequest::all())
267+
.await
268+
.unwrap();
269+
}
243270
}

0 commit comments

Comments
 (0)