@ -657,7 +657,7 @@ class BackupEngineTest : public testing::Test {
engine_options_ - > max_background_operations = 7 ;
// delete old files in db
DestroyDB ( dbname_ , options_ ) ;
DestroyDBWithoutCheck ( dbname_ , options_ ) ;
// delete old LATEST_BACKUP file, which some tests create for compatibility
// testing.
@ -993,6 +993,12 @@ class BackupEngineTest : public testing::Test {
Options options_ ;
protected :
void DestroyDBWithoutCheck ( const std : : string & dbname ,
const Options & options ) {
// DestroyDB may fail because the db might not be existed for some tests
DestroyDB ( dbname , options ) . PermitUncheckedError ( ) ;
}
std : : unique_ptr < BackupEngineOptions > engine_options_ ;
} ; // BackupEngineTest
@ -1033,7 +1039,7 @@ TEST_F(BackupEngineTest, FileCollision) {
// If the db directory has been cleaned up, it is sensitive to file
// collision.
ASSERT_OK ( DestroyDB ( dbname_ , options_ ) ) ;
DestroyDBWithoutCheck ( dbname_ , options_ ) ;
// open fresh DB, but old backups present
OpenDBAndBackupEngine ( false /* destroy_old_data */ , false /* dummy */ ,
@ -1054,7 +1060,7 @@ TEST_F(BackupEngineTest, FileCollision) {
CloseDBAndBackupEngine ( ) ;
// delete old data
ASSERT_OK ( DestroyDB ( dbname_ , options_ ) ) ;
DestroyDBWithoutCheck ( dbname_ , options_ ) ;
}
}
@ -1099,7 +1105,7 @@ TEST_P(BackupEngineTestWithParam, OfflineIntegrationTest) {
// second iter -- don't flush before backup
for ( int iter = 0 ; iter < 2 ; + + iter ) {
// delete old data
DestroyDB ( dbname_ , options_ ) ;
DestroyDBWithoutCheck ( dbname_ , options_ ) ;
bool destroy_data = true ;
// every iteration --
@ -1118,7 +1124,7 @@ TEST_P(BackupEngineTestWithParam, OfflineIntegrationTest) {
ASSERT_OK ( backup_engine_ - > CreateNewBackup ( db_ . get ( ) , iter = = 0 ) )
< < " iter: " < < iter < < " , idx: " < < i ;
CloseDBAndBackupEngine ( ) ;
DestroyDB ( dbname_ , options_ ) ;
DestroyDBWithoutCheck ( dbname_ , options_ ) ;
// ---- make sure it's empty ----
DB * db = OpenDB ( ) ;
@ -1146,7 +1152,7 @@ TEST_P(BackupEngineTestWithParam, OnlineIntegrationTest) {
const int max_key = keys_iteration * 4 + 10 ;
Random rnd ( 7 ) ;
// delete old data
DestroyDB ( dbname_ , options_ ) ;
DestroyDBWithoutCheck ( dbname_ , options_ ) ;
// TODO: Implement & test db_paths support in backup (not supported in
// restore)
@ -1171,7 +1177,7 @@ TEST_P(BackupEngineTestWithParam, OnlineIntegrationTest) {
}
// close and destroy
CloseDBAndBackupEngine ( ) ;
DestroyDB ( dbname_ , options_ ) ;
DestroyDBWithoutCheck ( dbname_ , options_ ) ;
// ---- make sure it's empty ----
DB * db = OpenDB ( ) ;
@ -1547,7 +1553,7 @@ TEST_F(BackupEngineTest, TableFileCorruptedBeforeBackup) {
CloseDBAndBackupEngine ( ) ;
// delete old files in db
ASSERT_OK ( DestroyDB ( dbname_ , options_ ) ) ;
DestroyDBWithoutCheck ( dbname_ , options_ ) ;
// Enable table file checksum in DB manifest
options_ . file_checksum_gen_factory = GetFileChecksumGenCrc32cFactory ( ) ;
@ -1580,7 +1586,7 @@ TEST_F(BackupEngineTest, BlobFileCorruptedBeforeBackup) {
CloseDBAndBackupEngine ( ) ;
// delete old files in db
ASSERT_OK ( DestroyDB ( dbname_ , options_ ) ) ;
DestroyDBWithoutCheck ( dbname_ , options_ ) ;
// Enable file checksum in DB manifest
options_ . file_checksum_gen_factory = GetFileChecksumGenCrc32cFactory ( ) ;
@ -1614,7 +1620,7 @@ TEST_P(BackupEngineTestWithParam, TableFileCorruptedBeforeBackup) {
CloseDBAndBackupEngine ( ) ;
// delete old files in db
ASSERT_OK ( DestroyDB ( dbname_ , options_ ) ) ;
DestroyDBWithoutCheck ( dbname_ , options_ ) ;
// Enable table checksums in DB manifest
options_ . file_checksum_gen_factory = GetFileChecksumGenCrc32cFactory ( ) ;
@ -1643,7 +1649,7 @@ TEST_P(BackupEngineTestWithParam, BlobFileCorruptedBeforeBackup) {
CloseDBAndBackupEngine ( ) ;
// delete old files in db
ASSERT_OK ( DestroyDB ( dbname_ , options_ ) ) ;
DestroyDBWithoutCheck ( dbname_ , options_ ) ;
// Enable blob file checksums in DB manifest
options_ . file_checksum_gen_factory = GetFileChecksumGenCrc32cFactory ( ) ;
@ -1695,7 +1701,7 @@ TEST_F(BackupEngineTest, TableFileWithoutDbChecksumCorruptedDuringBackup) {
CloseDBAndBackupEngine ( ) ;
// delete old files in db
ASSERT_OK ( DestroyDB ( dbname_ , options_ ) ) ;
DestroyDBWithoutCheck ( dbname_ , options_ ) ;
}
TEST_F ( BackupEngineTest , TableFileWithDbChecksumCorruptedDuringBackup ) {
@ -1734,7 +1740,7 @@ TEST_F(BackupEngineTest, TableFileWithDbChecksumCorruptedDuringBackup) {
CloseDBAndBackupEngine ( ) ;
// delete old files in db
ASSERT_OK ( DestroyDB ( dbname_ , options_ ) ) ;
DestroyDBWithoutCheck ( dbname_ , options_ ) ;
}
}
@ -2208,7 +2214,7 @@ TEST_F(BackupEngineTest, TableFileCorruptionBeforeIncremental) {
}
CloseDBAndBackupEngine ( ) ;
ASSERT_OK ( DestroyDB ( dbname_ , options_ ) ) ;
DestroyDBWithoutCheck ( dbname_ , options_ ) ;
}
}
}
@ -2273,7 +2279,7 @@ TEST_F(BackupEngineTest, FileSizeForIncremental) {
// Even though we have "the same" DB state as backup 1, we need
// to restore to recreate the same conditions as later restore.
db_ . reset ( ) ;
ASSERT_OK ( DestroyDB ( dbname_ , options_ ) ) ;
DestroyDBWithoutCheck ( dbname_ , options_ ) ;
ASSERT_OK ( backup_engine_ - > RestoreDBFromBackup ( 1 , dbname_ , dbname_ ) ) ;
CloseDBAndBackupEngine ( ) ;
@ -2294,7 +2300,7 @@ TEST_F(BackupEngineTest, FileSizeForIncremental) {
// Restore backup 1 (again)
db_ . reset ( ) ;
ASSERT_OK ( DestroyDB ( dbname_ , options_ ) ) ;
DestroyDBWithoutCheck ( dbname_ , options_ ) ;
ASSERT_OK ( backup_engine_ - > RestoreDBFromBackup ( 1 , dbname_ , dbname_ ) ) ;
CloseDBAndBackupEngine ( ) ;
@ -2332,7 +2338,7 @@ TEST_F(BackupEngineTest, FileSizeForIncremental) {
EXPECT_EQ ( children . size ( ) , 3U ) ; // Another SST added
}
CloseDBAndBackupEngine ( ) ;
ASSERT_OK ( DestroyDB ( dbname_ , options_ ) ) ;
DestroyDBWithoutCheck ( dbname_ , options_ ) ;
ROCKSDB_NAMESPACE : : SyncPoint : : GetInstance ( ) - > DisableProcessing ( ) ;
ROCKSDB_NAMESPACE : : SyncPoint : : GetInstance ( ) - > ClearAllCallBacks ( ) ;
}
@ -2609,7 +2615,7 @@ TEST_P(BackupEngineRateLimitingTestWithParam, RateLimiting) {
// destroy old data
Options options ;
options . env = special_env . get ( ) ;
DestroyDB ( dbname_ , options ) ;
DestroyDBWithoutCheck ( dbname_ , options ) ;
if ( custom_rate_limiter ) {
std : : shared_ptr < RateLimiter > backup_rate_limiter =
@ -2699,7 +2705,7 @@ TEST_P(BackupEngineRateLimitingTestWithParam, RateLimitingVerifyBackup) {
Options options ;
options . env = special_env . get ( ) ;
DestroyDB ( dbname_ , options ) ;
DestroyDBWithoutCheck ( dbname_ , options ) ;
// Rate limiter uses `CondVar::TimedWait()`, which does not have access to the
// `Env` to advance its time according to the fake wait duration. The
// workaround is to install a callback that advance the `Env`'s mock time.
@ -2743,7 +2749,7 @@ TEST_P(BackupEngineRateLimitingTestWithParam, RateLimitingVerifyBackup) {
CloseDBAndBackupEngine ( ) ;
AssertBackupConsistency ( backup_id , 0 , 10000 , 10010 ) ;
DestroyDB ( dbname_ , options ) ;
DestroyDBWithoutCheck ( dbname_ , options ) ;
ROCKSDB_NAMESPACE : : SyncPoint : : GetInstance ( ) - > DisableProcessing ( ) ;
ROCKSDB_NAMESPACE : : SyncPoint : : GetInstance ( ) - > ClearCallBack (
@ -2760,7 +2766,7 @@ TEST_P(BackupEngineRateLimitingTestWithParam, RateLimitingChargeReadInBackup) {
10 /* fairness */ , RateLimiter : : Mode : : kWritesOnly /* mode */ ) ) ;
engine_options_ - > backup_rate_limiter = backup_rate_limiter ;
DestroyDB ( dbname_ , Options ( ) ) ;
DestroyDBWithoutCheck ( dbname_ , Options ( ) ) ;
OpenDBAndBackupEngine ( true /* destroy_old_data */ , false /* dummy */ ,
kShareWithChecksum /* shared_option */ ) ;
FillDB ( db_ . get ( ) , 0 , 10 ) ;
@ -2784,7 +2790,7 @@ TEST_P(BackupEngineRateLimitingTestWithParam, RateLimitingChargeReadInBackup) {
total_bytes_through_with_no_read_charged ) ;
CloseDBAndBackupEngine ( ) ;
AssertBackupConsistency ( 1 , 0 , 10 , 20 ) ;
DestroyDB ( dbname_ , Options ( ) ) ;
DestroyDBWithoutCheck ( dbname_ , Options ( ) ) ;
}
TEST_P ( BackupEngineRateLimitingTestWithParam , RateLimitingChargeReadInRestore ) {
@ -2798,20 +2804,20 @@ TEST_P(BackupEngineRateLimitingTestWithParam, RateLimitingChargeReadInRestore) {
10 /* fairness */ , RateLimiter : : Mode : : kWritesOnly /* mode */ ) ) ;
engine_options_ - > restore_rate_limiter = restore_rate_limiter ;
DestroyDB ( dbname_ , Options ( ) ) ;
DestroyDBWithoutCheck ( dbname_ , Options ( ) ) ;
OpenDBAndBackupEngine ( true /* destroy_old_data */ ) ;
FillDB ( db_ . get ( ) , 0 , 10 ) ;
ASSERT_OK ( backup_engine_ - > CreateNewBackup ( db_ . get ( ) ,
false /* flush_before_backup */ ) ) ;
CloseDBAndBackupEngine ( ) ;
DestroyDB ( dbname_ , Options ( ) ) ;
DestroyDBWithoutCheck ( dbname_ , Options ( ) ) ;
OpenBackupEngine ( false /* destroy_old_data */ ) ;
ASSERT_OK ( backup_engine_ - > RestoreDBFromLatestBackup ( dbname_ , dbname_ ) ) ;
std : : int64_t total_bytes_through_with_no_read_charged =
restore_rate_limiter - > GetTotalBytesThrough ( ) ;
CloseBackupEngine ( ) ;
DestroyDB ( dbname_ , Options ( ) ) ;
DestroyDBWithoutCheck ( dbname_ , Options ( ) ) ;
restore_rate_limiter . reset ( NewGenericRateLimiter (
restore_rate_limiter_limit , 100 * 1000 /* refill_period_us */ ,
@ -2826,7 +2832,7 @@ TEST_P(BackupEngineRateLimitingTestWithParam, RateLimitingChargeReadInRestore) {
total_bytes_through_with_no_read_charged * 2 ) ;
CloseBackupEngine ( ) ;
AssertBackupConsistency ( 1 , 0 , 10 , 20 ) ;
DestroyDB ( dbname_ , Options ( ) ) ;
DestroyDBWithoutCheck ( dbname_ , Options ( ) ) ;
}
TEST_P ( BackupEngineRateLimitingTestWithParam ,
@ -2840,7 +2846,7 @@ TEST_P(BackupEngineRateLimitingTestWithParam,
10 /* fairness */ , RateLimiter : : Mode : : kAllIo /* mode */ ) ) ;
engine_options_ - > backup_rate_limiter = backup_rate_limiter ;
DestroyDB ( dbname_ , Options ( ) ) ;
DestroyDBWithoutCheck ( dbname_ , Options ( ) ) ;
OpenDBAndBackupEngine ( true /* destroy_old_data */ ) ;
FillDB ( db_ . get ( ) , 0 , 10 ) ;
ASSERT_OK ( backup_engine_ - > CreateNewBackup ( db_ . get ( ) ,
@ -2857,7 +2863,7 @@ TEST_P(BackupEngineRateLimitingTestWithParam,
EXPECT_GT ( engine_options_ - > backup_rate_limiter - > GetTotalBytesThrough ( ) ,
total_bytes_through_before_initialize ) ;
CloseDBAndBackupEngine ( ) ;
DestroyDB ( dbname_ , Options ( ) ) ;
DestroyDBWithoutCheck ( dbname_ , Options ( ) ) ;
}
class BackupEngineRateLimitingTestWithParam2
@ -2908,7 +2914,7 @@ TEST_P(BackupEngineRateLimitingTestWithParam2,
} ) ;
ROCKSDB_NAMESPACE : : SyncPoint : : GetInstance ( ) - > EnableProcessing ( ) ;
DestroyDB ( dbname_ , Options ( ) ) ;
DestroyDBWithoutCheck ( dbname_ , Options ( ) ) ;
OpenDBAndBackupEngine ( true /* destroy_old_data */ , false /* dummy */ ,
kShareWithChecksum /* shared_option */ ) ;
@ -2954,7 +2960,7 @@ TEST_P(BackupEngineRateLimitingTestWithParam2,
total_bytes_through_before_initialize ) ;
CloseDBAndBackupEngine ( ) ;
DestroyDB ( dbname_ , Options ( ) ) ;
DestroyDBWithoutCheck ( dbname_ , Options ( ) ) ;
OpenBackupEngine ( false /* destroy_old_data */ ) ;
int64_t total_bytes_through_before_restore =
engine_options_ - > restore_rate_limiter - > GetTotalBytesThrough ( ) ;
@ -2965,7 +2971,7 @@ TEST_P(BackupEngineRateLimitingTestWithParam2,
total_bytes_through_before_restore ) ;
CloseBackupEngine ( ) ;
DestroyDB ( dbname_ , Options ( ) ) ;
DestroyDBWithoutCheck ( dbname_ , Options ( ) ) ;
ROCKSDB_NAMESPACE : : SyncPoint : : GetInstance ( ) - > DisableProcessing ( ) ;
ROCKSDB_NAMESPACE : : SyncPoint : : GetInstance ( ) - > ClearCallBack (
@ -2975,14 +2981,14 @@ TEST_P(BackupEngineRateLimitingTestWithParam2,
# endif // !defined(ROCKSDB_VALGRIND_RUN) || defined(ROCKSDB_FULL_VALGRIND_RUN)
TEST_F ( BackupEngineTest , ReadOnlyBackupEngine ) {
DestroyDB ( dbname_ , options_ ) ;
DestroyDBWithoutCheck ( dbname_ , options_ ) ;
OpenDBAndBackupEngine ( true ) ;
FillDB ( db_ . get ( ) , 0 , 100 ) ;
ASSERT_OK ( backup_engine_ - > CreateNewBackup ( db_ . get ( ) , true ) ) ;
FillDB ( db_ . get ( ) , 100 , 200 ) ;
ASSERT_OK ( backup_engine_ - > CreateNewBackup ( db_ . get ( ) , true ) ) ;
CloseDBAndBackupEngine ( ) ;
DestroyDB ( dbname_ , options_ ) ;
DestroyDBWithoutCheck ( dbname_ , options_ ) ;
engine_options_ - > destroy_old_data = false ;
test_backup_fs_ - > ClearWrittenFiles ( ) ;
@ -3007,7 +3013,7 @@ TEST_F(BackupEngineTest, ReadOnlyBackupEngine) {
}
TEST_F ( BackupEngineTest , OpenBackupAsReadOnlyDB ) {
DestroyDB ( dbname_ , options_ ) ;
DestroyDBWithoutCheck ( dbname_ , options_ ) ;
options_ . write_dbid_to_manifest = false ;
OpenDBAndBackupEngine ( true ) ;
@ -3020,7 +3026,7 @@ TEST_F(BackupEngineTest, OpenBackupAsReadOnlyDB) {
FillDB ( db_ . get ( ) , 100 , 200 ) ;
ASSERT_OK ( backup_engine_ - > CreateNewBackup ( db_ . get ( ) , /*flush*/ false ) ) ;
db_ . reset ( ) ; // CloseDB
DestroyDB ( dbname_ , options_ ) ;
DestroyDBWithoutCheck ( dbname_ , options_ ) ;
BackupInfo backup_info ;
// First, check that we get empty fields without include_file_details
ASSERT_OK ( backup_engine_ - > GetBackupInfo ( /*id*/ 1U , & backup_info ,
@ -3073,7 +3079,7 @@ TEST_F(BackupEngineTest, OpenBackupAsReadOnlyDB) {
}
TEST_F ( BackupEngineTest , ProgressCallbackDuringBackup ) {
DestroyDB ( dbname_ , options_ ) ;
DestroyDBWithoutCheck ( dbname_ , options_ ) ;
// Too big for this small DB
engine_options_ - > callback_trigger_interval_size = 100000 ;
OpenDBAndBackupEngine ( true ) ;
@ -3093,11 +3099,11 @@ TEST_F(BackupEngineTest, ProgressCallbackDuringBackup) {
[ & is_callback_invoked ] ( ) { is_callback_invoked = true ; } ) ) ;
ASSERT_TRUE ( is_callback_invoked ) ;
CloseDBAndBackupEngine ( ) ;
DestroyDB ( dbname_ , options_ ) ;
DestroyDBWithoutCheck ( dbname_ , options_ ) ;
}
TEST_F ( BackupEngineTest , GarbageCollectionBeforeBackup ) {
DestroyDB ( dbname_ , options_ ) ;
DestroyDBWithoutCheck ( dbname_ , options_ ) ;
OpenDBAndBackupEngine ( true ) ;
ASSERT_OK ( backup_chroot_env_ - > CreateDirIfMissing ( backupdir_ + " /shared " ) ) ;
@ -3151,7 +3157,7 @@ TEST_F(BackupEngineTest, EnvFailures) {
// Read from meta-file failure
{
DestroyDB ( dbname_ , options_ ) ;
DestroyDBWithoutCheck ( dbname_ , options_ ) ;
OpenDBAndBackupEngine ( true ) ;
FillDB ( db_ . get ( ) , 0 , 100 ) ;
ASSERT_OK ( backup_engine_ - > CreateNewBackup ( db_ . get ( ) , true ) ) ;
@ -3176,7 +3182,7 @@ TEST_F(BackupEngineTest, EnvFailures) {
// Verify manifest can roll while a backup is being created with the old
// manifest.
TEST_F ( BackupEngineTest , ChangeManifestDuringBackupCreation ) {
DestroyDB ( dbname_ , options_ ) ;
DestroyDBWithoutCheck ( dbname_ , options_ ) ;
options_ . max_manifest_file_size = 0 ; // always rollover manifest for file add
OpenDBAndBackupEngine ( true ) ;
FillDB ( db_ . get ( ) , 0 , 100 , kAutoFlushOnly ) ;
@ -3213,7 +3219,7 @@ TEST_F(BackupEngineTest, ChangeManifestDuringBackupCreation) {
ASSERT_TRUE ( db_chroot_env_ - > FileExists ( prev_manifest_path ) . IsNotFound ( ) ) ;
CloseDBAndBackupEngine ( ) ;
DestroyDB ( dbname_ , options_ ) ;
DestroyDBWithoutCheck ( dbname_ , options_ ) ;
AssertBackupConsistency ( 0 , 0 , 100 ) ;
}
@ -3265,7 +3271,7 @@ TEST_F(BackupEngineTest, BackupWithMetadata) {
ASSERT_EQ ( std : : to_string ( i ) , backup_info . app_metadata ) ;
}
CloseDBAndBackupEngine ( ) ;
DestroyDB ( dbname_ , options_ ) ;
DestroyDBWithoutCheck ( dbname_ , options_ ) ;
}
TEST_F ( BackupEngineTest , BinaryMetadata ) {
@ -3283,7 +3289,7 @@ TEST_F(BackupEngineTest, BinaryMetadata) {
ASSERT_EQ ( 1 , backup_infos . size ( ) ) ;
ASSERT_EQ ( binaryMetadata , backup_infos [ 0 ] . app_metadata ) ;
CloseDBAndBackupEngine ( ) ;
DestroyDB ( dbname_ , options_ ) ;
DestroyDBWithoutCheck ( dbname_ , options_ ) ;
}
TEST_F ( BackupEngineTest , MetadataTooLarge ) {
@ -3292,7 +3298,7 @@ TEST_F(BackupEngineTest, MetadataTooLarge) {
ASSERT_NOK (
backup_engine_ - > CreateNewBackupWithMetadata ( db_ . get ( ) , largeMetadata ) ) ;
CloseDBAndBackupEngine ( ) ;
DestroyDB ( dbname_ , options_ ) ;
DestroyDBWithoutCheck ( dbname_ , options_ ) ;
}
TEST_F ( BackupEngineTest , MetaSchemaVersion2_SizeCorruption ) {
@ -3734,7 +3740,7 @@ TEST_F(BackupEngineTest, IgnoreLimitBackupsOpenedWhenNotReadOnly) {
ASSERT_EQ ( 2 , backup_infos [ 1 ] . backup_id ) ;
ASSERT_EQ ( 4 , backup_infos [ 2 ] . backup_id ) ;
CloseDBAndBackupEngine ( ) ;
DestroyDB ( dbname_ , options_ ) ;
DestroyDBWithoutCheck ( dbname_ , options_ ) ;
}
TEST_F ( BackupEngineTest , CreateWhenLatestBackupCorrupted ) {
@ -3942,7 +3948,7 @@ TEST_F(BackupEngineTest, BackgroundThreadCpuPriority) {
ROCKSDB_NAMESPACE : : SyncPoint : : GetInstance ( ) - > DisableProcessing ( ) ;
ROCKSDB_NAMESPACE : : SyncPoint : : GetInstance ( ) - > ClearAllCallBacks ( ) ;
CloseDBAndBackupEngine ( ) ;
DestroyDB ( dbname_ , options_ ) ;
DestroyDBWithoutCheck ( dbname_ , options_ ) ;
}
// Populates `*total_size` with the size of all files under `backup_dir`.