From 6cb208107e6f3225ee6f0572a49a558c54a3bbe9 Mon Sep 17 00:00:00 2001 From: Oleksandr Byelkin Date: Sun, 19 Jan 2020 14:08:35 +0100 Subject: 5.6.46-86.2 --- storage/tokudb/PerconaFT/src/ydb.cc | 58 ++++++++++++++++++++++++++++++++----- 1 file changed, 50 insertions(+), 8 deletions(-) (limited to 'storage/tokudb/PerconaFT/src/ydb.cc') diff --git a/storage/tokudb/PerconaFT/src/ydb.cc b/storage/tokudb/PerconaFT/src/ydb.cc index 66e7502f625..ca8bf82009b 100644 --- a/storage/tokudb/PerconaFT/src/ydb.cc +++ b/storage/tokudb/PerconaFT/src/ydb.cc @@ -39,6 +39,9 @@ Copyright (c) 2006, 2015, Percona and/or its affiliates. All rights reserved. extern const char *toku_patent_string; const char *toku_copyright_string = "Copyright (c) 2006, 2015, Percona and/or its affiliates. All rights reserved."; + +extern int writing_rollback; + #include #include #include @@ -87,6 +90,10 @@ const char *toku_copyright_string = "Copyright (c) 2006, 2015, Percona and/or it int toku_close_trace_file (void) { return 0; } #endif +extern "C" { + uint force_recovery = 0; +} + // Set when env is panicked, never cleared. static int env_is_panicked = 0; @@ -223,6 +230,9 @@ env_fs_redzone(DB_ENV *env, uint64_t total) { // Check the available space in the file systems used by tokuft and erect barriers when available space gets low. static int env_fs_poller(void *arg) { + if(force_recovery == 6) { + return 0; + } DB_ENV *env = (DB_ENV *) arg; int r; @@ -307,6 +317,9 @@ env_fs_init(DB_ENV *env) { // Initialize the minicron that polls file system space static int env_fs_init_minicron(DB_ENV *env) { + if(force_recovery == 6) { + return 0; + } int r = toku_minicron_setup(&env->i->fs_poller, env->i->fs_poll_time*1000, env_fs_poller, env); if (r == 0) env->i->fs_poller_is_init = true; @@ -709,7 +722,7 @@ static int validate_env(DB_ENV *env, } // Test for fileops directory - if (r == 0) { + if (r == 0 && force_recovery != 6) { path = toku_construct_full_name( 2, env->i->dir, toku_product_name_strings.fileopsdirectory); assert(path); @@ -752,7 +765,7 @@ static int validate_env(DB_ENV *env, } // Test for recovery log - if ((r == 0) && (env->i->open_flags & DB_INIT_LOG)) { + if ((r == 0) && (env->i->open_flags & DB_INIT_LOG) && force_recovery != 6) { // if using transactions, test for existence of log r = ydb_recover_log_exists(env); // return 0 or ENOENT if (expect_newenv && (r != ENOENT)) @@ -813,6 +826,27 @@ unlock_single_process(DB_ENV *env) { // (The set of necessary files is defined in the function validate_env() above.) static int env_open(DB_ENV * env, const char *home, uint32_t flags, int mode) { + + if(force_recovery == 6) { + { + const int len = strlen(toku_product_name_strings.rollback_cachefile); + toku_product_name_strings.rollback_cachefile[len] = '2'; + toku_product_name_strings.rollback_cachefile[len+1] = 0; + } + + { + const int len = strlen(toku_product_name_strings.single_process_lock); + toku_product_name_strings.single_process_lock[len] = '2'; + toku_product_name_strings.single_process_lock[len+1] = 0; + } + + { + const int len = strlen(toku_product_name_strings.environmentdictionary); + toku_product_name_strings.environmentdictionary[len] = '2'; + toku_product_name_strings.environmentdictionary[len+1] = 0; + } + } + HANDLE_PANICKED_ENV(env); int r; bool newenv; // true iff creating a new environment @@ -903,7 +937,7 @@ env_open(DB_ENV * env, const char *home, uint32_t flags, int mode) { bool need_rollback_cachefile; need_rollback_cachefile = false; - if (flags & (DB_INIT_TXN | DB_INIT_LOG)) { + if (flags & (DB_INIT_TXN | DB_INIT_LOG) && force_recovery != 6) { need_rollback_cachefile = true; } @@ -916,7 +950,7 @@ env_open(DB_ENV * env, const char *home, uint32_t flags, int mode) { r = ydb_maybe_upgrade_env(env, &last_lsn_of_clean_shutdown_read_from_log, &upgrade_in_progress); if (r!=0) goto cleanup; - if (upgrade_in_progress) { + if (upgrade_in_progress || force_recovery == 6) { // Delete old rollback file. There was a clean shutdown, so it has nothing useful, // and there is no value in upgrading it. It is simpler to just create a new one. char* rollback_filename = toku_construct_full_name(2, env->i->dir, toku_product_name_strings.rollback_cachefile); @@ -934,9 +968,13 @@ env_open(DB_ENV * env, const char *home, uint32_t flags, int mode) { unused_flags &= ~DB_INIT_TXN & ~DB_INIT_LOG; + if(force_recovery == 6) { + flags |= DB_INIT_LOG | DB_INIT_TXN; + } + // do recovery only if there exists a log and recovery is requested // otherwise, a log is created when the logger is opened later - if (!newenv) { + if (!newenv && force_recovery == 0) { if (flags & DB_INIT_LOG) { // the log does exist if (flags & DB_RECOVER) { @@ -1005,7 +1043,7 @@ env_open(DB_ENV * env, const char *home, uint32_t flags, int mode) { assert (using_txns); toku_logger_set_cachetable(env->i->logger, env->i->cachetable); if (!toku_logger_rollback_is_open(env->i->logger)) { - bool create_new_rollback_file = newenv | upgrade_in_progress; + bool create_new_rollback_file = newenv | upgrade_in_progress | (force_recovery == 6); r = toku_logger_open_rollback(env->i->logger, env->i->cachetable, create_new_rollback_file); if (r != 0) { r = toku_ydb_do_error(env, r, "Cant open rollback\n"); @@ -1024,6 +1062,7 @@ env_open(DB_ENV * env, const char *home, uint32_t flags, int mode) { assert_zero(r); r = toku_db_use_builtin_key_cmp(env->i->persistent_environment); assert_zero(r); + writing_rollback++; r = toku_db_open_iname(env->i->persistent_environment, txn, toku_product_name_strings.environmentdictionary, DB_CREATE, mode); if (r != 0) { r = toku_ydb_do_error(env, r, "Cant open persistent env\n"); @@ -1056,6 +1095,7 @@ env_open(DB_ENV * env, const char *home, uint32_t flags, int mode) { assert_zero(r); } capture_persistent_env_contents(env, txn); + writing_rollback--; } { r = toku_db_create(&env->i->directory, env, 0); @@ -1074,8 +1114,10 @@ env_open(DB_ENV * env, const char *home, uint32_t flags, int mode) { txn = NULL; } cp = toku_cachetable_get_checkpointer(env->i->cachetable); - r = toku_checkpoint(cp, env->i->logger, NULL, NULL, NULL, NULL, STARTUP_CHECKPOINT); - assert_zero(r); + if (!force_recovery) { + r = toku_checkpoint(cp, env->i->logger, NULL, NULL, NULL, NULL, STARTUP_CHECKPOINT); + } + writing_rollback--; env_fs_poller(env); // get the file system state at startup r = env_fs_init_minicron(env); if (r != 0) { -- cgit v1.2.1