| 1 | /***************************************************************************** |
| 2 | |
| 3 | Copyright (c) 2016, 2018, MariaDB Corporation. |
| 4 | |
| 5 | This program is free software; you can redistribute it and/or modify it under |
| 6 | the terms of the GNU General Public License as published by the Free Software |
| 7 | Foundation; version 2 of the License. |
| 8 | |
| 9 | This program is distributed in the hope that it will be useful, but WITHOUT |
| 10 | ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS |
| 11 | FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. |
| 12 | |
| 13 | You should have received a copy of the GNU General Public License along with |
| 14 | this program; if not, write to the Free Software Foundation, Inc., |
| 15 | 51 Franklin Street, Suite 500, Boston, MA 02110-1335 USA |
| 16 | |
| 17 | *****************************************************************************/ |
| 18 | |
| 19 | /**************************************************//** |
| 20 | @file include/dict0defrag_bg.h |
| 21 | Code used for background table and index |
| 22 | defragmentation |
| 23 | |
| 24 | Created 25/08/2016 Jan Lindström |
| 25 | *******************************************************/ |
| 26 | |
| 27 | #ifndef dict0defrag_bg_h |
| 28 | #define dict0defrag_bg_h |
| 29 | |
| 30 | #include "univ.i" |
| 31 | |
| 32 | #include "dict0types.h" |
| 33 | #include "os0event.h" |
| 34 | #include "os0thread.h" |
| 35 | |
| 36 | /*****************************************************************//** |
| 37 | Initialize the defrag pool, called once during thread initialization. */ |
| 38 | void |
| 39 | dict_defrag_pool_init(void); |
| 40 | /*========================*/ |
| 41 | |
| 42 | /*****************************************************************//** |
| 43 | Free the resources occupied by the defrag pool, called once during |
| 44 | thread de-initialization. */ |
| 45 | void |
| 46 | dict_defrag_pool_deinit(void); |
| 47 | /*==========================*/ |
| 48 | |
| 49 | /*****************************************************************//** |
| 50 | Add an index in a table to the defrag pool, which is processed by the |
| 51 | background stats gathering thread. Only the table id and index id are |
| 52 | added to the list, so the table can be closed after being enqueued and |
| 53 | it will be opened when needed. If the table or index does not exist later |
| 54 | (has been DROPped), then it will be removed from the pool and skipped. */ |
| 55 | void |
| 56 | dict_stats_defrag_pool_add( |
| 57 | /*=======================*/ |
| 58 | const dict_index_t* index); /*!< in: table to add */ |
| 59 | |
| 60 | /*****************************************************************//** |
| 61 | Delete a given index from the auto defrag pool. */ |
| 62 | void |
| 63 | dict_stats_defrag_pool_del( |
| 64 | /*=======================*/ |
| 65 | const dict_table_t* table, /*!<in: if given, remove |
| 66 | all entries for the table */ |
| 67 | const dict_index_t* index); /*!< in: index to remove */ |
| 68 | |
| 69 | /*****************************************************************//** |
| 70 | Get the first index that has been added for updating persistent defrag |
| 71 | stats and eventually save its stats. */ |
| 72 | void |
| 73 | dict_defrag_process_entries_from_defrag_pool(); |
| 74 | /*===========================================*/ |
| 75 | |
| 76 | /*********************************************************************//** |
| 77 | Save defragmentation result. |
| 78 | @return DB_SUCCESS or error code */ |
| 79 | dberr_t |
| 80 | dict_stats_save_defrag_summary( |
| 81 | /*============================*/ |
| 82 | dict_index_t* index) /*!< in: index */ |
| 83 | MY_ATTRIBUTE((warn_unused_result)); |
| 84 | |
| 85 | /*********************************************************************//** |
| 86 | Save defragmentation stats for a given index. |
| 87 | @return DB_SUCCESS or error code */ |
| 88 | dberr_t |
| 89 | dict_stats_save_defrag_stats( |
| 90 | /*============================*/ |
| 91 | dict_index_t* index); /*!< in: index */ |
| 92 | #endif /* dict0defrag_bg_h */ |
| 93 | |