rocksdb/db/db_impl
Peter Dillinger 3d358a7e25 Fix handling of accidental truncation of IDENTITY file (#10173)
Summary:
A consequence of https://github.com/facebook/rocksdb/issues/9990 was requiring a non-empty DB ID to generate
new SST files. But if the DB ID is not tracked in the manifest and the IDENTITY file
is somehow truncated to 0 bytes, then an empty DB ID would be assigned, leading
to crash. This change ensures a non-empty DB ID is assigned and set in the
IDENTITY file.

Also,
* Some light refactoring to clean up the logic
* (I/O efficiency) If the ID is tracked in the manifest and already matches the
IDENTITY file, don't needlessly overwrite the file.
* (Debugging) Log the DB ID to info log on open, because sometimes IDENTITY
can change if DB is moved around (though it would be unusual for info log to
be copied/moved without IDENTITY file)

Pull Request resolved: https://github.com/facebook/rocksdb/pull/10173

Test Plan: unit tests expanded/updated

Reviewed By: ajkr

Differential Revision: D37176545

Pulled By: pdillinger

fbshipit-source-id: a9b414cd35bfa33de48af322a36c24538d50bef1
2022-06-15 15:39:49 -07:00
..
compacted_db_impl.cc Return "invalid argument" when read timestamp is too old (#10109) 2022-06-06 14:36:22 -07:00
compacted_db_impl.h Add timestamp support to CompactedDBImpl (#10030) 2022-05-24 12:14:10 -07:00
db_impl.cc Fix C4702 on windows (#10146) 2022-06-14 21:32:10 -07:00
db_impl.h Fix handling of accidental truncation of IDENTITY file (#10173) 2022-06-15 15:39:49 -07:00
db_impl_compaction_flush.cc Return try again when full_history_ts_low is higher than requested ts (#10126) 2022-06-10 08:21:08 -07:00
db_impl_debug.cc Use std::numeric_limits<> (#9954) 2022-05-05 13:08:21 -07:00
db_impl_experimental.cc Track SST unique id in MANIFEST and verify (#9990) 2022-05-19 11:04:21 -07:00
db_impl_files.cc Fix handling of accidental truncation of IDENTITY file (#10173) 2022-06-15 15:39:49 -07:00
db_impl_open.cc Fix handling of accidental truncation of IDENTITY file (#10173) 2022-06-15 15:39:49 -07:00
db_impl_readonly.cc Return "invalid argument" when read timestamp is too old (#10109) 2022-06-06 14:36:22 -07:00
db_impl_readonly.h Add timestamp support to DBImplReadOnly (#10004) 2022-05-19 18:39:41 -07:00
db_impl_secondary.cc Consolidate manual_compaction_paused_ check (#10070) 2022-06-06 18:32:26 -07:00
db_impl_secondary.h Persist the new MANIFEST after successfully syncing the new WAL during recovery (#9922) 2022-06-01 10:52:26 -07:00
db_impl_write.cc Verify write batch checksum before WAL (#10114) 2022-06-15 13:43:58 -07:00