| 1 | /* -*- mode: C++; c-basic-offset: 4; indent-tabs-mode: nil -*- */ |
| 2 | // vim: ft=cpp:expandtab:ts=8:sw=4:softtabstop=4: |
| 3 | #ident "$Id$" |
| 4 | /*====== |
| 5 | This file is part of PerconaFT. |
| 6 | |
| 7 | |
| 8 | Copyright (c) 2006, 2015, Percona and/or its affiliates. All rights reserved. |
| 9 | |
| 10 | PerconaFT is free software: you can redistribute it and/or modify |
| 11 | it under the terms of the GNU General Public License, version 2, |
| 12 | as published by the Free Software Foundation. |
| 13 | |
| 14 | PerconaFT is distributed in the hope that it will be useful, |
| 15 | but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 16 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 17 | GNU General Public License for more details. |
| 18 | |
| 19 | You should have received a copy of the GNU General Public License |
| 20 | along with PerconaFT. If not, see <http://www.gnu.org/licenses/>. |
| 21 | |
| 22 | ---------------------------------------- |
| 23 | |
| 24 | PerconaFT is free software: you can redistribute it and/or modify |
| 25 | it under the terms of the GNU Affero General Public License, version 3, |
| 26 | as published by the Free Software Foundation. |
| 27 | |
| 28 | PerconaFT is distributed in the hope that it will be useful, |
| 29 | but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 30 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 31 | GNU Affero General Public License for more details. |
| 32 | |
| 33 | You should have received a copy of the GNU Affero General Public License |
| 34 | along with PerconaFT. If not, see <http://www.gnu.org/licenses/>. |
| 35 | ======= */ |
| 36 | |
| 37 | #ident "Copyright (c) 2006, 2015, Percona and/or its affiliates. All rights reserved." |
| 38 | |
| 39 | #pragma once |
| 40 | |
| 41 | #include <db.h> |
| 42 | #include <errno.h> |
| 43 | |
| 44 | #include "portability/memory.h" |
| 45 | #include "portability/toku_portability.h" |
| 46 | |
| 47 | #include "ft/comparator.h" |
| 48 | #include "ft/ft-ops.h" |
| 49 | #include "util/x1764.h" |
| 50 | |
| 51 | typedef void (*prepared_txn_callback_t)(DB_ENV *env, struct tokutxn *txn); |
| 52 | typedef void (*keep_cachetable_callback_t)(DB_ENV *env, struct cachetable *ct); |
| 53 | |
| 54 | // Run tokuft recovery from the log |
| 55 | // Returns 0 if success |
| 56 | int tokuft_recover(DB_ENV *env, |
| 57 | prepared_txn_callback_t prepared_txn_callback, |
| 58 | keep_cachetable_callback_t keep_cachetable_callback, |
| 59 | struct tokulogger *logger, |
| 60 | const char *env_dir, |
| 61 | const char *log_dir, |
| 62 | ft_compare_func bt_compare, |
| 63 | ft_update_func update_function, |
| 64 | generate_row_for_put_func generate_row_for_put, |
| 65 | generate_row_for_del_func generate_row_for_del, |
| 66 | size_t cachetable_size); |
| 67 | |
| 68 | // Effect: Check the tokuft logs to determine whether or not we need to run recovery. |
| 69 | // If the log is empty or if there is a clean shutdown at the end of the log, then we |
| 70 | // don't need to run recovery. |
| 71 | // Returns: true if we need recovery, otherwise false. |
| 72 | int tokuft_needs_recovery(const char *logdir, bool ignore_empty_log); |
| 73 | |
| 74 | // Return 0 if recovery log exists, ENOENT if log is missing |
| 75 | int tokuft_recover_log_exists(const char * log_dir); |
| 76 | |
| 77 | // For test only - set callbacks for recovery testing |
| 78 | void toku_recover_set_callback (void (*)(void*), void*); |
| 79 | void toku_recover_set_callback2 (void (*)(void*), void*); |
| 80 | |
| 81 | extern int tokuft_recovery_trace; |
| 82 | |
| 83 | int toku_recover_lock (const char *lock_dir, int *lockfd); |
| 84 | |
| 85 | int toku_recover_unlock(int lockfd); |
| 86 | |