Skip to content

01-Taosd

Taosd command line
1. Verify taosd -s options to dump sdb.json

Repair cmdline help should expose the current repair-target interface.
1. Verify `taosd -r --help` still prints the vnode/force-only usage.

Repair cmdline should accept the current target grammar and strategy names.
1. Verify valid `wal`, `meta`, and `tsdb` targets are accepted.
2. Verify TSDB accepts the current explicit strategies.
3. Verify mixed repair targets still parse together.

Repair cmdline should reject invalid target syntax and invalid strategies.
1. Verify parser-level grammar errors still fail with stable messages.
2. Verify target-type-specific restrictions still hold.

Repair cmdline should reject invalid mode usage and removed legacy options.
1. Verify `--repair-target` cannot be used without `-r`.
2. Verify required repair-mode options are enforced.
3. Verify removed legacy args still fail as invalid options.

Server config basic
1. Verify alter support vnodes config
2. Verify alter ttl config
3. Verify alter bypass flag config
4. Verify alter audit config
5. Verify alter config on dnode 1
6. Verify alter timezone config
7. Verify alter memPoolReservedSizeMB config
8. Verify dismatch config refresh

Server config hot refresh
1. Alter taos.cfg item by "alter" sql
2. Verify the altered item value take effect
3. Stop and restart taosd
4. Verify the altered item value take effect after restart
5. Config item include server and client side

Client config hot refresh
1. Alter taos.cfg item by "alter" sql
2. Show local variant to verify
3. Restart taosd
4. Show local variant to verify again

Server persist config
1. Obtain taos.cfg file path
2. Modify fqdn/dataDir/logDir with new values
3. Restart taosd
4. Check config values loaded from mnd sdb
5. Expect new values go into effect

Taosd telemetry audit
1. Create database with vgroups 1
2. create audit user and token
2. Create super table and table
3. Insert data into table
4. Delete data from table
5. Start http server to receive telemetry info
6. Check telemetry info content valid
7. Stop http server

Taosd telemetry audit
1. Create database with vgroups 1
2. Create super table and table
3. Insert data into table
4. Delete data from table
5. Start http server to receive telemetry info
6. Check telemetry info content valid
7. Stop http server

Taosd log
1. Check log compress
2. Check log output
3. Check log rotate
4. Close taosd and taos

Taosd telemetry monitor
1. Configure monitorFqdn/monitorPort/monitor params
2. Start http server to receive monitor info
3. Do some operations to generate monitor info
4. Check monitor info content valid
5. Check telemetry info content valid
6. Stop http server

Taosd restart
1. Create 1 stable and 4 child tables
2. Insert 13 rows for each child table
3. Restart taosd 5 times, and query sum of columns after each restart
4. Check the query results
5. Expect all query results are correct

Taosd self audit
1. Create database with vgroups 1
2. Create super table and table
3. Insert data into table
4. Delete data from table
5. Check info content valid

Taosd self audit
1. Create database with vgroups 1
2. set switch auditSaveInSelf 1
2. Create super table and table
3. Insert data into table
4. Delete data from table
5. Check info content valid

Server support telemetry
1. Configure telemetry params
2. Start http server to receive telemetry info
3. Check telemetry info content valid
4. Stop http server

Meta force repair should accept the new repair-target syntax.
1. Verify meta repair uses `--repair-target meta:vnode=<id>`.
2. Verify explicit `strategy=from_redo` is also accepted.

Meta force repair should create backup files for a real vnode.
1. Create real vnode data.
2. Stop taosd and run meta force repair against that vnode.
3. Verify external backup directory is created and contains meta files.

Meta force repair should fail when the target backup directory already exists.
1. Create real vnode data and pre-create the expected backup directory.
2. Stop taosd and run meta force repair against that vnode.
3. Verify the process fails with the existing-backup-dir error.

Meta force repair should use the default tmp backup root when backup-path is omitted.
1. Create real vnode data and remove any pre-existing default backup directory.
2. Stop taosd and run meta force repair without `--backup-path`.
3. Verify the backup appears under the default tmp root.

TSDB force repair base module should load as a valid test file.
1. Import the shared base helpers module.
2. Execute a no-op smoke test.
3. Verify the file satisfies CI collection rules without affecting repair coverage.

TSDB force repair should keep a real fileset writable after missing-head repair.
1. Build one real core fixture and remove its head file.
2. Run force repair for the affected fid with backup enabled.
3. Verify the database remains readable and writable after restart.

TSDB force repair should keep a multi-fileset database writable after old-head repair.
1. Build one vnode fixture with multiple real filesets.
2. Remove the head file from an older fileset and run force repair.
3. Verify remaining data stays readable and the table remains writable after restart.

TSDB force repair should rebuild head/data/sma from readable blocks.
1. Create one vnode with enough rows to form multiple blocks.
2. Corrupt late bytes in a real `.head` file without changing file size.
3. Run tsdb force repair and verify it records `rebuild_core_group`.
4. Restart normally and verify the table still has readable rows.

TSDB force repair head-only rebuild should recover real head damage.
1. Build one real core fixture and corrupt a real `.head` file without changing file size.
2. Run force repair with `head_only_rebuild` for the affected fid.
3. Verify the original `.data` file remains on disk and the database stays writable after restart.

TSDB force repair default strategy should not fix head size mismatch.
1. Build one real core fixture and extend its head file to create size mismatch.
2. Run force repair without an explicit strategy so it uses `drop_invalid_only`.
3. Verify the head file size remains changed, proving deep repair was not applied.

TSDB force repair should repair two targeted filesets in one run.
1. Build one vnode fixture with multiple real filesets.
2. Corrupt two targeted heads and run one repair command with two `--repair-target` entries.
3. Verify the database remains readable and writable after restart.

TSDB force repair wildcard target should repair all filesets in one vnode.
1. Build one vnode fixture with multiple real filesets.
2. Corrupt two filesets and run one repair command with `fileid=*`.
3. Verify the database remains readable and writable after restart.

TSDB force repair full rebuild should recover a real head size mismatch.
1. Build one real core fixture and extend its head file to create size mismatch.
2. Run force repair with `full_rebuild` for the affected fid.
3. Verify rows remain queryable and the database stays writable after restart.

TSDB force repair fixture builder should expose one real core fileset.
1. Build a real core fixture from on-disk vnode data.
2. Verify the fixture reports vnode, fid, and row count.
3. Verify the resolved head and data files exist on disk.

TSDB force repair fixture builder should expose multiple real filesets.
1. Build a real multi-fileset fixture from on-disk vnode data.
2. Verify the fixture reports vnode and multiple distinct fids.
3. Verify the resolved file paths exist on disk.

TSDB force repair fixture builder should expose one real stt file.
1. Build a real stt fixture from flushed vnode data.
2. Verify the fixture resolves vnode, fid, and stt entry count.
3. Verify the referenced stt file exists on disk.

TSDB force repair size-mismatch injector should alter file size.
1. Create a temporary file with known size.
2. Apply the size-mismatch corruption helper.
3. Verify the helper reports size-mismatch and the file size changed.

TSDB force repair should leave a healthy fileset readable and writable.
1. Build one real healthy core fixture.
2. Run force repair against that fileset without injecting corruption.
3. Verify row count is unchanged and the table remains writable after restart.

TSDB force repair should dispatch inside tsdb open fs.
1. Create a real vnode.
2. Run tsdb force repair.
3. Verify tsdb open fs reports the repair dispatch marker.

TSDB force repair should not stay on phase1 placeholder path.
1. Create a real vnode.
2. Stop taosd and run tsdb force repair against that vnode.
3. Verify the process no longer reports the phase1 placeholder text.

TSDB force repair should keep the database writable after missing-stt repair.
1. Build one real stt fixture and remove its stt file.
2. Run force repair for the affected fid.
3. Verify the table remains readable and accepts new writes after restart.

TSDB force repair should keep missing-stt repair writable with backup-root enabled.
1. Create a real vnode with an stt file and configure a backup root.
2. Remove the stt file and run force repair for the affected fid.
3. Verify the database remains writable after restart and optionally validate repair.log.

TSDB force repair should remove missing stt metadata from current.json.
1. Build one real stt fixture and confirm current.json contains stt entries.
2. Remove the stt file and run force repair for the affected fid.
3. Verify current.json no longer references the missing stt after repair.

tsdbSttFileReadStatisBlock must return FILE_CORRUPTED for numOfPKs > TD_MAX_PK_COLS.
Prior to the fix, statisBlk->numOfPKs was used as the loop bound when
writing into two fixed-size TD_MAX_PK_COLS-element stack arrays
(firstKeyInfos / lastKeyInfos). An attacker-controlled value > 2 would
overwrite adjacent stack memory.
Fix: validate numOfPKs <= TD_MAX_PK_COLS at function entry and return
TSDB_CODE_FILE_CORRUPTED immediately without touching the stack arrays.
Test steps:
1. Create a table, insert rows, and flush to produce a real .stt file.
2. Stop taosd.
3. Patch numOfPKs in the first SStatisBlk to 127 (well above TD_MAX_PK_COLS=2).
4. Restart taosd.
5. Query the table to trigger statis block reading.
6. Verify taosd is still reachable (graceful rejection, not a crash / ASAN abort).

tsdbSttFileReadStatisBlock must not reject numOfPKs within the valid range.
numOfPKs values 0 and TD_MAX_PK_COLS (2) must pass the bounds check.
This smoke-test verifies normal .stt files remain readable after the fix.
1. Create a table, insert rows, and flush to produce a real .stt file.
2. Verify the original numOfPKs is within [0, TD_MAX_PK_COLS].
3. Query the table and confirm it returns the expected row count.

tsdbDataFileReadBrinBlock must reject oversized numOfPKs without stack corruption.
Prior to the fix, brinBlk->numOfPKs was used as the loop bound when
writing into two fixed-size TD_MAX_PK_COLS-element stack arrays
(firstInfos / lastInfos in tsdbDataFileReadBrinBlock). An oversized
value > 2 would overwrite adjacent stack memory.
Fix: validate numOfPKs <= TD_MAX_PK_COLS at function entry and return
TSDB_CODE_FILE_CORRUPTED immediately.
Test steps:
1. Create a table, insert enough rows and flush repeatedly until the
data is compacted into a real .head file.
2. Stop taosd.
3. Patch numOfPKs in the first SBrinBlk to 127 (> TD_MAX_PK_COLS=2).
4. Restart taosd.
5. Run a SELECT query to trigger brin block reading.
6. Verify taosd is still reachable (graceful rejection, not a crash).

WAL force repair should rename corrupted wal directory and recover startup.
1. Create real vnode data with small WAL segment size and confirm multiple wal files exist.
2. Remove a middle wal log/index pair and run wal force repair for that vnode.
3. Verify a `wal.corrupted.*` directory is created and the database remains writable after restart.