From 4052fccde9d9533fa9c57749b63ba3cda2c9b134 Mon Sep 17 00:00:00 2001 From: Jay Huh Date: Fri, 25 Sep 2026 16:27:49 -0700 Subject: [PATCH] Enable SecondaryDB in CF-consistency crash tests (#15270) Summary: Pull Request resolved: https://github.com/facebook/rocksdb/pull/15270 D121318547 added SecondaryDB batch-iterator coverage to CfConsistencyStressTest::ContinuouslyVerifyDb(), but the automated CF-consistency crash-test profile never selected test_secondary. Automated runs therefore exercised only the primary DB path while the targeted manual validation used test_secondary=true. Randomize test_secondary between 0 and 1 in cf_consistency_params. Each generated run can now exercise either the existing primary-only path or the SecondaryDB path, preserving both configurations in the continuous matrix. The regression test deterministically verifies both random outcomes. Existing sanitization may still disable SecondaryDB when another selected option is incompatible, such as remote compaction or primary UDI mode. Reviewed By: xingbowang Differential Revision: D121813002 fbshipit-source-id: 4080e2131c1f063d590d24cc0bcee9b9096de63a --- tools/db_crashtest.py | 1 + tools/db_crashtest_test.py | 11 +++++++++++ 2 files changed, 12 insertions(+) diff --git a/tools/db_crashtest.py b/tools/db_crashtest.py index 7d8b9d842f..0b7b2e5999 100644 --- a/tools/db_crashtest.py +++ b/tools/db_crashtest.py @@ -967,6 +967,7 @@ cf_consistency_params = { "disable_wal": lambda: random.randint(0, 1), "reopen": 0, "test_cf_consistency": 1, + "test_secondary": lambda: random.randint(0, 1), # use small value for write_buffer_size so that RocksDB triggers flush # more frequently "write_buffer_size": 1024 * 1024, diff --git a/tools/db_crashtest_test.py b/tools/db_crashtest_test.py index 5a716484ba..a5b076301e 100644 --- a/tools/db_crashtest_test.py +++ b/tools/db_crashtest_test.py @@ -345,6 +345,17 @@ class DBCrashTestTest(unittest.TestCase): command, ) + def test_cf_consistency_randomizes_secondary(self): + db_crashtest = self.load_db_crashtest() + + params = db_crashtest.gen_cmd_params( + self.build_mode_args("blackbox", cf_consistency=True) + ) + + with mock.patch.object(db_crashtest.random, "randint", side_effect=[0, 1]): + self.assertEqual(0, params["test_secondary"]()) + self.assertEqual(1, params["test_secondary"]()) + def test_skip_verifydb_disables_verification_knobs(self): db_crashtest = self.load_db_crashtest()