mysql-5.6 icon indicating copy to clipboard operation
mysql-5.6 copied to clipboard

SST stats missing of compaction result of set global rocksdb_compact_cf="default"

Open rockeet opened this issue 1 year ago • 9 comments

set global rocksdb_compact_cf = "default";

The compacted SST missing stats info distincts per prefix:

image

The correct SST stat info should like this:

image

We traced to Rdb_ddl_manager::safe_find returned nullptr to Rdb_tbl_prop_coll, which is caused by in Rdb_ddl_manager::init, Rdb_key_def is not fully initialized(Rdb_key_def::setup was not called). From this point, I have no idea about how to go forward and resolve this issue(Rdb_key_def::setup needs TABLE object which can not be obtained).

rockeet avatar Aug 17 '22 05:08 rockeet

Can you tell me the what is the value for rocksdb_table_stats_sampling_pct for your workload? There is sampling around the "distincts per prefix" which is added as part of https://github.com/facebook/mysql-5.6/commit/c3d6ffc2f96324cb0c436f1a6ed77441c8b3c16d.

Can you try to repro this after setting rocksdb_table_stats_sampling_pct = 0?

Pushapgl avatar Aug 17 '22 19:08 Pushapgl

mysql> show variables like 'rocksdb_table_stats_%';
+--------------------------------------------------+-------+
| Variable_name                                    | Value |
+--------------------------------------------------+-------+
| rocksdb_table_stats_background_thread_nice_value | 19    |
| rocksdb_table_stats_max_num_rows_scanned         | 0     |
| rocksdb_table_stats_recalc_threshold_count       | 100   |
| rocksdb_table_stats_recalc_threshold_pct         | 10    |
| rocksdb_table_stats_sampling_pct                 | 10    |
| rocksdb_table_stats_use_table_scan               | OFF   |
+--------------------------------------------------+-------+
6 rows in set (0.00 sec)

This issue just happens for non opened table, if a table is opened, stat of SSTs for that table are correct.

rockeet avatar Aug 18 '22 03:08 rockeet

Can you set rocksdb_table_stats_sampling_pct to 0, then see if the issue still exists?

Pushapgl avatar Aug 18 '22 16:08 Pushapgl

set rocksdb_table_stats_sampling_pct to 0 didn't resolve this issue.

I have read the code, this issue is not related to rocksdb_table_stats_sampling_pct.

rockeet avatar Aug 19 '22 06:08 rockeet

can you provide me a repro for the issue?

Pushapgl avatar Aug 19 '22 18:08 Pushapgl

Step 1

start a clean myrocks server

Step 2

run sysbench on a client

sysbench oltp_write_only prepare --threads=100 --tables=100 --table_size=100000 \
    --db-driver=mysql --mysql-host=<myrocks-server> --mysql-port=3306 \
    --mysql-user=test  --mysql-password=<passwd> --mysql-db=test \
    --mysql_storage_engine='rocksdb default charset latin1' 

Step 3

stop and restart myrocks server

Step 4

run mysql command on a client, NOTE: don't run any mysql command before this command.

set global rocksdb_compact_cf = "default";

Step 5

After compact completed, SST indexstat is wrong.

In our in house myrocks branch, we have a webview to see per-SST info thus we discovered this issue.

In myrocks world, I think this info should be added into information_schema.ROCKSDB_SST_PROPS as a json column.

rockeet avatar Aug 20 '22 02:08 rockeet

I've previously documented when we might get empty sst stats here:

https://github.com/facebook/mysql-5.6/issues/807

I think you are describing case #2

lth avatar Nov 23 '22 18:11 lth

@lth Yes, this is the issue you had documented. This issue is serious as it would yield wrong query plans, could you provide a fix?

rockeet avatar Nov 24 '22 02:11 rockeet

I don't have a good fix for you, but rocksdb_table_stats_use_table_scan was meant to address these problem, but we don't use it in production, so it is very possible that it has problems.

lth avatar Dec 02 '22 23:12 lth