fix(server): handle incomplete RocksDB with missing column families gracefully - #2404
Open
cauchy1988 wants to merge 1 commit into
Open
cauchy1988 wants to merge 1 commit into
cauchy1988 wants to merge 1 commit into
Conversation
…racefully When a replica server crashes during DB::Open (e.g. OOM, kill -9), it may leave an incomplete rdb directory with only partial column families in the MANIFEST. On restart, the server hits CHECK_PREFIX_MSG and aborts immediately, making the replica unrecoverable. Instead of crashing, detect missing_meta_cf or missing_data_cf, remove the corrupted rdb directory, set db_exist=false, and fall through to create a fresh DB. The replica will re-sync data from the primary. Closes apache#2215
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem
When a replica server crashes during
DB::Open(e.g. OOM,kill -9), it may leave an incomplete rdb directory — the MANIFEST contains only partial column families (e.g. onlypegasus_datawithoutpegasus_meta). On restart, the server hits:and aborts immediately, making the replica unrecoverable.
Root Cause
rdb_pathexists but is incomplete)db_exist = trueand the code enters the "open existing DB" pathcheck_column_families()detectsmissing_meta_cf = trueormissing_data_cf = trueCHECK_PREFIX_MSGcauses a hard abortAn incomplete DB is unusable anyway (cannot read decree, data version, etc. from it), so crashing is unnecessary.
Fix
When
missing_meta_cf || missing_data_cfis detected:rdbdirectorydb_exist = falseThe existing
db_existbranch (LoadLatestOptions etc.) is wrapped inif (db_exist)to avoid operating on the deleted directory.Testing
./run.sh test -m base_api_test:integration_test.write_corrupt_dbandintegration_test.read_corrupt_dbnow pass. This also resolvesbase_api_testfailed due to the failure of a replica server #2283, where the replica dropped on a corrupted DB (get_alive_replica_server_count()returned 2) and cascaded into 49 failures across the whole suite.Related
Closes #2215
Closes #2283