Administrative Commands
These TCP commands inspect configuration, manage dumps and replication, rebuild tables and posting lists, and control the query cache. They use the same connection and framing as the query commands in the Protocol Reference. When api.admin_token is configured, each one requires a successful AUTH on the same connection first and otherwise returns ERROR 7 Administrative command requires AUTH. When the token is empty, the gate is disabled and every command is allowed.
| Command | What it does | Section |
|---|---|---|
CONFIG HELP, CONFIG SHOW, CONFIG VERIFY | Show configuration help and current values, and validate a candidate file | CONFIG |
DUMP SAVE, DUMP LOAD, DUMP VERIFY, DUMP INFO, DUMP STATUS | Save, load, verify, and inspect dump files, and monitor dump progress | DUMP |
REPLICATION STATUS | Report binlog replication state | REPLICATION STATUS |
REPLICATION STOP | Stop binlog replication | REPLICATION STOP |
REPLICATION START | Resume binlog replication | REPLICATION START |
SYNC <table>, SYNC STOP | Rebuild a table from a MySQL snapshot, or cancel a running sync | SYNC |
SYNC STATUS | Report SYNC progress and results | SYNC STATUS |
OPTIMIZE | Rebuild posting lists | OPTIMIZE |
DEBUG ON, DEBUG OFF | Toggle query metrics for the current connection | DEBUG |
CACHE STATS, CACHE CLEAR, CACHE ENABLE, CACHE DISABLE | Inspect and control the query cache | CACHE |
SET, SHOW VARIABLES | Change and list runtime variables | SET and SHOW VARIABLES |
CONFIG Commands
The CONFIG command family provides runtime configuration help, inspection, and verification.
CONFIG is for inspection
CONFIG SHOW and CONFIG VERIFY inspect and validate configuration. To change a value on a running server, use SET / SHOW VARIABLES, which are limited to the mutable runtime variables.
CONFIG HELP [path]
Display help for configuration options.
Syntax:
CONFIG HELP [path]Parameters:
| Parameter | Required | Description |
|---|---|---|
path | No | Dot-separated configuration path (e.g., mysql.port) |
Examples:
List the top-level configuration sections:
CONFIG HELPResponse (sections are sorted by name; the mysql description is shortened here):
+OK
Available configuration sections:
api - API server configuration
bm25 - BM25 relevance scoring configuration
build - Index build configuration
cache - Query cache configuration
dump - Dump persistence configuration
index - Legacy global index configuration (deprecated; prefer per-table ngram_size)
logging - Logging configuration
memory - Memory management configuration
mysql - MySQL connection settings. Values can be overridden via environment variables: ...
network - Network security configuration
replication - Replication configuration
server - Legacy server configuration (deprecated, use api.tcp instead)
tables - Table configuration (supports multiple tables)
Use "CONFIG HELP <section>" for detailed information.Show help for a section:
CONFIG HELP mysqlResponse:
+OK
mysql
Type: object
Description: MySQL connection settings. Values can be overridden via environment variables: MYGRAM_MYSQL_USER, MYGRAM_MYSQL_PASSWORD, MYGRAM_MYSQL_HOST, MYGRAM_MYSQL_PORT, MYGRAM_MYSQL_DATABASE (env vars take precedence over config file values)A section prints only its type and description. Ask for a property path to see its default and allowed range:
CONFIG HELP mysql.portResponse:
+OK
mysql.port
Type: integer
Default: 3306
Range: 1 - 65535
Description: MySQL server portThe output text comes from the configuration schema and is always in English. An unknown path returns ERROR 8 Configuration path not found: <path>.
CONFIG SHOW [path]
Display current configuration values. Sensitive fields (passwords, secrets) are masked with ***.
Syntax:
CONFIG SHOW [path]Parameters:
| Parameter | Required | Description |
|---|---|---|
path | No | Dot-separated configuration path to show only specific section |
Examples:
Show entire current configuration:
CONFIG SHOWResponse:
+OK
mysql:
host: "127.0.0.1"
port: 3306
user: "repl_user"
password: "***"
database: "mydb"
use_gtid: true
...
tables:
- name: "articles"
primary_key: "id"
...
replication:
enable: true
server_id: 12345
...Show specific section:
CONFIG SHOW mysqlShow specific property:
CONFIG SHOW mysql.portResponse:
+OK
3306CONFIG VERIFY <filepath>
Verify a configuration file without loading it.
Syntax:
CONFIG VERIFY <filepath>Parameters:
| Parameter | Required | Description |
|---|---|---|
filepath | Yes | Path to a .yaml or .yml configuration file, relative to the directory containing the active configuration file |
The server rejects absolute paths, paths containing .., symbolic links, and files with any other extension, so CONFIG VERIFY can only read candidate files placed next to the active configuration.
Examples:
Verify a valid file:
CONFIG VERIFY candidate.yamlResponse (success). The summary shows only the MySQL host and port; the user name and password are never printed:
+OK
Configuration is valid
Tables: 2 (articles, products)
MySQL: 127.0.0.1:3306Verify an invalid file:
CONFIG VERIFY invalid.yamlResponse (error). Like every error, it is a single ERROR <code> line; line breaks inside the validation message are replaced with spaces:
ERROR 1002 Configuration validation failed: <validation message>On a MySQL-enabled build, CONFIG VERIFY also converts each required filter's configured value to its declared column type, without connecting to MySQL. A value that cannot be converted is rejected with ERROR 1004 Configuration validation failed: Table '<database>.<table>': <filter error>.
DUMP Commands
The DUMP command family provides unified snapshot management with integrity verification.
DUMP LOAD replaces current data
DUMP SAVE writes, DUMP VERIFY checks, and DUMP INFO reports. DUMP LOAD is different: it replaces the current index and document store with the dump's contents. Confirm the target file and its GTID before running it.
DUMP SAVE
Save complete snapshot to single binary file (.dmp). This command runs asynchronously and returns immediately.
Syntax:
DUMP SAVE [<filepath>]Response:
OK DUMP_STARTED <filepath>Example:
DUMP SAVE mygramdb.dmpThe filename resolves under dump.dir; a path outside that directory is refused. Use DUMP STATUS to monitor progress and check completion.
mygram-cli reads the filepath as the last non-empty token, decoded with the server escape rules, so quote a path that contains spaces. A token starting with - is sent to the server, which rejects it as an unknown DUMP SAVE flag. --with-stats is not part of the grammar and is rejected the same way.
DUMP SAVE requires every configured table to have completed its initial load; until then it returns ERROR 6029 Cannot save dump before every table has completed its initial load. Please wait for SYNC to complete. It also requires a GTID position, else ERROR 6029 Cannot save dump without GTID position. Please run SYNC command first to establish initial position. While any SYNC is in flight, including an attempt of the automatic initial load, it returns ERROR 4011.
DUMP LOAD
Load snapshot from binary file.
This replaces the live search state
DUMP LOAD replaces the current index and document store. Run DUMP VERIFY and DUMP INFO first to check for corruption and to confirm the GTID and table identities.
Syntax:
DUMP LOAD <filepath>Example:
DUMP LOAD mygramdb.dmpDUMP VERIFY
Verify snapshot file integrity without loading data.
Syntax:
DUMP VERIFY <filepath>Example:
DUMP VERIFY mygramdb.dmpDUMP INFO
Display snapshot file metadata (version, GTID, tables, size, flags).
Syntax:
DUMP INFO <filepath>Example:
DUMP INFO mygramdb.dmpDUMP STATUS
Monitor the progress of async dump operations (DUMP SAVE).
Syntax:
DUMP STATUSResponse:
OK DUMP_STATUS
save_in_progress: <true|false>
load_in_progress: <true|false>
replication_paused_for_dump: <true|false>
status: <IDLE|SAVING|LOADING|COMPLETED|FAILED>
filepath: <path>
tables_processed: <count>
tables_total: <count>
current_table: <table_name>
elapsed_seconds: <seconds>
result_filepath: <path> (when COMPLETED)
error: <message> (when FAILED)
ENDStatus values:
| Value | Meaning |
|---|---|
IDLE | No dump operation in progress |
SAVING | DUMP SAVE in progress |
LOADING | DUMP LOAD in progress |
COMPLETED | The last dump operation completed successfully |
FAILED | The last dump operation failed |
Example (during save):
OK DUMP_STATUS
save_in_progress: true
load_in_progress: false
replication_paused_for_dump: true
status: SAVING
filepath: /backup/mygramdb.dmp
tables_processed: 2
tables_total: 5
current_table: users
elapsed_seconds: 3.45
ENDFor detailed snapshot management, integrity protection, best practices, and troubleshooting, see Snapshot Guide.
REPLICATION STATUS
Get current replication status.
Syntax
REPLICATION STATUSResponse
Multi-line key-value format:
OK REPLICATION
status: <running|stopped|failed|not_configured>
current_gtid: <current_gtid>
processed_events: <count>
queue_size: <size>
crc_errors: <count>
schema_incompatible: <true|false>
last_error_code: <code>
last_error: <message>
last_applied_unixtime: <unix_timestamp>
seconds_since_last_applied: <seconds>
END| Field | Description |
|---|---|
status | Replication state (values below) |
current_gtid | Last processed GTID position |
processed_events | Total binlog events processed |
queue_size | Pending events in the queue; returned in every state of a configured reader, including stopped and failed |
crc_errors | Total binlog event CRC errors detected |
schema_incompatible | true when replication stopped because a monitored schema is incompatible |
last_error_code | Numeric code of the last replication error, or 0 when there is none |
last_error | Message of the last replication error, or empty when there is none |
last_applied_unixtime | Unix timestamp of the last successfully applied position, or 0 when unknown |
seconds_since_last_applied | Seconds since the last successfully applied position, or -1 when unknown |
status is one of the following. not_configured is returned when no binlog reader is configured; the other three apply when one is.
| Value | Meaning |
|---|---|
running | Actively replicating from MySQL |
stopped | Replication was stopped manually |
failed | Replication stopped because of an error |
not_configured | MySQL replication is not configured |
Example (running):
OK REPLICATION
status: running
current_gtid: 3E11FA47-71CA-11E1-9E33-C80AA9429562:1-100
processed_events: 5000
queue_size: 0
crc_errors: 0
schema_incompatible: false
last_error_code: 0
last_error:
last_applied_unixtime: 1710000000
seconds_since_last_applied: 2
ENDExample (stopped):
OK REPLICATION
status: stopped
current_gtid: 3E11FA47-71CA-11E1-9E33-C80AA9429562:1-100
processed_events: 5000
queue_size: 0
crc_errors: 0
schema_incompatible: false
last_error_code: 0
last_error:
last_applied_unixtime: 1710000000
seconds_since_last_applied: 120
ENDREPLICATION STOP
Stop binlog replication (index becomes read-only).
No MySQL changes are applied while stopped
Search keeps working during REPLICATION STOP, but new MySQL changes are not reflected. After maintenance, run REPLICATION START and confirm with REPLICATION STATUS.
Syntax
REPLICATION STOPResponse
OK REPLICATION_STOPPEDREPLICATION START
Resume binlog replication.
Syntax
REPLICATION STARTResponse
OK REPLICATION_STARTEDSYNC
Manually trigger snapshot synchronization from MySQL to MygramDB for a specific table. The SYNC Command Guide covers the full lifecycle; this section is the command reference.
Syntax
SYNC <table_name>Parameters
| Parameter | Required | Description |
|---|---|---|
table_name | Yes | Name of the table to synchronize (must be configured in config file) |
Response (Success)
OK SYNC STARTED table=<table_name>Response (Error)
The checks run in this order:
| Condition | Response |
|---|---|
| Table catalog not initialized | ERROR 4008 Table catalog not initialized |
| Unknown table, or a bare name under a multi-database configuration | ERROR 4007 Table not found: <name> or ERROR 4007 Bare table names are not supported; use <database>.<table>: <name> |
OPTIMIZE, DUMP SAVE, or DUMP LOAD in progress | ERROR 6030 Cannot start SYNC while <operation> is in progress |
| Shutdown requested | ERROR 6027 Cannot start SYNC for '<database>.<table>': server is shutting down |
| Table missing from the sync manager | ERROR 4010 Table '<database>.<table>' not found |
Another long operation, including any running SYNC on this or another table | ERROR 4011 <detail>, for example Cannot start SYNC while SYNC (<database>.<table>) is in progress |
| Memory critically low | ERROR 4012 Memory critically low. Cannot start SYNC. |
| Worker thread could not be created | ERROR 4013 Failed to create sync thread: <detail> |
Branch on the numeric code, not the message: 6030 and 4011 can carry the same Cannot start SYNC while <operation> is in progress text.
Behavior
SYNC runs asynchronously in the background and returns immediately after starting. It builds the snapshot from MySQL using a SELECT query, and each table takes its own consistent snapshot. On MySQL, commits between the GTID capture and the snapshot transaction may be replayed during replication; this at-least-once replay is intentional and idempotent.
While a SYNC gates a table, SEARCH, COUNT, GET, and FACET on it are rejected with ERROR 6029 Table '<database>.<table>' is synchronizing, please try again later. With replication enabled the gate covers every configured table; see Read availability checks.
The SYNC Command Guide describes the GTID capture and replication restart, failed-load error codes, the automatic initial load, and the commands that conflict with a running SYNC (Command Conflicts).
Cancel a SYNC
SYNC STOP [<table_name>]Stops the sync for the named table. Without a table name, cancellation is requested for every running sync. Cancellation is asynchronous. Use SYNC STATUS until the operation reports CANCELLED or another terminal state.
Cancelling an automatic attempt makes the loader give up on that table; a manual SYNC can initialize it afterwards. A SYNC STOP between attempts, when no SYNC is active, returns ERROR 8 No active SYNC operations to stop (or ERROR 8 No active SYNC operation for table: <name> when a table is named).
Example
$ mygram-cli
127.0.0.1:11016> AUTH <token>
OK AUTHENTICATED
127.0.0.1:11016> SYNC articles
OK SYNC STARTED table=articlesSYNC STATUS
Check the progress and status of SYNC operations.
Syntax
SYNC STATUSResponse Examples
SYNC STATUS is a multi-line wire response. The server wraps the status lines with OK SYNC_STATUS and END. mygram-cli removes these envelope lines before printing the status body; the examples below show the wire response.
In Progress:
OK SYNC_STATUS
table=articles status=IN_PROGRESS progress=10000/25000 rows (40.0%) rate=5000 rows/s
ENDJoining the previous worker:
OK SYNC_STATUS
table=articles status=JOINING_PREVIOUS
ENDStarting:
OK SYNC_STATUS
table=articles status=STARTING
ENDCancelling:
OK SYNC_STATUS
table=articles status=CANCELLING
ENDCompleted:
OK SYNC_STATUS
table=articles status=COMPLETED rows=25000 time=5.2s gtid=uuid:123 replication=STARTED
ENDFailed:
OK SYNC_STATUS
table=articles status=FAILED rows=5000 error="MySQL connection lost"
ENDIdle:
OK SYNC_STATUS
status=IDLE message="No sync operation performed"
ENDStatus Fields
| Field | Description |
|---|---|
table | Table name being synced |
status | JOINING_PREVIOUS, STARTING, IN_PROGRESS, COMPLETED, FAILED, CANCELLING, CANCELLED, or IDLE |
progress | Current/total rows processed |
rate | Processing rate (rows/s) |
rows | Total rows processed |
time | Total processing time |
gtid | Snapshot marker: MySQL's conservative lower-bound GTID or MariaDB's exact snapshot binlog position converted to a GTID; normal restart uses the drained pre-SYNC GTID, while undecodable-event (2017) recovery may restart from this marker |
replication | Replication status: STARTED, DISABLED, FAILED |
error | Error message (if failed) |
JOINING_PREVIOUS is a transient state while the previous worker for the table is joined; it changes to STARTING once the new worker is claimed. CANCELLING means that SYNC STOP requested cancellation. The transient states do not carry progress details.
CLI Example
The CLI strips the OK SYNC_STATUS and END envelope before displaying the status body.
$ mygram-cli
127.0.0.1:11016> AUTH <token>
OK AUTHENTICATED
127.0.0.1:11016> SYNC STATUS
table=articles status=IN_PROGRESS progress=10000/25000 rows (40.0%) rate=5000 rows/sFor manual snapshot synchronization setup, see the Replication Guide.
OPTIMIZE Command
Optimize index posting lists (convert Delta Encoding to Roaring Bitmap based on density).
When to run it
OPTIMIZE runs without stopping search, but it temporarily uses extra memory. On large datasets, run it during low-traffic hours and check memory health with /info or INFO beforehand.
Syntax
OPTIMIZE [<db.table>]Omit the table to optimize all configured tables. Name one table to optimize only that table; use database.table when the configuration spans multiple databases.
How it works
- Pre-execution checks: Memory health and availability verification
- Takes a snapshot of term names and rebuilds every posting list into a fresh optimized allocation
- Processes terms in batches; batches limit per-batch bookkeeping and allow periodic atomic publication, but do not remove the full rebuild's dominant memory cost
- Query processing and writes continue while the replacement lists are built
- Each batch is swapped in atomically, so replication keeps running throughout
Memory Safety
Pre-execution memory checks:
- Rejects execution if system memory health is CRITICAL (<10% available)
- Estimates peak memory from the resident index, a full rebuild copy, 10% temporary overhead, a term-name snapshot, and batch bookkeeping
- Requires roughly
2.1xthe index memory to be free; the exact estimate also grows with the number of distinct terms and the batch bookkeeping
Memory usage pattern:
- The existing index stays resident while the full optimized replacement is built, so peak usage approaches two index copies
- Batch size does not materially reduce peak memory; it limits per-batch bookkeeping and controls when replacements are published
Global Exclusion
- Only one OPTIMIZE operation can run at a time across all tables
- New OPTIMIZE commands are rejected while optimization is in progress
- Check
optimization_statusviaINFOcommand
Performance
Runtime depends on the number and size of posting lists and the host's available memory. Searches and replication continue during the rebuild, though concurrent updates may briefly contend when batches are published. Measure a run with your own data before scheduling regular optimization.
Response
Success:
OK OPTIMIZED tables=<n> terms=<n> delta=<n> roaring=<n> memory=<human>Example:
OK OPTIMIZED tables=1 terms=1500000 delta=1200000 roaring=300000 memory=450.00 MBErrors:
| Condition | Response |
|---|---|
| Already optimizing | ERROR 6030 Another OPTIMIZE operation is already in progress |
| Memory critically low | ERROR 6030 Memory critically low. Cannot start optimization: available=1.50 GB total=8.00 GB |
| Insufficient memory | ERROR 6030 Insufficient memory for optimization: Insufficient memory: estimated=2.50 GB available=1.80 GB |
DEBUG Command
Enable or disable debug mode for the current connection to see detailed query execution metrics.
Per-connection setting
DEBUG ON affects only the current TCP connection. Other mygram-cli sessions and application connections are unchanged.
Syntax
DEBUG ON
DEBUG OFFHow it works
| Aspect | Behavior |
|---|---|
| Per-Connection State | Debug mode is enabled/disabled for the current connection only |
| Query Timing | Shows execution time breakdown (index search, filtering) |
| Search Details | Displays n-grams generated, posting list sizes, and candidate counts |
| Optimization Visibility | Reports which optimization strategies were applied |
| Performance Impact | Minimal overhead, only collects metrics when enabled |
Response
OK DEBUG_ONor
OK DEBUG_OFFDebug Output Format
When debug mode is enabled, SEARCH appends a debug block to its response. Lines in brackets appear only when they apply:
OK RESULTS <count> <id1> <id2> ...
# DEBUG
query_time: <ms>ms
index_time: <ms>ms
[filter_time: <ms>ms]
terms: <n>
ngrams: <n>
candidates: <n>
after_intersection: <n>
after_not: <n>
after_filters: <n>
final: <n>
[optimization: <strategy>]
[sort: <column> <direction>]
limit: <value> [(default)]
[offset: <value> [(default)]]
cache: hit | miss | disabled
[cache_age_ms: <ms>]
[cache_saved_ms: <ms>]
[cache_reason: not_found | invalidated]
[cache_cost_ms: <ms>]
[cache_key: <canonical-key>]COUNT returns a shorter block: the timing lines, terms, ngrams, and the cache lines. The candidate counts, final, optimization, sort, limit, and offset are SEARCH-only.
OK COUNT <n>
# DEBUG
query_time: <ms>ms
index_time: <ms>ms
terms: <n>
ngrams: <n>
cache: hit | miss | disabled
...Debug Metrics Explained
| Field | Description |
|---|---|
query_time | Total query execution time, with an ms suffix |
index_time | Time spent searching the index, with an ms suffix |
filter_time | Time spent applying filters; printed only when greater than zero |
terms | Number of search terms |
ngrams | Total n-grams generated from the search terms |
candidates | Initial candidate documents from the index |
after_intersection | Results after AND term intersection |
after_not | Results after NOT term filtering |
after_filters | Results after FILTER conditions |
final | Total matching documents (before LIMIT/OFFSET) |
optimization | Strategy label, for example size-based term ordering, early-exit (empty posting list), synonym-expanded search, fuzzy-search (distance=1), or reuse-fetch (small result set); printed only when one was used |
sort | Applied sorting (column and direction); printed only when a sort was applied |
limit | Maximum results returned; shows (default) if not specified explicitly |
offset | Result offset for pagination; printed only when greater than zero |
cache | hit, miss, or disabled. Queries without search text always report disabled |
cache_age_ms, cache_saved_ms | On a hit: age of the cached entry and the execution time it saved |
cache_reason, cache_cost_ms | On a miss: not_found or invalidated, and the measured cost of this execution |
cache_key | Canonical query key, when one exists |
CACHE Commands
Inspect and control the query cache. See Configuration Guide for the cache settings themselves.
Syntax
CACHE STATS
CACHE CLEAR [<db.table>]
CACHE ENABLE
CACHE DISABLECACHE CLEAR without a table drops every entry; with a table it drops only that table's entries.
Responses
OK CACHE_CLEARED
OK CACHE_CLEARED table=app_db.articles
OK CACHE_ENABLED
OK CACHE_DISABLEDCACHE STATS returns a multi-line report terminated by END:
OK CACHE_STATS
# Cache
enabled: true
total_queries: 15000
cache_hits: 12000
cache_misses: 3000
hit_rate: 0.8000
current_entries: 420
current_memory_bytes: 8388608
evictions: 12
ttl_expirations: 5
avg_cache_hit_time_ms: 0.041
avg_cache_miss_time_ms: 18.220
total_time_saved_ms: 218640.000
ENDCACHE STATS can report the current counters while the cache is disabled. CACHE CLEAR requires an enabled cache; an unconfigured cache or an operation that requires the cache returns ERROR 8001 (kCacheDisabled). CACHE ENABLE returns ERROR 8001 Cache cannot be enabled: the invalidation worker could not be started. when its invalidation worker cannot start.
CACHE ENABLE / CACHE DISABLE change the running state only. SET cache.enabled = ... also changes process memory only and does not rewrite the configuration file. Edit config.yaml to persist the setting across a restart.
SET and SHOW VARIABLES
MySQL-style runtime variable commands. Only variables reported as mutable can be changed; see Operations Guide for the full workflow.
Syntax
SET <variable> = <value> [, <variable2> = <value2> ...]
SHOW VARIABLES [LIKE '<pattern>']The compact form is also valid: SET api.default_limit=50. It can be mixed with comma-separated assignments.
SHOW VARIABLES LIKE accepts exactly one pattern and matches it case-insensitively.
Responses
+OK Variable 'logging.level' set to 'debug'
+OK 2 variables setSHOW VARIABLES renders a MySQL-style table with a Mutable column:
+---------------------+-----------+---------+
| Variable_name | Value | Mutable |
+---------------------+-----------+---------+
| api.default_limit | 100 | YES |
| cache.enabled | true | YES |
| memory.verify_text | off | NO |
+---------------------+-----------+---------+SET validates each value with the configuration schema used at startup. A multi-assignment command applies all changes or none; an invalid assignment is named in the ERROR 1004 response. The same server_id and cache.max_memory_mb limits apply at runtime. SET cache.enabled = true can fail with ERROR 8001 Failed to set variable 'cache.enabled': Cache cannot be enabled. cache.min_query_cost_ms must be a finite, non-negative number; values such as nan, inf, and -inf are rejected with ERROR 1004.
When SHOW VARIABLES returns a sensitive field, its value is masked as ***. This includes mysql.password, mysql.ssl_key, and fields whose names contain password, secret, ssl_key, api_key, auth_key, private_key, access_key, or token. Empty values remain empty.
See Also
- Protocol Reference - Connection,
AUTH, and query commands - SYNC Command Guide - SYNC lifecycle, conflicts, and troubleshooting
- Snapshot Guide - Snapshot management and best practices
- Operations Guide - Runtime variables and readiness
- Replication Setup - MySQL replication configuration