The oma replay command reads the CANONICAL_JSONL event stream, replays it to the target OceanBase Database as configured, and accumulates statistics. Log parsing must be completed before replaying. For supported source ranges, see Performance assessment overview.
Command form
java -Xmx2g -jar oma.jar replay -c <configuration file> [--dry-run] [--output-format json]
Option description
Options |
Default Value |
Description |
|---|---|---|
-c, --config |
./config.json |
JSON Configuration File Path |
--dry-run |
Off | Only performs parsing, filtering, conversion, and timing control; skips database execution |
--read-only |
Off | Read-only mode, which replays only SELECT statements and disables transactions and DDL. Events excluded by this mode are counted in Filtered Quantity, and the filtering reason is recorded as FILTERED_BY_SQL_TYPE. |
--output-format |
text |
Output format:textorjson |
--verbose |
Off | Output DEBUG-level logs |
--replayer-count |
Configuration Value | Overwritereplay.replayerCount, the total number of processes participating in the replay (the base for directory hash modulo), must be greater than or equal to 1. |
--replayer-index |
Configuration Value | Overwritereplay.replayerIndex, the current process number, which must be greater than or equal to 0 and less than the total number of processes. |
--start-time |
None | Start filter time, in the format of"yyyy-MM-dd HH:mm:ss", which takes precedence over the resume time recorded in the checkpoint. Seconds are not compared; runtime is accurate to only minutes. |
--report |
None | Generates a report only for existing statistical files without starting playback. For more information, see Performance statistics and reports. |
-h, --help、--version |
None | View Help and Version |
Configuration file search order
- The path specified by
-c. ./config.jsonin the current directory.~/.oceanbase-replay/config.jsonin the user's home directory.- The built-in
classpath:config.jsonof the program.
Configuration structure
The configuration is in JSON format. The top-level groups are s3, database, replay, filters, sqlKeywordFilter, sqlTransform, sqlMapping, checkpoint, and stats.
Group |
field |
Description |
|---|---|---|
s3 |
logPath |
Event stream input path, must include the scheme prefix: file:///absolute_path for local directories, or s3://… or oss://… for object storage. An empty value will trigger the error "s3.logPath configuration cannot be empty"; an absolute path without a prefix will be identified as non-local storage, triggering the error "s3.endpoint configuration cannot be empty (required in S3/OSS mode)". |
s3 |
logFormat |
Input format. Leave this parameter empty for the parsed result.CANONICAL_JSONL; Other optionsTIDB_AUDIT、TIDB_AUDIT_V2、KEY_VALUE、GENERAL_LOG |
s3 |
endpoint、region、bucketName、accessKey、secretKey、connectionTimeout、readTimeout、maxRetries、s3ReadBackoffInitialMs、s3ReadBackoffMaxMs、subdirPrefix、subdirCount |
Read input from object storage. The storage type is specified by thelogPathPrefix determination, no independentstorageTypeParameter;s3://andoss://NextendpointandbucketNameRequired |
database |
host、port、username、password、database、tenantMode |
Target connection information.tenantModeTakeMYSQLorORACLE; The port for connections through OBProxy is typically 2883. |
database |
jdbcUrl、jdbcParameters、userMappings |
Custom connection string and connection parameters.userMappingsMaps the target credentials (obtained from the event's) to the initial database name/schema of the session as the key.databaseField. If empty, use the default value.database.database), which containsusernameandpassword; used when the key is not hitdatabase.username、database.password. The match key is the database name, not the source username. |
database |
poolInitialSize、poolMaxActive、poolMinIdle、poolMaxWait |
Connection Pool Size and Wait Strategy |
replay |
replayMode |
Replay mode. Only FULL_SPEED, TIME_BASED, RATE_LIMITED, and TIME_BASED_LIMITED are supported. Other values will result in the error message replayMode only supports FULL_SPEED, TIME_BASED, RATE_LIMITED, TIME_BASED_LIMITED. |
replay |
rateLimitQps、timeBasedMaxWaitMs |
The target QPS for rate limiting. It indicates the maximum wait time in milliseconds for a single step during chronological replay. |
replay |
dynamicInput |
Whether to Continuously Read New Inputs |
replay |
replayerCount、replayerIndex |
Total number of processes and current process number. Command-line options take precedence over configuration. An out-of-range number will result in a parameter error. For details, see "Common configuration errors". |
replay |
bufSize、commandBufferCapacity、queueMaxPending、sessionQueueCapacity、pollTimeoutMs、drainTimeoutSeconds |
Read Buffer, Command Queue, and Final Wait |
replay |
abortThreshold |
Replay stops when the failure count reaches this threshold. |
replay |
sessionTimeoutMs、reconnectDelayMs、maxReconnectAttempts、strictSessionLifecycle |
Session Keepalive, Reconnection on Disconnection, and Strict Session Lifecycle Mode |
replay |
psMode.enabled、psMode.cacheMaxSize |
Prepared Statement Mode and Statement Cache Upper Limit |
filters |
allowedSqlTypes、enableDDL、transactionEnabled |
List of allowed SQL types, whether to replay DDL statements, and whether to replay transactions |
filters |
useWhitelist、whitelistDatabases、blacklistDatabases、excludedUsers |
Database and user filtering. The allowlist switch determines which list to use. |
sqlKeywordFilter |
useWhitelist、whitelistKeywords、blacklistKeywords |
Filter by SQL keywords |
sqlTransform |
removeTiFlashHints、removeTidbRowid、transformBatchStatements、customRules |
Statement preprocessing: Remove TiFlash hints, remove TiDB ROWIDs, and split batch statements.customRules(pattern、replacement(List) The current version only supports configuration definition and does not integrate with the execution pipeline. Configurations will not take effect after being set. |
sqlMapping |
enabled、filePath、mappings |
Statement rewrite mapping. The actual effective link is loaded from an independent mapping file:filePathSpecify the path. If not specified, environment variables will be used in sequence.SQL_MAPPING_FILE, Defaultconfig/sql-mappings.json), match the entire statement by its MD5 fingerprint and replace it as a whole. The entry'senabledDecides whether to take effect. Top-levelenabledNot read in the execution link, set tofalseCannot prevent enabled entries in the mapping file from taking effect. Inlinemappings(pattern、replacement(List) The current version only supports configuration definition and has not connected the execution link. The configuration will not take effect after being set. |
checkpoint |
filePath、saveIntervalMs |
The checkpoint save path and save interval.filePathIt only determines where the checkpoint is written. When loading progress, it reads from the directory where the execution command is located.checkpoint.json, they may not be the same file. For more information, see "Sharding and resuming runs". |
stats |
enabled(Default:false)、dir(Default:stats)、flushIntervalSec(Default:5)、slowSqlThresholdMs(Default:1000)、sourceLabel、targetLabel |
Statistics switch, output directory, disk persistence interval, slow SQL threshold, and source label in the report.enabledisfalseNo statistical files are generated during this time;dirWhen it is a relative path, it is relative to the current directory where the command is executed. |
Configuration example
The configuration for simulated replay is as follows, with target connections as placeholders:
{
"s3": {
"logPath": "file:///abs/path/work/rds-canonical",
"logFormat": "CANONICAL_JSONL"
},
"database": {
"host": "127.0.0.1",
"port": 2883,
"username": "root",
"password": "",
"database": "test",
"tenantMode": "MYSQL"
},
"replay": {
"replayMode": "FULL_SPEED",
"dynamicInput": false
},
"filters": {
"transactionEnabled": false,
"enableDDL": false,
"allowedSqlTypes": ["SELECT"]
},
"sqlMapping": {
"filePath": "/abs/path/work/sql-mappings.json"
},
"checkpoint": {
"filePath": "/abs/path/work/checkpoint.json"
},
"stats": {
"enabled": true,
"dir": "/abs/path/work/stats"
}
}
The mapping file is a JSON object. The keys are the MD5 fingerprints of the original SQL statements, and the values contain the following fields:
{
"<MD5 of original SQL>": {
"sqlFingerprint": "<MD5 of original SQL>",
"originalSql": "<Original statement>",
"mappedSql": "<Replaced statement>",
"description": "<Remarks>",
"enabled": true,
"createdTime": "2026-11-01T00:00:00",
"updatedTime": "2026-11-01T00:00:00"
}
}
When no statement rewriting is needed, set filePath to a non-existent file or an empty mapping file with content {}. Do not rely on sqlMapping.enabled=false to prevent rewriting; this switch is not read during execution.
Common configuration errors
The program exits during startup if the configuration is invalid. Common configuration errors include:
The s3.logPath configuration cannot be empty.
The s3.endpoint configuration cannot be empty (required in S3/OSS mode).
replayMode only supports the values FULL_SPEED, TIME_BASED, RATE_LIMITED, and TIME_BASED_LIMITED.
Parameter error: replayerIndex must be within the range [0, replayerCount).
The corresponding causes are as follows: the configuration file is empty or s3.logPath is not specified; logPath does not have a scheme prefix; replayMode has an invalid value; the shard index exceeds the total number of shards.
Mock replay
First, use --dry-run to verify parsing, filtering, and the time-series link:
java -Xmx2g -jar oma.jar replay -c work/dry-run.json --dry-run --output-format json
In this mode, no connection is established to the target database, and no execution occurs. Configuration parameters such as
hostandportcan be placeholder values.It is recommended to select only
SELECTand disable DDL and transactions, which is consistent with the example configuration.The program starts an internal HTTP service that listens on port
9080by default. The operating system must allow local listening. If the process continues listening after processing is complete, you can exit normally by pressing Ctrl+C.If
sqlMapping.filePathis not configured, the program sequentially checks the environment variableSQL_MAPPING_FILEand the default pathconfig/sql-mappings.json. If this file does not exist, it runs with an empty mapping and automatically creates the file in the current directory upon exit. To avoid generating an extra file, explicitly point it to an existing one.A "successful" mock replay only indicates that events were processed correctly and does not guarantee that SQL statements can be executed in OceanBase.
Dry-run diagnostic report
After the run completes, a diagnostic report for reconciliation is printed. The fields and their meanings are as follows:
field |
Meaning |
|---|---|
Total Log Lines |
Number of Rows of Events Read |
Parsing succeeded / Parsing failed |
Deserialized event results. The sum of these two values equals Total log lines. |
Number of Filters |
Events Excluded by Filter Rules, Read-only Mode, or Keyword Filtering |
Filter reason |
Filter details counted by cause code, such as those in read-only mode.FILTERED_BY_SQL_TYPE |
SQL Mapping Hit / SQL Translation Hit |
Events Hit by Rewrite Rules |
Estimated Parsing QPS |
Throughput reference value in parsing phase |
SQL Type TopN / Database TopN / User TopN / Table TopN |
Event distribution,nullwill appear as a group |
Number of Outliers |
Number of Events with Exceptions During Parsing or Transformation |
You can reconcile the Total log lines with the number of output events from Log parsing, and the Successfully parsed count with the number of commits in the subsequent replay. If these three do not match, first check if other formats are mixed in the input directory or if any events were skipped.
Live replay
Before performing a live replay, ensure the following conditions are met; otherwise, statements will fail due to missing tables, missing databases, or data mismatch:
- Accessible target OceanBase tenant address, port, username, password, and necessary permissions.
- Database and table structures involved in the logs, along with initial data that meets query conditions. Logs are not database backups and cannot replace data migration.
- Database name mapping or filtering rules. The same log may involve multiple source database names; confirm they can be mapped to target databases.
- Independent replay configuration, checkpoint directory, and statistics directory.
Replace the target connection with actual values and verify the mapping, then remove --dry-run and execute java -Xmx2g -jar oma.jar replay -c <actual configuration>. It is recommended to first limit the queries to a small number of SELECT statements to verify in a test database, then gradually increase the volume. Historical logs usually also contain INSERT, DDL, and management statements.
To determine which databases and objects need to be preconfigured, you can first use the mock replay to look at the diagnostic report's Top N Databases, Top N Tables, and Top N SQL Types: For samples primarily containing probe-active statements and metadata queries, only the databases involved in the logs need to be created. For samples containing business table queries, table structures and data that meet query conditions are also required; otherwise, statements can execute but return an empty set, and target_* execution times cannot represent real load.
Which database is connected for each session
In a live replay, the target database for each session connection is determined by the event, which is counterintuitive:
In
MYSQLmode, the database to connect to is taken from the event's owndatabasefield.database.databaseis only used to counttarget_endpointrecords in the database and does not participate in constructing the connection string. When the source log's database name is empty, this field is set to the string"null"(not the JSONnull), and the connection string becomesjdbc:oceanbase://127.0.0.1:2883/null, which manifests as an error indicating the database cannot be found when the connection database name is null, with 0 successful events submitted. To resolve this, usefilters.useWhitelistwithfilters.whitelistDatabasesto exclude non-existent database names, allowing normal replay.In
ORACLEmode, the connection string does not include a database name. Ifdatabase.databaseis missing by default, it defaults totest. In an OceanBase Oracle-compatible tenant, there is notestdatabase, so an error is reported for its absence. After retries are exhausted, the top-level prompt only shows "Replay failed, target transaction results may be uncertain," which is unrelated to the actual cause. For Oracle-compatible tenant replay, explicitly configuredatabase.database, for example, by setting it toSYS.Idle detection statements for the connection pool differ by
tenantMode:SELECT 1 FROM DUALforORACLEandSELECT 1forMYSQL.
End and cleanup of replay
After input processing is complete, the main thread initiates a graceful shutdown, performing seven steps in sequence: stop the replay service, wait for the queue to clear, save the checkpoint, close the connection pool, close the queue manager, refresh statistics and Kafka, and output the runtime summary. The process exits automatically upon completion without requiring manual intervention.
The fields in the runtime summary are
Total Processed,Success,Failed,Current QPS,Avg Exec Time,Queue Depth,Active Conns, andElapsed Time. During submission, there are alsoReplayScheduler Submitted: N, Rejected: N. The difference between the number of submitted events andTotal Processedrepresents events that are in transit and have not been replayed.For multi-session, cross-database replays, after all events are submitted,
Total Processedmay stop increasing,Queue Depthmay be 0, butActive Connsmay not zero out. In this case, press Ctrl+C to trigger the same seven-step cleanup sequence. The log will prompt "Press Ctrl+C again to force exit (unsaved data may be lost)."Forced termination (
kill -9) skips the cleanup: the checkpoint stops at the last automatic save time, thestatusin the statistics databasereplay_run_metadatastops atRUNNING,ended_atis empty, and the "Replay reconciliation" section in the report becomes allnull, as described in Performance statistics and reports.
Quick troubleshooting for runtime errors
Corresponds to the following scenarios:
- Event
databaseis the string"null"(an error indicating the database cannot be found when the connection database name is null). Use a database whitelist to exclude this. - Samples contain queries for
information_schema.EVENTS, which OceanBase does not support. This is an expected failure. For large volumes, rewrite or filter usingsqlMapping. - An Oracle-compatible tenant is not configured with
database.database, which defaults totest, resulting in an error indicating the database cannot be found. See "Which database is the session connected to".
Sharding and Resuming Playback
When a single process handles large-scale events, use
--replayer-countto specify the total number of processes and--replayer-indexto specify the index of the current process. The total number of processes must be the same, and their indices must be unique. Unlike--worker-countin Log Parsing, this set of options does take effect during playback. However, shards are not split in the order ofshard_Nindices: each input subdirectory is hashed with its absolute path using the FNV-1a 64-bit hash function, then moduloreplayerCount. Only the directories whose remainder equals the current process'sreplayerIndexare read by that process.Therefore,
replayerCountdoes not need to equal the--shardsvalue used during parsing: it only determines the base for the hash modulo operation and has no direct correspondence with the number of directories. IfreplayerCountis greater than the number of shards, some processes may run idle without any directories; if it is less, one process will handle multiple directories. WhenreplayerCountis 1, a single process handles all directories.All processes participating in the same round of local playback must use the same layout of absolute input paths and the same
replayerCount(each process has a unique index, consecutively covering from 0 toreplayerCount - 1). Attribution is determined by path string hashing. If the absolute path of the same directory varies across different machines (due to different mount points or working directories), it will be assigned to different processes, leading to duplicate playback or missed shards.Playback progress is recorded in checkpoint files, with the
shard_Nin the input directory as the key. Each shard containslastProcessedTime,lastProcessedSequence, andlastSavedTime. A checkpoint is considered usable if it meets all the following criteria:sourcePathmatches the currents3.logPath,logFormatis consistent, and at least one shard'slastProcessedSequenceis greater than 0 and has alastProcessedTime.When loading a checkpoint, the system reads the
checkpoint.jsonfile located in the directory where the execution command resides, not the file specified bycheckpoint.filePath. If acheckpoint.jsonfile exists in the runtime directory, it is loaded and the completed portion is skipped based on the shard progress. The new progress is written to the file specified byfilePath. If nocheckpoint.jsonfile exists in the runtime directory but one exists at the path specified byfilePath, that checkpoint is still not loaded, and a full replay is performed.Therefore, always execute
oma replayfrom the same directory and setcheckpoint.filePathto point to thecheckpoint.jsonfile within that directory to avoid reading from A and writing to B. When you need to restart from the beginning, remove thecheckpoint.jsonfile from the runtime directory.--dry-rundoes not persist checkpoints to disk, so resume playback behavior can only be verified during actual playback.--start-timespecifies the start time to skip already processed periods, and it has a higher priority than the resume time recorded in checkpoints. This time only applies during the execution scheduling phase and does not affect the number of events read for the diagnostic report.
For information on viewing playback results, see Performance statistics and reports.