Add MySQL metastore backend#6199
Draft
saliagadotcom wants to merge 7 commits intoquickwit-oss:mainfrom
Draft
Conversation
Amp-Thread-ID: https://ampcode.com/threads/T-019cde82-1c12-7582-ae61-2ecbd862be03 Co-authored-by: Amp <amp@ampcode.com> Co-authored-by: Cursor <cursoragent@cursor.com> Ai-assisted: true
Co-authored-by: Cursor <cursoragent@cursor.com> Ai-assisted: true
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Add MySQL metastore backend
Description
Adds MySQL as a new production-grade metastore backend for Quickwit, enabling deployments that prefer MySQL over PostgreSQL for storing index metadata, splits, shards, delete tasks, and index templates.
The existing metastore has two backends: file-backed (dev) and PostgreSQL (production). This PR introduces a third: MySQL, following the same architecture and feature surface as the PostgreSQL backend.
MySQL metastore modules
The MySQL metastore lives in
quickwit-metastore/src/metastore/mysql/and mirrors the PostgreSQL metastore module-for-module:metastore.rsMetastoreServicetrait implementation (~2,158 lines) covering all 30+ metastore operations: index CRUD, split staging/publishing/deletion, shard open/acquire/prune, delete tasks, and index templates.model.rsMysqlIndex,MysqlSplit,MysqlShard,MysqlDeleteTask,MysqlIndexTemplate) for SQLx row deserialization.factory.rsMysqlMetastoreFactory— URI-based factory that creates aMysqlMetastorefrom amysql://connection string.pool.rsTrackedPool<MySql>— connection pool wrapper with metrics tracking for active/idle connections.migrator.rsQW_MYSQL_SKIP_MIGRATION_LOCKING).error.rsMetastoreErrorconversion, mapping MySQL error codes to domain errors.tags.rssea_query.utils.rssplit_stream.rsSTREAM_SPLITS_CHUNK_SIZE).metrics.rsauth.rsqueries/ON DUPLICATE KEY UPDATE).Protocol & type layer changes (
quickwit-common,quickwit-proto)Protocol::MySQLvariant withmysql://URI parsingmysql://user:pass@host:3306/dbmetastore URIs with credential redaction in logs.is_database()now coversProtocol::MySQLjoin()andparent()on database URIs.sqlx::Type<MySql>+sqlx::Encode<MySql>forIndexUid,DocMappingUid,ShardId#[cfg(feature = "postgres")]→#[cfg(any(feature = "postgres", feature = "mysql"))]sea_query::Valueconversions andTryFrom<String>impls are needed by both backends.Configuration (
quickwit-config)MetastoreBackend::MySQLenum variantmetastore_backend: mysqlin config files.MetastoreConfig::MySQL(MysqlMetastoreConfig)min_connections,max_connections,acquire_timeout,idle_timeout,max_lifetime).MysqlAuthModeenum (Password,AwsIam)Schema (
migrations/mysql/)1_initial-schema.up.sqlcreates six tables adapted for MySQL's DDL dialect:indexes— index metadata withindex_metadata_jsoncolumn (TEXT)splits— split lifecycle management withBIGINTtimestamps,split_metadata_json(TEXT), andJSONtag columnsshards— shard state tracking withpublish_position_inclusive(VARCHAR(255))delete_tasks— delete query queue withdelete_query_json(TEXT)index_templates— index template storage withindex_template_json(TEXT) and priority-based matchingkv— key-value metadata storageResolver & feature gating
MysqlMetastoreFactoryregistered inMetastoreResolverbehind#[cfg(feature = "mysql")]UnsupportedMetastorefallback when compiled without the feature (matches Postgres pattern)mysqlfeature added toquickwit-metastore,quickwit-proto, andquickwit-cliCargo.tomlDocker & testing infrastructure
docker-compose.ymlwith health checks.env.exampleupdated withQW_MYSQL_*connection variablesHow was this tested?
mysql://protocol including credential redactionmysqlfeatureCouldn't find any contribution rules about LLM usage but warning for substantial LLM usage in this PR!