facebook / rocksdb

A library that provides an embeddable, persistent key-value store for fast storage.
http://rocksdb.org
GNU General Public License v2.0
28.09k stars 6.25k forks source link

Add timestamp support in dump_wal/dump/idump #12690

Closed jowlyzhang closed 2 months ago

jowlyzhang commented 2 months ago

As titled. For dumping wal files, since a mapping from column family id to the user comparator object is needed to print the timestamp in human readable format, option [--db=<db_path>] is added to dump_wal command to allow the user to choose to optionally open the DB as read only instance and dump the wal file with better timestamp formatting.

Test plan: Manually tested

dump_wal: [dump a wal file specified with --walfile]

>> ./ldb --walfile=$TEST_DB/000004.log dump_wal  --print_value
>>1,1,28,13,PUT(0) : 0x666F6F0100000000000000 : 0x7631 
(Column family id: [0] contained in WAL are not opened in DB. Applied default hex formatting for user key. Specify --db=<db_path> to open DB for better user key formatting if it contains timestamp.)

[dump with --db specified for better timestamp formatting]

>> ./ldb --walfile=$TEST_DB/000004.log dump_wal  --db=$TEST_DB --print_value
>> 1,1,28,13,PUT(0) : 0x666F6F|timestamp:1 : 0x7631

dump: [dump a file specified with --path]

>>./ldb --path=/tmp/rocksdbtest-501/column_family_test_75359_17910784957761284041/000004.log dump
Sequence,Count,ByteSize,Physical Offset,Key(s) : value 
1,1,28,13,PUT(0) : 0x666F6F0100000000000000 : 0x7631 
(Column family id: [0] contained in WAL are not opened in DB. Applied default hex formatting for user key. Specify --db=<db_path> to open DB for better user key formatting if it contains timestamp.)

[dump db specified with --db]

>> ./ldb --db=/tmp/rocksdbtest-501/column_family_test_75359_17910784957761284041 dump           
>> foo|timestamp:1 ==> v1
Keys in range: 1

idump

./ldb --db=$TEST_DB idump
'foo|timestamp:1' seq:1, type:1 => v1
Internal keys in range: 1
facebook-github-bot commented 2 months ago

@jowlyzhang has imported this pull request. If you are a Meta employee, you can view this diff on Phabricator.

facebook-github-bot commented 2 months ago

@jowlyzhang merged this pull request in facebook/rocksdb@9a72cf1a619a3a0c51bc5572d91071b79f62758e.