|
1 | 1 | /*****************************************************************************
|
2 | 2 |
|
3 | 3 | Copyright (c) 1997, 2016, Oracle and/or its affiliates. All Rights Reserved.
|
4 |
| -Copyright (c) 2017, 2019, MariaDB Corporation. |
| 4 | +Copyright (c) 2017, 2020, MariaDB Corporation. |
5 | 5 |
|
6 | 6 | This program is free software; you can redistribute it and/or modify it under
|
7 | 7 | the terms of the GNU General Public License as published by the Free Software
|
@@ -47,11 +47,6 @@ dberr_t
|
47 | 47 | recv_find_max_checkpoint(ulint* max_field)
|
48 | 48 | MY_ATTRIBUTE((nonnull, warn_unused_result));
|
49 | 49 |
|
50 |
| -/** Remove records for a corrupted page. |
51 |
| -This function should called when srv_force_recovery > 0. |
52 |
| -@param[in] page_id page id of the corrupted page */ |
53 |
| -ATTRIBUTE_COLD void recv_recover_corrupt_page(page_id_t page_id); |
54 |
| - |
55 | 50 | /** Apply any buffered redo log to a page that was just read from a data file.
|
56 | 51 | @param[in,out] bpage buffer pool page */
|
57 | 52 | ATTRIBUTE_COLD void recv_recover_page(buf_page_t* bpage);
|
@@ -106,14 +101,12 @@ bool recv_sys_add_to_parsing_buf(const byte* log_block, lsn_t scanned_lsn);
|
106 | 101 | to wait merging to file pages.
|
107 | 102 | @param[in] checkpoint_lsn the LSN of the latest checkpoint
|
108 | 103 | @param[in] store whether to store page operations
|
109 |
| -@param[in] available_memory memory to read the redo logs |
110 | 104 | @param[in] apply whether to apply the records
|
111 | 105 | @return whether MLOG_CHECKPOINT record was seen the first time,
|
112 | 106 | or corruption was noticed */
|
113 | 107 | bool recv_parse_log_recs(
|
114 | 108 | lsn_t checkpoint_lsn,
|
115 | 109 | store_t* store,
|
116 |
| - ulint available_memory, |
117 | 110 | bool apply);
|
118 | 111 |
|
119 | 112 | /** Moves the parsing buffer data left to the buffer start */
|
@@ -223,6 +216,10 @@ struct page_recv_t
|
223 | 216 | iterator end() { return NULL; }
|
224 | 217 | bool empty() const { ut_ad(!head == !tail); return !head; }
|
225 | 218 | inline void clear();
|
| 219 | +#ifdef UNIV_DEBUG |
| 220 | + /** Declare the records as freed; @see recv_sys_t::alloc() */ |
| 221 | + inline void free() const; |
| 222 | +#endif |
226 | 223 | } log;
|
227 | 224 |
|
228 | 225 | /** Ignore any earlier redo log records for this page. */
|
@@ -284,8 +281,6 @@ struct recv_sys_t{
|
284 | 281 | record, or 0 if none was parsed */
|
285 | 282 | /** the time when progress was last reported */
|
286 | 283 | time_t progress_time;
|
287 |
| - mem_heap_t* heap; /*!< memory heap of log records and file |
288 |
| - addresses*/ |
289 | 284 |
|
290 | 285 | using map = std::map<const page_id_t, page_recv_t,
|
291 | 286 | std::less<const page_id_t>,
|
@@ -314,6 +309,26 @@ struct recv_sys_t{
|
314 | 309 | /** Last added LSN to pages. */
|
315 | 310 | lsn_t last_stored_lsn;
|
316 | 311 |
|
| 312 | +private: |
| 313 | + /** Maximum number of buffer pool blocks to allocate for redo log records */ |
| 314 | + ulint max_log_blocks; |
| 315 | + |
| 316 | + /** Base node of the redo block list (up to max_log_blocks) |
| 317 | + List elements are linked via buf_block_t::unzip_LRU. */ |
| 318 | + UT_LIST_BASE_NODE_T(buf_block_t) blocks; |
| 319 | +public: |
| 320 | + /** @return the maximum number of buffer pool blocks for log records */ |
| 321 | + ulint max_blocks() const { return max_log_blocks; } |
| 322 | + /** Check whether the number of read redo log blocks exceeds the maximum. |
| 323 | + Store last_stored_lsn if the recovery is not in the last phase. |
| 324 | + @param[in,out] store whether to store page operations |
| 325 | + @return whether the memory is exhausted */ |
| 326 | + inline bool is_memory_exhausted(store_t *store); |
| 327 | + |
| 328 | +#ifdef UNIV_DEBUG |
| 329 | + /** whether all redo log in the current batch has been applied */ |
| 330 | + bool after_apply= false; |
| 331 | +#endif |
317 | 332 | /** Initialize the redo log recovery subsystem. */
|
318 | 333 | void create();
|
319 | 334 |
|
@@ -352,6 +367,32 @@ struct recv_sys_t{
|
352 | 367 | progress_time = time;
|
353 | 368 | return true;
|
354 | 369 | }
|
| 370 | + |
| 371 | + /** Get the memory block for storing recv_t and redo log data |
| 372 | + @param[in] len length of the data to be stored |
| 373 | + @param[in] store_recv whether to store recv_t object |
| 374 | + @return pointer to len bytes of memory (never NULL) */ |
| 375 | + inline byte *alloc(size_t len, bool store_recv= false); |
| 376 | + |
| 377 | +#ifdef UNIV_DEBUG |
| 378 | +private: |
| 379 | + /** Find the buffer pool block that is storing a redo log record. |
| 380 | + @param[in] data pointer to buffer returned by alloc() |
| 381 | + @return redo list element */ |
| 382 | + inline buf_block_t *find_block(const void *data) const; |
| 383 | +public: |
| 384 | + /** Declare a redo log record freed from a buffer pool block. |
| 385 | + @param[in] data pointer to buffer returned by alloc() */ |
| 386 | + inline void free(const void *data) const; |
| 387 | +#endif |
| 388 | + |
| 389 | + /** @return the free length of the latest alloc() block, in bytes */ |
| 390 | + inline size_t get_free_len() const; |
| 391 | + |
| 392 | + /** Remove records for a corrupted page. |
| 393 | + This function should only be called when innodb_force_recovery is set. |
| 394 | + @param page_id corrupted page identifier */ |
| 395 | + ATTRIBUTE_COLD void free_corrupted_page(page_id_t page_id); |
355 | 396 | };
|
356 | 397 |
|
357 | 398 | /** The recovery system */
|
@@ -392,10 +433,4 @@ times! */
|
392 | 433 | roll-forward */
|
393 | 434 | #define RECV_SCAN_SIZE (4U << srv_page_size_shift)
|
394 | 435 |
|
395 |
| -/** This many frames must be left free in the buffer pool when we scan |
396 |
| -the log and store the scanned log records in the buffer pool: we will |
397 |
| -use these free frames to read in pages when we start applying the |
398 |
| -log records to the database. */ |
399 |
| -extern ulint recv_n_pool_free_frames; |
400 |
| - |
401 | 436 | #endif
|
0 commit comments