diff --git a/src/ctrip_swap_iter.c b/src/ctrip_swap_iter.c index 2850d1d75c2..9b9db6c946d 100644 --- a/src/ctrip_swap_iter.c +++ b/src/ctrip_swap_iter.c @@ -290,9 +290,6 @@ rocksIter *rocksCreateIter(rocks *rocks, redisDb *db) { rocksdb_options_t* cf_opts[CF_COUNT], *db_opts; db_opts = rocksdb_options_create_copy(rocks->db_opts); rocksdb_options_set_db_log_dir(db_opts, ""); - /* disable background jobs since child have no background threads */ - rocksdb_options_set_max_background_jobs(db_opts, 0); - rocksdb_options_set_max_background_compactions(db_opts, 0); for (i = 0; i < CF_COUNT; i++) { /* disable cf cache since cache is useless for iterator */ cf_opts[i] = rocksdb_options_create_copy(rocks->cf_opts[i]); @@ -303,10 +300,12 @@ rocksIter *rocksCreateIter(rocks *rocks, redisDb *db) { } char *errs[CF_COUNT] = {NULL}; - rocksdb_t* checkpoint_db = rocksdb_open_column_families(db_opts, + /* Open checkpoint read-only so child iteration never schedules bg work to + avoid potential rocksdb hanging. */ + rocksdb_t* checkpoint_db = rocksdb_open_for_read_only_column_families(db_opts, server.rocksdb_rdb_checkpoint_dir, CF_COUNT, swap_cf_names, (const rocksdb_options_t *const *)cf_opts, - it->cf_handles, errs); + it->cf_handles, 0, errs); for (i = 0; i < CF_COUNT; i++) rocksdb_options_destroy(cf_opts[i]); rocksdb_options_destroy(db_opts); @@ -691,4 +690,3 @@ int swapIterTest(int argc, char *argv[], int accurate) { #endif -