MySQL 9.1.0
Source Code Documentation
arch0arch.h
Go to the documentation of this file.
1/*****************************************************************************
2
3Copyright (c) 2017, 2024, Oracle and/or its affiliates.
4
5This program is free software; you can redistribute it and/or modify it under
6the terms of the GNU General Public License, version 2.0, as published by the
7Free Software Foundation.
8
9This program is designed to work with certain software (including
10but not limited to OpenSSL) that is licensed under separate terms,
11as designated in a particular file or component or in included license
12documentation. The authors of MySQL hereby grant you an additional
13permission to link the program and your derivative works with the
14separately licensed software that they have either included with
15the program or referenced in the documentation.
16
17This program is distributed in the hope that it will be useful, but WITHOUT
18ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
19FOR A PARTICULAR PURPOSE. See the GNU General Public License, version 2.0,
20for more details.
21
22You should have received a copy of the GNU General Public License along with
23this program; if not, write to the Free Software Foundation, Inc.,
2451 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
25
26*****************************************************************************/
27
28/** @file include/arch0arch.h
29 Common interface for redo log and dirty page archiver system
30
31 *******************************************************/
32
33#ifndef ARCH_ARCH_INCLUDE
34#define ARCH_ARCH_INCLUDE
35
37#include <list>
38#include "buf0buf.h" /* buf_page_t */
39#include "ut0mem.h"
40#include "ut0mutex.h"
41
42/** @name Archive file name prefix and constant length parameters. */
43/** @{ */
44/** Archive directory prefix */
45const char ARCH_DIR[] = OS_FILE_PREFIX "ib_archive";
46
47/** Archive Log group directory prefix */
48const char ARCH_LOG_DIR[] = "log_group_";
49
50/** Archive Page group directory prefix */
51const char ARCH_PAGE_DIR[] = "page_group_";
52
53/** Archive log file prefix */
54const char ARCH_LOG_FILE[] = "ib_log_";
55
56/** Archive page file prefix */
57const char ARCH_PAGE_FILE[] = "ib_page_";
58
59/** @} */
60
61/** File name for the durable file which indicates whether a group was made
62durable or not. Required to differentiate durable group from group left over by
63crash during clone operation. */
64constexpr char ARCH_PAGE_GROUP_DURABLE_FILE_NAME[] = "durable";
65
66/** Byte length for printing LSN.
67Each archive group name is appended with start LSN */
68const uint MAX_LSN_DECIMAL_DIGIT = 32;
69
70/** Max string length for archive log file name */
72 sizeof(ARCH_DIR) + 1 + sizeof(ARCH_LOG_DIR) + MAX_LSN_DECIMAL_DIGIT + 1 +
74
75/** Max string length for archive page file name */
77 sizeof(ARCH_DIR) + 1 + sizeof(ARCH_PAGE_DIR) + MAX_LSN_DECIMAL_DIGIT + 1 +
79
80/** Max string length for archive group directory name */
82 sizeof(ARCH_DIR) + 1 + sizeof(ARCH_PAGE_DIR) + MAX_LSN_DECIMAL_DIGIT + 1;
83
84/** Log archiver background thread */
86
87/** Archiver thread event to signal that data is available */
89
90/** Memory block size */
92
93/** Archiver client state.
94Archiver clients request archiving for specific interval using
95the start and stop interfaces. During this time the client is
96attached to global Archiver system. A client copies archived
97data for the interval after calling stop. System keeps the data
98till the time client object is destroyed.
99
100@startuml
101
102 state ARCH_CLIENT_STATE_INIT
103 state ARCH_CLIENT_STATE_STARTED
104 state ARCH_CLIENT_STATE_STOPPED
105
106 [*] -down-> ARCH_CLIENT_STATE_INIT
107 ARCH_CLIENT_STATE_INIT -down-> ARCH_CLIENT_STATE_STARTED : Attach and start \
108 archiving
109 ARCH_CLIENT_STATE_STARTED -right-> ARCH_CLIENT_STATE_STOPPED : Stop \
110 archiving
111 ARCH_CLIENT_STATE_STOPPED -down-> [*] : Detach client
112
113@enduml */
115 /** Client is initialized */
117
118 /** Archiving started by client */
120
121 /** Archiving stopped by client */
124
125/** Remove files related to page and log archiving.
126@param[in] file_path path to the file
127@param[in] file_name name of the file */
128void arch_remove_file(const char *file_path, const char *file_name);
129
130/** Remove group directory and the files related to page and log archiving.
131@param[in] dir_path path to the directory
132@param[in] dir_name directory name */
133void arch_remove_dir(const char *dir_path, const char *dir_name);
134
135/** Archiver system state.
136Archiver state changes are triggered by client request to start or
137stop archiving and system wide events like shutdown fatal error etc.
138Following diagram shows the state transfer.
139
140@startuml
141
142 state ARCH_STATE_INIT
143 state ARCH_STATE_ACTIVE
144 state ARCH_STATE_PREPARE_IDLE
145 state ARCH_STATE_IDLE
146 state ARCH_STATE_ABORT
147
148 [*] -down-> ARCH_STATE_INIT
149
150 ARCH_STATE_INIT -down-> ARCH_STATE_ACTIVE : Start archiving
151 ARCH_STATE_ACTIVE -right-> ARCH_STATE_PREPARE_IDLE : Stop archiving
152 ARCH_STATE_PREPARE_IDLE -right-> ARCH_STATE_IDLE : All data archived
153 ARCH_STATE_IDLE -down-> ARCH_STATE_ABORT : Shutdown or Fatal Error
154 ARCH_STATE_PREPARE_IDLE --> ARCH_STATE_ACTIVE : Resume archiving
155 ARCH_STATE_IDLE --> ARCH_STATE_ACTIVE : Start archiving
156 ARCH_STATE_ABORT -down-> [*]
157
158@enduml */
160 /** Archiver is initialized */
162
163 /** Archiver is active and archiving data */
165
166 /** Archiver is processing last data chunks before idle state */
168
169 /** Archiver is idle */
171
172 /** Server is in read only mode, and hence the archiver */
174
175 /** Archiver is aborted */
178
179/** Archived data block state.
180A data block is a block in memory that holds dirty page IDs before persisting
181into disk. Shown below is the state transfer diagram for a data block.
182
183@startuml
184
185 state ARCH_BLOCK_INIT
186 state ARCH_BLOCK_ACTIVE
187 state ARCH_BLOCK_READY_TO_FLUSH
188 state ARCH_BLOCK_FLUSHED
189
190 [*] -down-> ARCH_BLOCK_INIT
191 ARCH_BLOCK_INIT -> ARCH_BLOCK_ACTIVE : Writing page ID
192 ARCH_BLOCK_ACTIVE -> ARCH_BLOCK_READY_TO_FLUSH : Block is full
193 ARCH_BLOCK_READY_TO_FLUSH -> ARCH_BLOCK_FLUSHED : Block is flushed
194 ARCH_BLOCK_FLUSHED --> ARCH_BLOCK_ACTIVE : Writing page ID
195 ARCH_BLOCK_FLUSHED -down-> [*]
196
197@enduml */
199 /** Data block is initialized */
201
202 /** Data block is active and having data */
204
205 /** Data block is full but not flushed to disk */
207
208 /** Data block is flushed and can be reused */
211
212/** Archiver block type */
214 /* Block which holds reset information */
216
217 /* Block which holds archived page IDs */
220
221/** Archiver block flush type */
223 /** Flush when block is full */
225
226 /** Flush partial block.
227 Needed for persistent page tracking. */
230
231/** Page Archive doublewrite buffer block offsets */
233 /** Archive doublewrite buffer page offset for RESET page. */
235
236 /* Archive doublewrite buffer page offset for FULL FLUSH page. */
238
239 /* Archive doublewrite buffer page offset for PARTIAL FLUSH page. */
242
243/** Initialize Page and Log archiver system
244@return error code */
246
247/** Free Page and Log archiver system */
248void arch_free();
249
250/** Start log archiver background thread.
251@return error code */
253
254/** Start page archiver background thread.
255@return error code */
257
258/** Archiver thread event to signal that data is available */
260
261/** Page archiver background thread */
263
264/** Wakes up archiver threads.
265@return true iff any thread was still alive */
266bool arch_wake_threads();
267
268/** Forward declarations */
269class Arch_Group;
270class Arch_Log_Sys;
271class Arch_Dblwr_Ctx;
273
274/** Guard to release resources safely */
276 public:
277 /** Attach a function to the guard which releases some resource. */
278 Arch_scope_guard(std::function<void()> function) { m_cleanup = function; }
279
280 /** Release the resources automatically at the time of destruction. */
282 if (m_cleanup) {
283 m_cleanup();
284 }
285 }
286
287 /** Manually release the resource. */
288 void cleanup() {
289 m_cleanup();
290 m_cleanup = nullptr;
291 }
292
293 private:
294 /** Function to release the resource. */
295 std::function<void()> m_cleanup{};
296};
297
298/** Position in page ID archiving system */
300 /** Initialize a position */
301 void init();
302
303 /** Position in the beginning of next block */
304 void set_next();
305
306 /** Unique block number */
307 uint64_t m_block_num;
308
309 /** Offset within a block */
311
313 if (m_block_num < pos.m_block_num ||
314 (m_block_num == pos.m_block_num && m_offset <= pos.m_offset)) {
315 return (true);
316 }
317 return (false);
318 }
319};
320
321/** Structure which represents a point in a file. */
323 /** LSN of the point */
325
326 /** Position of the point */
328};
329
330/* Structure which represents a file in a group and its reset points. */
332 /* Initialize the structure. */
333 void init();
334
335 /* Index of the file in the group */
337
338 /* LSN of the first reset point in the vector of reset points this
339 structure maintains. Treated as the file LSN. */
341
342 /* Vector of reset points which belong to this file */
343 std::vector<Arch_Point> m_start_point;
344};
345
346/* Structure representing list of archived files. */
347using Arch_Reset = std::deque<Arch_Reset_File>;
348
349/** In memory data block in Page ID archiving system */
351 public:
352 /** Constructor: Initialize elements
353 @param[in] blk_buf buffer for data block
354 @param[in] size buffer size
355 @param[in] type block type */
356 Arch_Block(byte *blk_buf, uint size, Arch_Blk_Type type)
357 : m_data(blk_buf), m_size(size), m_type(type) {}
358
359 /** Do a deep copy of the members of the block passed as the parameter.
360 @note This member needs to be updated whenever a new data member is added to
361 this class. */
362 void copy_data(const Arch_Block *block);
363
364 /** Set the block ready to begin writing page ID
365 @param[in] pos position to initiate block number */
366 void begin_write(Arch_Page_Pos pos);
367
368 /** End writing to a block.
369 Change state to #ARCH_BLOCK_READY_TO_FLUSH */
370 void end_write();
371
372 /** Check if block is initialised or not.
373 @return true if it has been initialised, else false */
374 bool is_init() const { return (m_state == ARCH_BLOCK_INIT); }
375
376 bool is_active() const { return (m_state == ARCH_BLOCK_ACTIVE); }
377 /** Check if the block can be flushed or not.
378 @return true, if the block cannot be flushed */
379 bool is_flushable() const { return (m_state != ARCH_BLOCK_READY_TO_FLUSH); }
380
381 /** Set current block flushed.
382 Must hold page archiver sys operation mutex. */
384
385 /** Add page ID to current block
386 @param[in] page page from buffer pool
387 @param[in] pos Archiver current position
388 @return true, if successful
389 false, if no more space in current block */
391
392 /* Add reset information to the current reset block.
393 @param[in] reset_lsn reset lsn info
394 @param[in] reset_pos reset pos info which needs to be added
395 to the current reset block */
396 void add_reset(lsn_t reset_lsn, Arch_Page_Pos reset_pos);
397
398 /** Copy page Ids from this block at read position to a buffer.
399 @param[in] read_pos current read position
400 @param[in] read_len length of data to copy
401 @param[out] read_buff buffer to copy page IDs.
402 Caller must allocate the buffer.
403 @return true, if successful
404 false, if block is already overwritten */
405 bool get_data(Arch_Page_Pos *read_pos, uint read_len, byte *read_buff);
406
407 /** Copy page Ids from a buffer to this block.
408 @param[in] read_len length of data to copy
409 @param[in] read_buff buffer to copy page IDs from
410 @param[in] read_offset offset from where to write
411 @return true if successful */
412 bool set_data(uint read_len, byte *read_buff, uint read_offset);
413
414 /** Flush this block to the file group
415 @param[in] file_group current archive group
416 @param[in] type flush type
417 @return error code. */
419
420 /* Update the block header with the given LSN
421 @param[in] stop_lsn stop LSN to update in the block header
422 @param[in] reset_lsn reset LSN to update in the blk header */
423 void update_block_header(lsn_t stop_lsn, lsn_t reset_lsn);
424
425 /** @return data length of the block. */
426 uint get_data_len() const { return m_data_len; }
427
428 /** Set the data length of the block.
429 @param[in] data_len data length */
430 void set_data_len(uint data_len) { m_data_len = data_len; }
431
432 /** Set the reset length of the block.
433 @param[in] reset_lsn reset lsn */
434 void set_reset_lsn(lsn_t reset_lsn) { m_reset_lsn = reset_lsn; }
435
436 /** @return block number of the block. */
437 uint64_t get_number() const { return (m_number); }
438
439 /** @return stop lsn */
440 lsn_t get_stop_lsn() const { return (m_stop_lsn); }
441
442 /** Get oldest LSN among the pages that are added to this block
443 @return oldest LSN in block pages */
444 lsn_t get_oldest_lsn() const { return (m_oldest_lsn); }
445
446 /** Get current state of the block
447 @return block state */
448 Arch_Blk_State get_state() const { return (m_state); }
449
450 /** Check if the block data is valid.
451 @param[in] block block to be validated
452 @return true if it's a valid block, else false */
453 static bool validate(byte *block);
454
455 /** Get file index of the file the block belongs to.
456 @return file index */
457 static uint get_file_index(uint64_t block_num, Arch_Blk_Type type);
458
459 /** Get block type from the block header.
460 @param[in] block block from where to get the type
461 @return block type */
462 static Arch_Blk_Type get_type(byte *block);
463
464 /** Get block data length from the block header.
465 @param[in] block block from where to get the data length
466 @return block data length */
467 static uint get_data_len(byte *block);
468
469 /** Get the stop lsn stored in the block header.
470 @param[in] block block from where to fetch the stop lsn
471 @return stop lsn */
472 static lsn_t get_stop_lsn(byte *block);
473
474 /** Get the block number from the block header.
475 @param[in] block block from where to fetch the block number
476 @return block number */
477 static uint64_t get_block_number(byte *block);
478
479 /** Get the reset lsn stored in the block header.
480 @param[in] block block from where to fetch the reset lsn
481 @return reset lsn */
482 static lsn_t get_reset_lsn(byte *block);
483
484 /** Get the checksum stored in the block header.
485 @param[in] block block from where to fetch the checksum
486 @return checksum */
487 static uint32_t get_checksum(byte *block);
488
489 /** Fetch the offset for a block in the archive file.
490 @param[in] block_num block number
491 @param[in] type type of block
492 @return file offset of the block */
493 static uint64_t get_file_offset(uint64_t block_num, Arch_Blk_Type type);
494
495 private:
496 /* @note member function copy_data needs to be updated whenever a new data
497 member is added to this class. */
498
499 /** Block data buffer */
500 byte *m_data;
501
502 /** Block data length in bytes */
504
505 /** Total block size in bytes */
506 uint m_size;
507
508 /** State of the block. */
510
511 /** Unique block number */
512 uint64_t m_number{};
513
514 /** Type of block. */
516
517 /** Checkpoint lsn at the time the last page ID was added to the
518 block. */
520
521 /** Oldest LSN of all the page IDs added to the block since the last
522 checkpoint */
524
525 /** Start LSN or the last reset LSN of the group */
527};
528
529/** Archiver file context.
530Represents a set of fixed size files within a group */
532 public:
533 class Recovery;
534
535 /** Constructor: Initialize members */
537
538 /** Destructor: Close open file and free resources */
540 close();
541
542 if (m_name_buf != nullptr) {
544 }
545 }
546
547 /** Initializes archiver file context.
548 @param[in] path path to the file
549 @param[in] base_dir directory name prefix
550 @param[in] base_file file name prefix
551 @param[in] num_files initial number of files
552 @return error code. */
553 dberr_t init(const char *path, const char *base_dir, const char *base_file,
554 uint num_files);
555
556 /** Open a file at specific index
557 @param[in] read_only open in read only mode
558 @param[in] start_lsn start lsn for the group
559 @param[in] file_index index of the file within the group which needs
560 to be opened
561 @param[in] file_offset start offset
562 @param[in] file_size maximum allowed file size or 0 to use its current
563 real size on disk as the limitation (file is full)
564 @return error code. */
565 dberr_t open(bool read_only, lsn_t start_lsn, uint file_index,
566 uint64_t file_offset, uint64_t file_size);
567
568 /** Add a new file and open
569 @param[in] start_lsn start lsn for the group
570 @param[in] new_file_size size limit for the new file
571 @param[in] initial_file_size initial size of file to create
572 @return error code. */
573 dberr_t open_new(lsn_t start_lsn, uint64_t new_file_size,
574 uint64_t initial_file_size);
575
576 /** Open next file for read
577 @param[in] start_lsn start lsn for the group
578 @param[in] file_offset start offset
579 @param[in] file_size maximum allowed file size or 0 to use its current
580 real size on disk as the limitation (file is full)
581 @return error code. */
582 dberr_t open_next(lsn_t start_lsn, uint64_t file_offset, uint64_t file_size);
583
584 /** Read data from the current file that is open.
585 Caller must ensure that the size is within the limits of current file
586 context.
587 @param[in,out] to_buffer read data into this buffer
588 @param[in] offset file offset from where to read
589 @param[in] size size of data to read in bytes
590 @return error code */
591 dberr_t read(byte *to_buffer, const uint64_t offset, uint size);
592
593 /** Resize file to provided size and overwrite the whole file with 0x00.
594 @param[in] file_size new file size
595 @return error code */
597
598 /** Write data to this file context from the given file offset.
599 Data source is another file context or buffer. If buffer is NULL, data is
600 copied from input file context. Caller must ensure that the size is within
601 the limits of current file for both source and destination file context.
602 @param[in] from_file file context to copy data from
603 @param[in] from_buffer buffer to copy data or NULL
604 @param[in] offset file offset from where to write
605 @param[in] size size of data to copy in bytes
606 @return error code */
607 dberr_t write(Arch_File_Ctx *from_file, byte *from_buffer, uint offset,
608 uint size);
609
610 /** Write data to this file context from the current offset.
611 Data source is another file context or buffer. If buffer is NULL, data is
612 copied from input file context. Caller must ensure that the size is within
613 the limits of current file for both source and destination file context.
614 @param[in] from_file file context to copy data from
615 @param[in] from_buffer buffer to copy data or NULL
616 @param[in] size size of data to copy in bytes
617 @return error code */
618 dberr_t write(Arch_File_Ctx *from_file, byte *from_buffer, uint size);
619
620 /** Flush file. */
621 void flush() {
624 }
625 }
626
627 /** Close file, if open */
628 void close() {
632 }
633 }
634
635 /** Check if file is closed
636 @return true, if file is closed */
637 bool is_closed() const { return (m_file.m_file == OS_FILE_CLOSED); }
638
639 /** Check how much is left in current file
640 @return length left in bytes */
641 uint64_t bytes_left() const {
643 return (m_size - m_offset);
644 }
645
646 /** Construct file name at specific index
647 @param[in] idx file index
648 @param[in] dir_lsn lsn of the group
649 @param[out] buffer file name including path.
650 The buffer is allocated by caller.
651 @param[in] length buffer length */
652 void build_name(uint idx, lsn_t dir_lsn, char *buffer, uint length);
653
654 /** Construct group directory name
655 @param[in] dir_lsn lsn of the group
656 @param[out] buffer directory name.
657 The buffer is allocated by caller.
658 @param[in] length buffer length */
659 void build_dir_name(lsn_t dir_lsn, char *buffer, uint length);
660
661 /** Get the logical size of a file.
662 @return logical file size. */
663 uint64_t get_size() const { return (m_size); }
664
665 /* Fetch offset of the file open in this context.
666 @return file offset */
667 uint64_t get_offset() const { return (m_offset); }
668
669 /** Get current file index.
670 @return current file index */
671 uint get_index() const { return m_index; }
672
673 /** Get number of files
674 @return current file count */
675 uint get_count() const { return (m_count); }
676
677 /** Get the physical size of a file that is open in this context.
678 @return physical file size */
679 uint64_t get_phy_size() const {
680 ut_ad(m_name_buf != nullptr);
682 return (file_size.m_total_size);
683 }
684
685 /** Update stop lsn of a file in the group.
686 @param[in] file_index file_index the current write_pos belongs to
687 @param[in] stop_lsn stop point */
688 void update_stop_point(uint file_index, lsn_t stop_lsn);
689
690#ifdef UNIV_DEBUG
691 /** Check if the information maintained in the memory is the same
692 as the information maintained in the files.
693 @return true if both sets of information are the same
694 @param[in] group group whose file is being validated
695 @param[in] file_index index of the file which is being validated
696 @param[in] start_lsn start LSN
697 @param[in,out] reset_count count of files which has been validated
698 @return true if both the sets of information are the same. */
699 bool validate(Arch_Group *group, uint file_index, lsn_t start_lsn,
700 uint &reset_count);
701#endif
702
703 /** Update the reset information in the in-memory structure that we maintain
704 for faster access.
705 @param[in] lsn lsn at the time of reset
706 @param[in] pos pos at the time of reset */
708
709 /** Find the appropriate reset LSN that is less than or equal to the
710 given lsn and fetch the reset point.
711 @param[in] check_lsn LSN to be searched against
712 @param[out] reset_point reset position of the fetched reset point
713 @return true if the search was successful. */
714 bool find_reset_point(lsn_t check_lsn, Arch_Point &reset_point);
715
716 /** Find the first stop LSN that is greater than the given LSN and fetch
717 the stop point.
718 @param[in] group the group whose stop_point we're interested in
719 @param[in] check_lsn LSN to be searched against
720 @param[out] stop_point stop point
721 @param[in] last_pos position of the last block in the group;
722 m_write_pos if group is active and m_stop_pos if not
723 @return true if the search was successful. */
724 bool find_stop_point(Arch_Group *group, lsn_t check_lsn,
725 Arch_Point &stop_point, Arch_Page_Pos last_pos);
726
727 /** Delete a single file belonging to the specified file index.
728 @param[in] file_index file index of the file which needs to be deleted
729 @param[in] begin_lsn group's start lsn
730 @return true if successful, else false. */
731 bool delete_file(uint file_index, lsn_t begin_lsn);
732
733 /** Delete all files for this archive group
734 @param[in] begin_lsn group's start lsn */
735 void delete_files(lsn_t begin_lsn);
736
737 /** Purge archived files until the specified purge LSN.
738 @param[in] begin_lsn start LSN of the group
739 @param[in] end_lsn end LSN of the group
740 @param[in] purge_lsn purge LSN until which files needs to be purged
741 @return LSN until which purging was successful
742 @retval LSN_MAX if there was no purging done. */
743 lsn_t purge(lsn_t begin_lsn, lsn_t end_lsn, lsn_t purge_lsn);
744
745 /** Fetch the status of the page tracking system.
746 @param[out] status vector of a pair of (ID, bool) where ID is the
747 start/stop point and bool is true if the ID is a start point else false */
748 void get_status(std::vector<std::pair<lsn_t, bool>> &status) {
749 for (auto reset_file : m_reset) {
750 for (auto reset_point : reset_file.m_start_point) {
751 status.push_back(std::make_pair(reset_point.lsn, true));
752 }
753 }
754 }
755
756 private:
757#ifdef UNIV_DEBUG
758 /** Check if the reset information maintained in the memory is the same
759 as the information maintained in the given file.
760 @param[in] file file descriptor
761 @param[in] file_index index of the file
762 @param[in,out] reset_count number of files processed containing
763 reset data
764 @return true if both sets of information are the same */
765 bool validate_reset_block_in_file(pfs_os_file_t file, uint file_index,
766 uint &reset_count);
767
768 /** Check if the stop LSN maintained in the memory is the same as the
769 information maintained in the files.
770 @param[in] group group whose file is being validated
771 @param[in] file file descriptor
772 @param[in] file_index index of the file for which the validation is
773 happening
774 @return true if both the sets of information are the same. */
776 uint file_index);
777#endif
778
779 /** Fetch reset lsn of a particular reset point pertaining to a file.
780 @param[in] block_num block number where the reset occurred.
781 @return reset lsn */
782 lsn_t fetch_reset_lsn(uint64_t block_num);
783
784 private:
785 /** File name buffer.
786 Used if caller doesn't allocate buffer. */
787 char *m_name_buf{nullptr};
788
789 /** File name buffer length */
791
792 /** Fixed length part of the file.
793 Path ended with directory separator. */
795
796 /** Fixed part of the path to file */
797 const char *m_path_name{nullptr};
798
799 /** Directory name prefix */
800 const char *m_dir_name{nullptr};
801
802 /** File name prefix */
803 const char *m_file_name{nullptr};
804
805 /** Current file descriptor */
807
808 /** File index within the archive group */
809 uint m_index{};
810
811 /** Current number of files in the archive group */
812 uint m_count{};
813
814 /** Current file offset */
815 uint64_t m_offset{};
816
817 /** File size limit in bytes */
818 uint64_t m_size{};
819
820 /** Queue of file structure holding reset information pertaining to
821 their respective files in a group.
822 Protected by Arch_Page_Sys::m_mutex and Arch_Page_Sys::m_oper_mutex.
823 @note used only by the page archiver */
825
826 /** Vector of stop points corresponding to a file.
827 Stop point refers to the stop lsn (checkpoint lsn) until which the pages are
828 guaranteed to be tracked in a file. Each block in a file maintains this
829 information.
830 Protected by Arch_Page_Sys::m_oper_mutex.
831 @note used only by the page archiver */
832 std::vector<lsn_t> m_stop_points;
833};
834
835/** Number which tries to uniquely identify the archived data (unless it is
836zero, which stands for unsupported identification). Currently only redo log
837files are identified (by Log_uuid's value). */
838typedef uint32_t Arch_group_uuid;
839
840/** Contiguous archived data for redo log or page tracking.
841If there is a gap, that is if archiving is stopped and started, a new
842group is created. */
844 public:
845 /** Function responsible to format the header of a new file which is
846 created, when the stream of data is written to a sequence of new files.
847 @param[in] start_offset offset at which a new file starts, expressed
848 in bytes from the beginning of the stream
849 @param[in] header header to format */
850 typedef std::function<dberr_t(uint64_t start_offset, byte *header)>
852
853 /** Constructor: Initialize members
854 @param[in] start_lsn start LSN for the group
855 @param[in] header_len length of header for archived files
856 @param[in] mutex archive system mutex from caller */
857 Arch_Group(lsn_t start_lsn, uint header_len, ib_mutex_t *mutex)
858 : m_begin_lsn(start_lsn),
859 m_header_len(header_len) IF_DEBUG(, m_arch_mutex(mutex)) {
863 }
864
865 /** Destructor: Delete all files for non-durable archiving. */
866 ~Arch_Group();
867
868 /** Initialize the doublewrite buffer file context for the archive group.
869 @param[in] path path to the file
870 @param[in] base_file file name prefix
871 @param[in] num_files initial number of files
872 @param[in] file_size file size in bytes
873 @return error code. */
874 static dberr_t init_dblwr_file_ctx(const char *path, const char *base_file,
875 uint num_files, uint64_t file_size);
876
877 /** Initialize the file context for the archive group.
878 File context keeps the archived data in files on disk. There
879 is one file context for a archive group.
880 @param[in] path path to the file
881 @param[in] base_dir directory name prefix
882 @param[in] base_file file name prefix
883 @param[in] num_files initial number of files
884 @param[in] file_size size of file used when a new file is created
885 @param[in] uuid uuid of this arch group or 0 if unknown
886 @return error code. */
887 dberr_t init_file_ctx(const char *path, const char *base_dir,
888 const char *base_file, uint num_files,
889 uint64_t file_size, Arch_group_uuid uuid) {
890 m_uuid = uuid;
892 return (m_file_ctx.init(path, base_dir, base_file, num_files));
893 }
894
895 /* Close the file contexts when they're not required anymore. */
898
902 }
903 }
904
905 /** Mark archive group inactive.
906 A group is marked inactive by archiver background before entering
907 into idle state ARCH_STATE_IDLE.
908 @param[in] end_lsn lsn where redo archiving is stopped */
909 void disable(lsn_t end_lsn) {
910 m_is_active = false;
911
912 if (end_lsn != LSN_MAX) {
913 m_end_lsn = end_lsn;
914 }
915 }
916
917 /** Attach a client to the archive group.
918 @param[in] is_durable true, if durable tracking is requested */
919 void attach(bool is_durable) {
921 ++m_num_active;
922
923 if (is_durable) {
925 } else {
926 ut_ad(m_ref_count < std::numeric_limits<decltype(m_ref_count)>::max());
927 if (m_ref_count < std::numeric_limits<decltype(m_ref_count)>::max()) {
928 ++m_ref_count;
929 }
930 }
931 }
932
933 /** Detach a client when archiving is stopped by the client.
934 The client still has reference to the group so that the group
935 is not destroyed when it retrieves the archived data. The
936 reference is removed later by #Arch_Group::release.
937 @param[in] stop_lsn archive stop lsn for client
938 @param[in] stop_pos archive stop position for client. Used only by
939 the page_archiver.
940 @return number of active clients */
941 uint detach(lsn_t stop_lsn, Arch_Page_Pos *stop_pos) {
942 ut_ad(m_num_active > 0);
944 --m_num_active;
945
946 if (m_num_active == 0) {
947 m_end_lsn = stop_lsn;
948 if (stop_pos != nullptr) {
949 m_stop_pos = *stop_pos;
950 }
951 }
952
953 return (m_num_active);
954 }
955
956 /** Release the archive group from a client.
957 Reduce the reference count. When all clients release the group,
958 the reference count falls down to zero. The function would then
959 return zero and the caller can remove the group.
960 @param[in] is_durable the client needs durable archiving */
961 void release(bool is_durable) {
964 if (is_durable) {
965 /* For durable, m_ref_count was not incremented. */
966 return;
967 }
968
969 ut_ad(m_ref_count > 0);
970 --m_ref_count;
971 /* If there was a bug, and m_ref_count was 0 before the decrement,
972 it would become std::numeric_limits<decltype(m_ref_count)>::max(),
973 and the caller would not remove the group. If we called attach()
974 afterwards (holding still the m_arch_mutex), the m_ref_count would
975 stay unchanged, because there is mechanism protecting from overflows.
976 This way, the scope of the potential bug, is limited to the group not
977 being removed. */
978 }
979
980 /** Construct file name for the active file which indicates whether a group
981 is active or not.
982 @note Used only by the page archiver.
983 @return error code. */
985
986 /** Construct file name for the durable file which indicates whether a group
987 was made durable or not.
988 @note Used only by the page archiver.
989 @return error code. */
991
992 /** Mark the group active by creating a file in the respective group
993 directory. This is required at the time of recovery to know whether a group
994 was active or not in case of a crash.
995 @note Used only by the page archiver.
996 @return error code. */
997 int mark_active();
998
999 /** Mark the group durable by creating a file in the respective group
1000 directory. This is required at the time of recovery to differentiate durable
1001 group from group left over by crash during clone operation.
1002 @note Used only by the page archiver.
1003 @return error code. */
1004 int mark_durable();
1005
1006 /** Mark the group inactive by deleting the 'active' file. This is required
1007 at the time of crash recovery to know whether a group was active or not in
1008 case of a crash.
1009 @note Used only by the page archiver.
1010 @return error code */
1011 int mark_inactive();
1012
1013 /** Check if archiving is going on for this group
1014 @return true, if the group is active */
1015 bool is_active() const { return (m_is_active); }
1016
1017 /** Write the header (RESET page) to an archived file.
1018 @note Used only by the Page Archiver and not by the Redo Log Archiver.
1019 @param[in] from_buffer buffer to copy data
1020 @param[in] length size of data to copy in bytes
1021 @note Used only by the Page Archiver.
1022 @return error code */
1023 dberr_t write_file_header(byte *from_buffer, uint length);
1024
1025 /** Write to the doublewrite buffer before writing archived data to a file.
1026 The source is either a file context or buffer. Caller must ensure that data
1027 is in single file in source file context.
1028 @param[in] from_file file context to copy data from
1029 @param[in] from_buffer buffer to copy data or NULL
1030 @param[in] write_size size of data to write in bytes
1031 @param[in] offset offset from where to write
1032 @note Used only by the Page Archiver.
1033 @return error code */
1035 byte *from_buffer, uint write_size,
1036 Arch_Page_Dblwr_Offset offset);
1037
1038 /** Archive data to one or more files.
1039 The source is either a file context or buffer. Caller must ensure that data
1040 is in single file in source file context.
1041 @param[in] from_file file context to copy data from
1042 @param[in] from_buffer buffer to copy data or NULL
1043 @param[in] length size of data to copy in bytes
1044 @param[in] partial_write true if the operation is part of partial flush
1045 @param[in] do_persist doublewrite to ensure persistence
1046 @param[in] new_file callback called for each new file being created
1047 @return error code */
1048 dberr_t write_to_file(Arch_File_Ctx *from_file, byte *from_buffer,
1049 uint length, bool partial_write, bool do_persist,
1050 Get_file_header_callback new_file);
1051
1052 /** Find the appropriate reset LSN that is less than or equal to the
1053 given lsn and fetch the reset point.
1054 @param[in] check_lsn LSN to be searched against
1055 @param[out] reset_point reset position of the fetched reset point
1056 @return true if the search was successful. */
1057 bool find_reset_point(lsn_t check_lsn, Arch_Point &reset_point) {
1058 return (m_file_ctx.find_reset_point(check_lsn, reset_point));
1059 }
1060
1061 /** Find the first stop LSN that is greater than the given LSN and fetch
1062 the stop point.
1063 @param[in] check_lsn LSN to be searched against
1064 @param[out] stop_point stop point
1065 @param[in] write_pos latest write_pos
1066 @return true if the search was successful. */
1067 bool find_stop_point(lsn_t check_lsn, Arch_Point &stop_point,
1068 Arch_Page_Pos write_pos) {
1070 Arch_Page_Pos last_pos = is_active() ? write_pos : m_stop_pos;
1071 return (m_file_ctx.find_stop_point(this, check_lsn, stop_point, last_pos));
1072 }
1073
1074#ifdef UNIV_DEBUG
1075 /** Adjust end LSN to end of file. This is used in debug
1076 mode to test the case when LSN is at file boundary.
1077 @param[in,out] stop_lsn stop lsn for client
1078 @param[out] blk_len last block length */
1079 void adjust_end_lsn(lsn_t &stop_lsn, uint32_t &blk_len);
1080
1081 /** Adjust redo copy length to end of file. This is used
1082 in debug mode to archive only till end of file.
1083 @param[in] arch_lsn LSN up to which data is already archived
1084 @param[in,out] copy_len length of data to copy in bytes */
1085 void adjust_copy_length(lsn_t arch_lsn, uint32_t &copy_len);
1086
1087 /** Check if the information maintained in the memory is the same
1088 as the information maintained in the files.
1089 @return true if both sets of information are the same */
1091#endif /* UNIV_DEBUG */
1092
1093 /** Get the total number of archived files belonging to this group.
1094 @return number of archived files */
1095 uint get_file_count() const { return (m_file_ctx.get_count()); }
1096
1097 /** Check if any client (durable or not) is attached to the archiver.
1098 @return true if any client is attached, else false */
1099 bool is_referenced() const {
1100 return (m_ref_count > 0) || (m_dur_ref_count > 0);
1101 }
1102
1103 /** Check if any client requiring durable archiving is active.
1104 @return true if any durable client is still attached, else false */
1106 return (m_num_active != m_ref_count);
1107 }
1108
1109 /** Check if any client requires durable archiving.
1110 @return true if there is at least 1 client that requires durable archiving*/
1111 bool is_durable() const { return (m_dur_ref_count > 0); }
1112
1113 /** Purge archived files until the specified purge LSN.
1114 @param[in] purge_lsn LSN until which archived files needs to be
1115 purged
1116 @param[out] purged_lsn LSN until which purging is successful;
1117 LSN_MAX if there was no purging done
1118 @return error code */
1119 uint purge(lsn_t purge_lsn, lsn_t &purged_lsn);
1120
1121 /** Operations to be done at the time of shutdown. */
1122 static void shutdown() { s_dblwr_file_ctx.close(); }
1123
1124 /** Update the reset information in the in-memory structure that we maintain
1125 for faster access.
1126 @param[in] lsn lsn at the time of reset
1127 @param[in] pos pos at the time of reset */
1130 }
1131
1132 /** Update stop lsn of a file in the group.
1133 @param[in] pos stop position
1134 @param[in] stop_lsn stop point */
1138 }
1139
1140 /** Recover the information belonging to this group from the archived files.
1141 @param[in,out] group_info structure containing information of a
1142 group obtained during recovery by scanning files
1143 @param[in] dblwr_ctx file context related to doublewrite buffer
1144 @return error code */
1145 dberr_t recover(Arch_Recv_Group_Info &group_info, Arch_Dblwr_Ctx *dblwr_ctx);
1146
1147 /** Parse block for block info (header/data).
1148 @param[in] cur_pos position to read
1149 @param[in,out] buff buffer into which to write the parsed data
1150 @param[in] buff_len length of the buffer
1151 @return error code */
1152 int read_data(Arch_Page_Pos cur_pos, byte *buff, uint buff_len);
1153
1154 /** Get archived file name at specific index in this group.
1155 Caller would use it to open and copy data from archived files.
1156 @param[in] idx file index in the group
1157 @param[out] name_buf file name and path. Caller must
1158 allocate the buffer.
1159 @param[in] buf_len allocated buffer length */
1160 void get_file_name(uint idx, char *name_buf, uint buf_len) {
1161 ut_ad(name_buf != nullptr);
1162
1163 /* Build name from the file context. */
1164 m_file_ctx.build_name(idx, m_begin_lsn, name_buf, buf_len);
1165 }
1166
1167 /** Get the current file size for this group.
1168 Fixed size files are used for archiving data in a group.
1169 @return file size in bytes */
1170 uint64_t get_file_size() const { return m_file_size; }
1171
1172 /** Get start LSN for this group
1173 @return start LSN */
1174 lsn_t get_begin_lsn() const { return (m_begin_lsn); }
1175
1176 /** @return stop LSN for this group */
1177 lsn_t get_end_lsn() const { return (m_end_lsn); }
1178
1179 /** @return stop block position of the group. */
1181
1182 /** @return uuid for the arch group */
1183 Arch_group_uuid get_uuid() const { return m_uuid; }
1184
1185 /** Fetch the status of the page tracking system.
1186 @param[out] status vector of a pair of (ID, bool) where ID is the
1187 start/stop point and bool is true if the ID is a start point else false */
1188 void get_status(std::vector<std::pair<lsn_t, bool>> &status) {
1190
1191 if (!is_active()) {
1192 status.push_back(std::make_pair(m_end_lsn, false));
1193 }
1194 }
1195
1196 /** Open the file which was open at the time of a crash, during crash
1197 recovery, and set the file offset to the last written offset.
1198 @param[in] write_pos latest write position at the time of crash/shutdown
1199 @param[in] create_new create new file if file not present
1200 @return error code. */
1201 dberr_t open_file(Arch_Page_Pos write_pos, bool create_new);
1202
1203 /** Disable copy construction */
1204 Arch_Group(Arch_Group const &) = delete;
1205
1206 /** Disable assignment */
1207 Arch_Group &operator=(Arch_Group const &) = delete;
1208
1209 private:
1210 class Recovery;
1211
1212 /** Get page IDs from archived file
1213 @param[in] read_pos position to read from
1214 @param[in] read_len length of data to read
1215 @param[in] read_buff buffer to read page IDs
1216 @return error code */
1217 int read_from_file(Arch_Page_Pos *read_pos, uint read_len, byte *read_buff);
1218
1219 /** Get the directory name for this archive group.
1220 It is used for cleaning up the archive directory.
1221 @param[out] name_buf directory name and path. Caller must
1222 allocate the buffer.
1223 @param[in] buf_len buffer length */
1224 void get_dir_name(char *name_buf, uint buf_len) {
1225 m_file_ctx.build_dir_name(m_begin_lsn, name_buf, buf_len);
1226 }
1227
1228 /** Create a new file and write the header.
1229 @param[in] start_offset start offste
1230 @param[in] get_header callback which prepares a header */
1232 Get_file_header_callback &get_header);
1233
1234 private:
1235 /** If the group is active */
1236 bool m_is_active{true};
1237
1238 /** To know which group was active at the time of a crash/shutdown during
1239 recovery we create an empty file in the group directory. This holds the name
1240 of the file. */
1241 char *m_active_file_name{nullptr};
1242
1243 /** File descriptor for a file required to indicate that the group was
1244 active at the time of crash during recovery . */
1246
1247 /** File name for the durable file which indicates whether a group was made
1248 durable or not. Required to differentiate durable group from group left over
1249 by crash during clone operation. */
1250 char *m_durable_file_name{nullptr};
1251
1252 /** File descriptor for a file to indicate that the group was made durable or
1253 not. Required to differentiate durable group from group left over by crash
1254 during clone operation. */
1256
1257 /** Number of clients referencing the group */
1259
1260 /** Number of clients referencing for durable archiving */
1262
1263 /** Number of clients for which archiving is in progress */
1265
1266 /** Start LSN for the archive group */
1268
1269 /** End lsn for this archive group */
1271
1272 /** Stop position of the group, if it's not active. */
1274
1275 /** Header length for the archived files */
1277
1278 /** Size of file used when a new file is being created. */
1279 uint64_t m_file_size;
1280
1281 /** UUID generated for this arch group. */
1283
1284 /** Archive file context */
1286
1287 /** Doublewrite buffer file context.
1288 Note - Used only in the case of page archiver. */
1290
1291#ifdef UNIV_DEBUG
1292 /** Mutex protecting concurrent operations by multiple clients.
1293 This is either the redo log or page archive system mutex. Currently
1294 used for assert checks. */
1295 ib_mutex_t *m_arch_mutex;
1296#endif /* UNIV_DEBUG */
1297};
1298
1299/** A list of archive groups */
1300using Arch_Grp_List = std::list<Arch_Group *, ut::allocator<Arch_Group *>>;
1301
1302/** An iterator for archive group */
1303using Arch_Grp_List_Iter = Arch_Grp_List::iterator;
1304
1306 public:
1307 const std::string &get_name() const override;
1308
1309 lsn_t get_consumed_lsn() const override;
1310
1311 void consumption_requested() override;
1312};
1313
1314/** Redo log archiving system */
1316 public:
1317 /** Constructor: Initialize members */
1321 m_group_list(),
1322 m_current_group() {
1324 }
1325
1326 /** Destructor: Free mutex */
1329 ut_ad(m_current_group == nullptr);
1330 ut_ad(m_group_list.empty());
1331
1333 }
1334
1335 /** Check if archiving is in progress.
1336 In #ARCH_STATE_PREPARE_IDLE state, all clients have already detached
1337 but archiver background task is yet to finish.
1338 @return true, if archiving is active */
1339 bool is_active() const {
1341 }
1342
1343 /** Check if archiver system is in initial state
1344 @return true, if redo log archiver state is #ARCH_STATE_INIT */
1345 bool is_init() const { return (m_state == ARCH_STATE_INIT); }
1346
1347 /** Get LSN up to which redo is archived
1348 @return last archived redo LSN */
1350 lsn_t archived_lsn = m_archived_lsn.load();
1351 ut_ad(archived_lsn == LSN_MAX ||
1352 archived_lsn % OS_FILE_LOG_BLOCK_SIZE == 0);
1353 if (archived_lsn != LSN_MAX && archived_lsn % OS_FILE_LOG_BLOCK_SIZE != 0) {
1354 archived_lsn = ut_uint64_align_down(archived_lsn, OS_FILE_LOG_BLOCK_SIZE);
1355 }
1356 return archived_lsn;
1357 }
1358
1359 /** Get recommended archived redo file size
1360 @return size of file in bytes */
1362
1363 /** Get current redo log archive group
1364 @return current archive group */
1366
1367 /** Start redo log archiving.
1368 If archiving is already in progress, the client
1369 is attached to current group.
1370 @param[out] group log archive group
1371 @param[out] start_lsn start lsn for client
1372 @param[out] header redo log header
1373 @param[in] is_durable if client needs durable archiving
1374 @return error code */
1375 int start(Arch_Group *&group, lsn_t &start_lsn, byte *header,
1376 bool is_durable);
1377
1378 /** Stop redo log archiving.
1379 If other clients are there, the client is detached from
1380 the current group.
1381 @param[out] group log archive group
1382 @param[out] stop_lsn stop lsn for client
1383 @param[out] log_blk redo log trailer block
1384 @param[in,out] blk_len length in bytes
1385 @return error code */
1386 int stop(Arch_Group *group, lsn_t &stop_lsn, byte *log_blk,
1387 uint32_t &blk_len);
1388
1389 /** Force to abort the archiver (state becomes ARCH_STATE_IDLE or
1390 ARCH_STATE_ABORT). */
1391 void force_abort();
1392
1393 /** Release the current group from client.
1394 @param[in] group group the client is attached to
1395 @param[in] is_durable if client needs durable archiving */
1396 void release(Arch_Group *group, bool is_durable);
1397
1398 /** Archive accumulated redo log in current group.
1399 This interface is for archiver background task to archive redo log
1400 data by calling it repeatedly over time.
1401 @param[in, out] init true when called the first time; it will
1402 then be set to false
1403 @param[in] curr_ctx system redo logs to copy data from
1404 @param[out] arch_lsn LSN up to which archiving is completed
1405 @param[out] wait true, if no more redo to archive
1406 @return true, if archiving is aborted */
1407 bool archive(bool init, Arch_File_Ctx *curr_ctx, lsn_t *arch_lsn, bool *wait);
1408
1409 /** Acquire redo log archiver mutex.
1410 It synchronizes concurrent start and stop operations by
1411 multiple clients. */
1413
1414 /** Release redo log archiver mutex */
1416
1417 /** Disable copy construction */
1418 Arch_Log_Sys(Arch_Log_Sys const &) = delete;
1419
1420 /** Disable assignment */
1422
1423 private:
1424 /** Wait for archive system to come out of #ARCH_STATE_PREPARE_IDLE.
1425 If the system is preparing to idle, #start needs to wait
1426 for it to come to idle state.
1427 @return true, if successful
1428 false, if needs to abort */
1429 bool wait_idle();
1430
1431 /** Wait for redo log archive up to the target LSN.
1432 We need to wait till current log sys LSN during archive stop.
1433 @param[in] target_lsn target archive LSN to wait for
1434 @return error code */
1435 int wait_archive_complete(lsn_t target_lsn);
1436
1437 /** Update checkpoint LSN and related information in redo
1438 log header block.
1439 @param[in,out] header redo log header buffer
1440 @param[in] file_start_lsn LSN of first data byte within file
1441 @param[in] checkpoint_lsn LSN of the checkpoint within the file or 0 */
1442 void update_header(byte *header, lsn_t file_start_lsn, lsn_t checkpoint_lsn);
1443
1444 /** Check and set log archive system state and output the
1445 amount of redo log available for archiving.
1446 @param[in] is_abort need to abort
1447 @param[in,out] archived_lsn LSN up to which redo log is archived
1448 @param[out] to_archive amount of redo log to be archived */
1449 Arch_State check_set_state(bool is_abort, lsn_t *archived_lsn,
1450 uint *to_archive);
1451
1452 /** Copy redo log from file context to archiver files.
1453 @param[in] file_ctx file context for system redo logs
1454 @param[in] start_lsn lsn at which we start copying
1455 @param[in] length data to copy in bytes
1456 @return error code */
1457 dberr_t copy_log(Arch_File_Ctx *file_ctx, lsn_t start_lsn, uint length);
1458
1459 /** Update m_state to the given state. Then check if Arch_Log_Sys is active
1460 and accordingly register or unregister the @see m_log_consumer. It is caller
1461 that should acquire log_sys's: m_files_mutex and writer_mutex prior before
1462 calling this method.
1463 @param[in] state state to assign to m_state */
1464 void update_state_low(Arch_State state);
1465
1466 /** Acquires log_sys's m_files_mutex, writer_mutex and calls
1467 @see update_state_low(state).
1468 @param[in] state state to assign to m_state */
1469 void update_state(Arch_State state);
1470
1471 private:
1472 /** Mutex to protect concurrent start, stop operations */
1473 ib_mutex_t m_mutex;
1474
1475 /** Archiver system state.
1476 #m_state is protected by #m_mutex and #log_t::writer_mutex. For changing
1477 the state both needs to be acquired. For reading, hold any of the two
1478 mutexes. Same is true for #m_archived_lsn. */
1480
1481 /** System has archived log up to this LSN */
1483
1484 /** List of log archive groups */
1486
1487 /** Current archive group */
1489
1490 /** Chunk size to copy redo data */
1492
1493 /** System log file number where the archiving started */
1495
1496 /** System log file offset where the archiving started */
1498
1499 /** Redo log consumer that can be registered to prevent consumption
1500 of redo log files which still haven't been archived. */
1502};
1503
1504/** Vector of page archive in memory blocks */
1505using Arch_Block_Vec = std::vector<Arch_Block *, ut::allocator<Arch_Block *>>;
1506
1507/** Page archiver in memory data */
1509 /** Constructor */
1510 ArchPageData() = default;
1511
1512 /** Allocate buffer and initialize blocks
1513 @return true, if successful */
1514 bool init();
1515
1516 /** Delete blocks and buffer */
1517 void clean();
1518
1519 /** Get the block for a position
1520 @param[in] pos position in page archive sys
1521 @param[in] type block type
1522 @return page archive in memory block */
1524
1525 /** @return temporary block used to copy active block for partial flush. */
1527 return (m_partial_flush_block);
1528 }
1529
1530 /** Vector of data blocks */
1532
1533 /** Reset block */
1535
1536 /** Temporary block used to copy active block for partial flush. */
1538
1539 /** Block size in bytes */
1541
1542 /** Total number of blocks */
1544
1545 /** In memory buffer */
1546 byte *m_buffer{nullptr};
1547};
1548
1549/** Forward declaration. */
1551
1552/** Dirty page archive system */
1554 public:
1555 /** Constructor: Initialize elements and create mutex */
1556 Arch_Page_Sys();
1557
1558 /** Destructor: Free memory buffer and mutexes */
1560
1561 /** Start dirty page ID archiving.
1562 If archiving is already in progress, the client is attached to current group.
1563 @param[out] group page archive group the client gets attached to
1564 @param[out] start_lsn start lsn for client in archived data
1565 @param[out] start_pos start position for client in archived data
1566 @param[in] is_durable true if client needs durable archiving
1567 @param[in] restart true if client is already attached to current group
1568 @param[in] recovery true if archiving is being started during
1569 recovery
1570 @return error code */
1571 int start(Arch_Group **group, lsn_t *start_lsn, Arch_Page_Pos *start_pos,
1572 bool is_durable, bool restart, bool recovery);
1573
1574 /** Stop dirty page ID archiving.
1575 If other clients are there, the client is detached from the current group.
1576 @param[in] group page archive group the client is attached to
1577 @param[out] stop_lsn stop lsn for client
1578 @param[out] stop_pos stop position in archived data
1579 @param[in] is_durable true if client needs durable archiving
1580 @return error code */
1581 int stop(Arch_Group *group, lsn_t *stop_lsn, Arch_Page_Pos *stop_pos,
1582 bool is_durable);
1583
1584 /** Start dirty page ID archiving during recovery.
1585 @param[in,out] info information related to a group required for recovery
1586 @return error code */
1588
1589 /** Release the current group from client.
1590 @param[in] group group the client is attached to
1591 @param[in] is_durable if client needs durable archiving
1592 @param[in] start_pos start position when the client calling the
1593 release was started */
1594 void release(Arch_Group *group, bool is_durable, Arch_Page_Pos start_pos);
1595
1596 /** Check and add page ID to archived data.
1597 Check for duplicate page.
1598 @param[in] bpage page to track
1599 @param[in] track_lsn LSN when tracking started
1600 @param[in] frame_lsn current LSN of the page
1601 @param[in] force if true, add page ID without check */
1602 void track_page(buf_page_t *bpage, lsn_t track_lsn, lsn_t frame_lsn,
1603 bool force);
1604
1605 /** Flush all the unflushed inactive blocks and flush the active block if
1606 required.
1607 @note Used only during the checkpointing process.
1608 @param[in] checkpoint_lsn next checkpoint LSN */
1609 void flush_at_checkpoint(lsn_t checkpoint_lsn);
1610
1611 /** Archive dirty page IDs in current group.
1612 This interface is for archiver background task to flush page archive
1613 data to disk by calling it repeatedly over time.
1614 @param[out] wait true, if no more data to archive
1615 @return true, if archiving is aborted */
1616 bool archive(bool *wait);
1617
1618 /** Acquire dirty page ID archiver mutex.
1619 It synchronizes concurrent start and stop operations by multiple clients. */
1621
1622 /** Release page ID archiver mutex */
1624
1625 /** Acquire dirty page ID archive operation mutex.
1626 It synchronizes concurrent page ID write to memory buffer. */
1628
1629 /** Release page ID archiver operatiion mutex */
1631
1632 /* Save information at the time of a reset considered as the reset point.
1633 @param[in] is_durable true if it's durable page tracking
1634 @return true if the reset point information stored in the data block needs to
1635 be flushed to disk before returning to the caller, else false */
1636 bool save_reset_point(bool is_durable);
1637
1638 /** Wait for reset info to be flushed to disk.
1639 @param[in] request_block block number until which blocks need to be
1640 flushed
1641 @return true if flushed, else false */
1642 bool wait_for_reset_info_flush(uint64_t request_block);
1643
1644 /** Get the group which has tracked pages between the start_id and stop_id.
1645 @param[in,out] start_id start LSN from which tracked pages are
1646 required; updated to the actual start LSN used for the search
1647 @param[in,out] stop_id stop_lsn until when tracked pages are
1648 required; updated to the actual stop LSN used for the search
1649 @param[out] group group which has the required tracked
1650 pages, else nullptr.
1651 @return error */
1652 int fetch_group_within_lsn_range(lsn_t &start_id, lsn_t &stop_id,
1653 Arch_Group **group);
1654
1655 /** Purge the archived files until the specified purge LSN.
1656 @param[in] purge_lsn purge lsn until where files needs to be purged
1657 @return error code
1658 @retval 0 if purge was successful */
1659 uint purge(lsn_t *purge_lsn);
1660
1661 /** Update the stop point in all the required structures.
1662 @param[in] cur_blk block which needs to be updated with the stop info */
1663 void update_stop_info(Arch_Block *cur_blk);
1664
1665 /** Fetch the status of the page tracking system.
1666 @param[out] status vector of a pair of (ID, bool) where ID is the
1667 start/stop point and bool is true if the ID is a start point else false */
1668 void get_status(std::vector<std::pair<lsn_t, bool>> &status) {
1669 for (auto group : m_group_list) {
1670 group->get_status(status);
1671 }
1672 }
1673
1674 /** Given start and stop position find number of pages tracked between them
1675 @param[in] start_pos start position
1676 @param[in] stop_pos stop position
1677 @param[out] num_pages number of pages tracked between start and stop
1678 position
1679 @return false if start_pos and stop_pos are invalid else true */
1680 bool get_num_pages(Arch_Page_Pos start_pos, Arch_Page_Pos stop_pos,
1681 uint64_t &num_pages);
1682
1683 /** Get approximate number of tracked pages between two given LSN values.
1684 @param[in,out] start_id fetch archived page Ids from this LSN
1685 @param[in,out] stop_id fetch archived page Ids until this LSN
1686 @param[out] num_pages number of pages tracked between specified
1687 LSN range
1688 @return error code */
1689 int get_num_pages(lsn_t &start_id, lsn_t &stop_id, uint64_t *num_pages);
1690
1691 /** Get page IDs from a specific position.
1692 Caller must ensure that read_len doesn't exceed the block.
1693 @param[in] group group whose pages we're interested in
1694 @param[in] read_pos position in archived data
1695 @param[in] read_len amount of data to read
1696 @param[out] read_buff buffer to return the page IDs.
1697 @note Caller must allocate the buffer.
1698 @return true if we could successfully read the block. */
1699 bool get_pages(Arch_Group *group, Arch_Page_Pos *read_pos, uint read_len,
1700 byte *read_buff);
1701
1702 /** Get archived page Ids between two given LSN values.
1703 Attempt to read blocks directly from in memory buffer. If overwritten,
1704 copy from archived files.
1705 @param[in] thd thread handle
1706 @param[in] cbk_func called repeatedly with page ID buffer
1707 @param[in] cbk_ctx callback function context
1708 @param[in,out] start_id fetch archived page Ids from this LSN
1709 @param[in,out] stop_id fetch archived page Ids until this LSN
1710 @param[in] buf buffer to fill page IDs
1711 @param[in] buf_len buffer length in bytes
1712 @return error code */
1713 int get_pages(MYSQL_THD thd, Page_Track_Callback cbk_func, void *cbk_ctx,
1714 lsn_t &start_id, lsn_t &stop_id, byte *buf, uint buf_len);
1715
1716 /** Set the latest stop LSN to the checkpoint LSN at the time it's called. */
1717 void post_recovery_init();
1718
1719 /** Recover the archiver system at the time of startup. Recover information
1720 related to all the durable groups and start archiving if any group was active
1721 at the time of crash/shutdown.
1722 @return error code */
1723 dberr_t recover();
1724
1725#ifdef UNIV_DEBUG
1726 /** Print information related to the archiver for debugging purposes. */
1727 void print();
1728#endif
1729
1730 /** Set the state of the archiver system to read only. */
1732
1733 /** Check if archiver system is in initial state
1734 @return true, if page ID archiver state is #ARCH_STATE_INIT */
1735 bool is_init() const { return (m_state == ARCH_STATE_INIT); }
1736
1737 /** Check if archiver system is active
1738 @return true, if page ID archiver state is #ARCH_STATE_ACTIVE or
1739 #ARCH_STATE_PREPARE_IDLE. */
1740 bool is_active() const {
1742 }
1743
1744 /** @return true if in abort state */
1745 bool is_abort() const { return (m_state == ARCH_STATE_ABORT); }
1746
1747 /** Get the mutex protecting concurrent start, stop operations required
1748 for initialising group during recovery.
1749 @return mutex */
1750 ib_mutex_t *get_mutex() { return (&m_mutex); }
1751
1752 /** @return operation mutex */
1753 ib_mutex_t *get_oper_mutex() { return (&m_oper_mutex); }
1754
1755 /** Fetch the system client context.
1756 @return system client context. */
1758
1759 /** @return the latest stop LSN */
1761
1762 /** Disable copy construction */
1763 Arch_Page_Sys(Arch_Page_Sys const &) = delete;
1764
1765 /** Disable assignment */
1767
1768 private:
1769 class Recovery;
1770
1771 /** Wait for archive system to come out of #ARCH_STATE_PREPARE_IDLE.
1772 If the system is preparing to idle, #start needs to wait
1773 for it to come to idle state.
1774 @return true, if successful
1775 false, if needs to abort */
1776 bool wait_idle();
1777
1778 /** Check if the gap from last reset is short.
1779 If not many page IDs are added till last reset, we avoid
1780 taking a new reset point
1781 @return true, if the gap is small. */
1782 bool is_gap_small();
1783
1784 /** Enable tracking pages in all buffer pools.
1785 @param[in] tracking_lsn track pages from this LSN */
1786 void set_tracking_buf_pool(lsn_t tracking_lsn);
1787
1788 /** Track pages for which IO is already started. */
1789 void track_initial_pages();
1790
1791 /** Flush the blocks to disk.
1792 @param[out] wait true, if no more data to archive
1793 @return error code */
1794 dberr_t flush_blocks(bool *wait);
1795
1796 /** Flush all the blocks which are ready to be flushed but not flushed.
1797 @param[out] cur_pos position of block which needs to be flushed
1798 @param[in] end_pos position of block until which the blocks need to
1799 be flushed
1800 @return error code */
1802
1803 /** Do a partial flush of the current active block
1804 @param[in] cur_pos position of block which needs to be flushed
1805 @param[in] partial_reset_block_flush true if reset block needs to be
1806 flushed
1807 @return error code */
1809 bool partial_reset_block_flush);
1810
1811 private:
1812 /** Mutex protecting concurrent start, stop operations */
1813 ib_mutex_t m_mutex;
1814
1815 /** Archiver system state. */
1817
1818 /** List of log archive groups */
1820
1821 /** Position where last client started archiving */
1823
1824 /** LSN when last client started archiving */
1826
1827 /** Latest LSN until where the tracked pages have been flushed. */
1829
1830 /** LSN until where the groups are purged. */
1832
1833 /** Mutex protecting concurrent operation on data */
1834 ib_mutex_t m_oper_mutex;
1835
1836 /** Current archive group */
1838
1839 /** In memory data buffer */
1841
1842 /** Position to add new page ID */
1844
1845 /** Position to add new reset element */
1847
1848 /** Position set to explicitly request the flush archiver to flush until
1849 this position.
1850 @note this is always increasing and is only updated by the requester thread
1851 like checkpoint */
1853
1854 /** Block number set to explicitly request the flush archiver to partially
1855 flush the current active block with reset LSN.
1856 @note this is always increasing and is only updated by the requester thread
1857 like checkpoint */
1858 uint64_t m_request_blk_num_with_lsn{std::numeric_limits<uint64_t>::max()};
1859
1860 /** Block number set once the flush archiver partially flushes the current
1861 active block with reset LSN.
1862 @note this is always increasing and is only updated by the requester thread
1863 like checkpoint */
1864 uint64_t m_flush_blk_num_with_lsn{std::numeric_limits<uint64_t>::max()};
1865
1866 /** Position for start flushing
1867 @note this is always increasing and is only updated by the page archiver
1868 thread */
1870
1871 /** The index of the file the last reset belonged to. */
1873
1874 /** System client. */
1876};
1877
1878/** Redo log archiver system global */
1880
1881/** Dirty page ID archiver system global */
1883
1884#endif /* ARCH_ARCH_INCLUDE */
void arch_free()
Free Page and Log archiver system.
Definition: arch0arch.cc:152
int start_page_archiver_background()
Start page archiver background thread.
Definition: arch0arch.cc:592
const uint MAX_ARCH_PAGE_FILE_NAME_LEN
Max string length for archive page file name.
Definition: arch0arch.h:76
Arch_Page_Dblwr_Offset
Page Archive doublewrite buffer block offsets.
Definition: arch0arch.h:232
@ ARCH_PAGE_DBLWR_PARTIAL_FLUSH_PAGE
Definition: arch0arch.h:240
@ ARCH_PAGE_DBLWR_RESET_PAGE
Archive doublewrite buffer page offset for RESET page.
Definition: arch0arch.h:234
@ ARCH_PAGE_DBLWR_FULL_FLUSH_PAGE
Definition: arch0arch.h:237
Arch_State
Archiver system state.
Definition: arch0arch.h:159
@ ARCH_STATE_INIT
Archiver is initialized.
Definition: arch0arch.h:161
@ ARCH_STATE_PREPARE_IDLE
Archiver is processing last data chunks before idle state.
Definition: arch0arch.h:167
@ ARCH_STATE_ACTIVE
Archiver is active and archiving data.
Definition: arch0arch.h:164
@ ARCH_STATE_ABORT
Archiver is aborted.
Definition: arch0arch.h:176
@ ARCH_STATE_READ_ONLY
Server is in read only mode, and hence the archiver.
Definition: arch0arch.h:173
@ ARCH_STATE_IDLE
Archiver is idle.
Definition: arch0arch.h:170
Arch_Blk_Flush_Type
Archiver block flush type.
Definition: arch0arch.h:222
@ ARCH_FLUSH_NORMAL
Flush when block is full.
Definition: arch0arch.h:224
@ ARCH_FLUSH_PARTIAL
Flush partial block.
Definition: arch0arch.h:228
Arch_Blk_Type
Archiver block type.
Definition: arch0arch.h:213
@ ARCH_DATA_BLOCK
Definition: arch0arch.h:218
@ ARCH_RESET_BLOCK
Definition: arch0arch.h:215
const char ARCH_PAGE_DIR[]
Archive Page group directory prefix.
Definition: arch0arch.h:51
Arch_Page_Sys * arch_page_sys
Dirty page ID archiver system global.
Definition: arch0arch.cc:40
void log_archiver_thread()
Log archiver background thread.
Definition: arch0arch.cc:615
int start_log_archiver_background()
Start log archiver background thread.
Definition: arch0arch.cc:570
void arch_remove_dir(const char *dir_path, const char *dir_name)
Remove group directory and the files related to page and log archiving.
Definition: arch0arch.cc:90
os_event_t page_archiver_thread_event
Archiver thread event to signal that data is available.
Definition: arch0page.cc:51
const char ARCH_PAGE_FILE[]
Archive page file prefix.
Definition: arch0arch.h:57
void arch_remove_file(const char *file_path, const char *file_name)
Remove files related to page and log archiving.
Definition: arch0arch.cc:60
constexpr uint ARCH_PAGE_BLK_SIZE
Memory block size.
Definition: arch0arch.h:91
Arch_Client_State
Archiver client state.
Definition: arch0arch.h:114
@ ARCH_CLIENT_STATE_STOPPED
Archiving stopped by client.
Definition: arch0arch.h:122
@ ARCH_CLIENT_STATE_INIT
Client is initialized.
Definition: arch0arch.h:116
@ ARCH_CLIENT_STATE_STARTED
Archiving started by client.
Definition: arch0arch.h:119
std::deque< Arch_Reset_File > Arch_Reset
Definition: arch0arch.h:347
uint32_t Arch_group_uuid
Number which tries to uniquely identify the archived data (unless it is zero, which stands for unsupp...
Definition: arch0arch.h:838
const uint MAX_ARCH_DIR_NAME_LEN
Max string length for archive group directory name.
Definition: arch0arch.h:81
void page_archiver_thread()
Page archiver background thread.
Definition: arch0page.cc:54
constexpr char ARCH_PAGE_GROUP_DURABLE_FILE_NAME[]
File name for the durable file which indicates whether a group was made durable or not.
Definition: arch0arch.h:64
const uint MAX_ARCH_LOG_FILE_NAME_LEN
Max string length for archive log file name.
Definition: arch0arch.h:71
Arch_Grp_List::iterator Arch_Grp_List_Iter
An iterator for archive group.
Definition: arch0arch.h:1303
Arch_Log_Sys * arch_log_sys
Redo log archiver system global.
Definition: arch0arch.cc:37
os_event_t log_archiver_thread_event
Archiver thread event to signal that data is available.
Definition: arch0arch.cc:43
const char ARCH_LOG_DIR[]
Archive Log group directory prefix.
Definition: arch0arch.h:48
dberr_t arch_init()
Initialize Page and Log archiver system.
Definition: arch0arch.cc:118
std::list< Arch_Group *, ut::allocator< Arch_Group * > > Arch_Grp_List
A list of archive groups.
Definition: arch0arch.h:1300
std::vector< Arch_Block *, ut::allocator< Arch_Block * > > Arch_Block_Vec
Vector of page archive in memory blocks.
Definition: arch0arch.h:1505
const uint MAX_LSN_DECIMAL_DIGIT
Byte length for printing LSN.
Definition: arch0arch.h:68
const char ARCH_DIR[]
Archive directory prefix.
Definition: arch0arch.h:45
bool arch_wake_threads()
Wakes up archiver threads.
Definition: arch0arch.cc:47
Arch_Blk_State
Archived data block state.
Definition: arch0arch.h:198
@ ARCH_BLOCK_READY_TO_FLUSH
Data block is full but not flushed to disk.
Definition: arch0arch.h:206
@ ARCH_BLOCK_INIT
Data block is initialized.
Definition: arch0arch.h:200
@ ARCH_BLOCK_ACTIVE
Data block is active and having data.
Definition: arch0arch.h:203
@ ARCH_BLOCK_FLUSHED
Data block is flushed and can be reused.
Definition: arch0arch.h:209
const char ARCH_LOG_FILE[]
Archive log file prefix.
Definition: arch0arch.h:54
static mysql_service_status_t init()
Component initialization.
Definition: audit_api_message_emit.cc:571
#define MYSQL_THD
Definition: backup_page_tracker.h:38
The database buffer pool high-level routines.
In memory data block in Page ID archiving system.
Definition: arch0arch.h:350
uint m_size
Total block size in bytes.
Definition: arch0arch.h:506
static uint64_t get_block_number(byte *block)
Get the block number from the block header.
Definition: arch0page.cc:1196
bool add_page(buf_page_t *page, Arch_Page_Pos *pos)
Add page ID to current block.
Definition: arch0page.cc:1290
Arch_Block(byte *blk_buf, uint size, Arch_Blk_Type type)
Constructor: Initialize elements.
Definition: arch0arch.h:356
uint get_data_len() const
Definition: arch0arch.h:426
uint64_t get_number() const
Definition: arch0arch.h:437
static bool validate(byte *block)
Check if the block data is valid.
Definition: arch0page.cc:1229
static uint64_t get_file_offset(uint64_t block_num, Arch_Blk_Type type)
Fetch the offset for a block in the archive file.
Definition: arch0page.cc:1208
uint64_t m_number
Unique block number.
Definition: arch0arch.h:512
byte * m_data
Block data buffer.
Definition: arch0arch.h:500
bool get_data(Arch_Page_Pos *read_pos, uint read_len, byte *read_buff)
Copy page Ids from this block at read position to a buffer.
Definition: arch0page.cc:1326
static uint32_t get_checksum(byte *block)
Get the checksum stored in the block header.
Definition: arch0page.cc:1204
lsn_t m_oldest_lsn
Oldest LSN of all the page IDs added to the block since the last checkpoint.
Definition: arch0arch.h:523
Arch_Blk_Type m_type
Type of block.
Definition: arch0arch.h:515
bool is_init() const
Check if block is initialised or not.
Definition: arch0arch.h:374
lsn_t get_oldest_lsn() const
Get oldest LSN among the pages that are added to this block.
Definition: arch0arch.h:444
dberr_t flush(Arch_Group *file_group, Arch_Blk_Flush_Type type)
Flush this block to the file group.
Definition: arch0page.cc:1359
bool is_active() const
Definition: arch0arch.h:376
bool is_flushable() const
Check if the block can be flushed or not.
Definition: arch0arch.h:379
Arch_Blk_State m_state
State of the block.
Definition: arch0arch.h:509
bool set_data(uint read_len, byte *read_buff, uint read_offset)
Copy page Ids from a buffer to this block.
Definition: arch0page.cc:1342
lsn_t get_stop_lsn() const
Definition: arch0arch.h:440
void set_reset_lsn(lsn_t reset_lsn)
Set the reset length of the block.
Definition: arch0arch.h:434
void update_block_header(lsn_t stop_lsn, lsn_t reset_lsn)
Definition: arch0page.cc:1246
void add_reset(lsn_t reset_lsn, Arch_Page_Pos reset_pos)
Definition: arch0page.cc:1404
static lsn_t get_reset_lsn(byte *block)
Get the reset lsn stored in the block header.
Definition: arch0page.cc:1200
Arch_Blk_State get_state() const
Get current state of the block.
Definition: arch0arch.h:448
static uint get_file_index(uint64_t block_num, Arch_Blk_Type type)
Get file index of the file the block belongs to.
Definition: arch0page.cc:1164
lsn_t m_stop_lsn
Checkpoint lsn at the time the last page ID was added to the block.
Definition: arch0arch.h:519
lsn_t m_reset_lsn
Start LSN or the last reset LSN of the group.
Definition: arch0arch.h:526
void begin_write(Arch_Page_Pos pos)
Set the block ready to begin writing page ID.
Definition: arch0page.cc:1263
static Arch_Blk_Type get_type(byte *block)
Get block type from the block header.
Definition: arch0page.cc:1183
void end_write()
End writing to a block.
Definition: arch0page.cc:1283
uint m_data_len
Block data length in bytes.
Definition: arch0arch.h:503
void set_data_len(uint data_len)
Set the data length of the block.
Definition: arch0arch.h:430
void copy_data(const Arch_Block *block)
Do a deep copy of the members of the block passed as the parameter.
Definition: arch0page.cc:1428
void set_flushed()
Set current block flushed.
Definition: arch0arch.h:383
Doublewrite buffer context.
Definition: arch0recv.h:135
Recovery system data structure for the archiver.
Definition: arch0recv.h:303
Archiver file context.
Definition: arch0arch.h:531
dberr_t open(bool read_only, lsn_t start_lsn, uint file_index, uint64_t file_offset, uint64_t file_size)
Open a file at specific index.
Definition: arch0arch.cc:368
bool is_closed() const
Check if file is closed.
Definition: arch0arch.h:637
char * m_name_buf
File name buffer.
Definition: arch0arch.h:787
bool find_reset_point(lsn_t check_lsn, Arch_Point &reset_point)
Find the appropriate reset LSN that is less than or equal to the given lsn and fetch the reset point.
Definition: arch0page.cc:397
bool validate(Arch_Group *group, uint file_index, lsn_t start_lsn, uint &reset_count)
Check if the information maintained in the memory is the same as the information maintained in the fi...
Definition: arch0page.cc:737
bool find_stop_point(Arch_Group *group, lsn_t check_lsn, Arch_Point &stop_point, Arch_Page_Pos last_pos)
Find the first stop LSN that is greater than the given LSN and fetch the stop point.
Definition: arch0page.cc:474
uint64_t m_offset
Current file offset.
Definition: arch0arch.h:815
pfs_os_file_t m_file
Current file descriptor.
Definition: arch0arch.h:806
lsn_t purge(lsn_t begin_lsn, lsn_t end_lsn, lsn_t purge_lsn)
Purge archived files until the specified purge LSN.
Definition: arch0page.cc:786
const char * m_file_name
File name prefix.
Definition: arch0arch.h:803
void build_dir_name(lsn_t dir_lsn, char *buffer, uint length)
Construct group directory name.
Definition: arch0arch.cc:559
uint get_index() const
Get current file index.
Definition: arch0arch.h:671
std::vector< lsn_t > m_stop_points
Vector of stop points corresponding to a file.
Definition: arch0arch.h:832
bool validate_stop_point_in_file(Arch_Group *group, pfs_os_file_t file, uint file_index)
Check if the stop LSN maintained in the memory is the same as the information maintained in the files...
Definition: arch0page.cc:569
uint64_t m_size
File size limit in bytes.
Definition: arch0arch.h:818
dberr_t init(const char *path, const char *base_dir, const char *base_file, uint num_files)
Initializes archiver file context.
Definition: arch0arch.cc:315
uint64_t bytes_left() const
Check how much is left in current file.
Definition: arch0arch.h:641
uint64_t get_phy_size() const
Get the physical size of a file that is open in this context.
Definition: arch0arch.h:679
void close()
Close file, if open.
Definition: arch0arch.h:628
bool validate_reset_block_in_file(pfs_os_file_t file, uint file_index, uint &reset_count)
Check if the reset information maintained in the memory is the same as the information maintained in ...
Definition: arch0page.cc:620
Arch_File_Ctx()
Constructor: Initialize members.
Definition: arch0arch.h:536
bool delete_file(uint file_index, lsn_t begin_lsn)
Delete a single file belonging to the specified file index.
Definition: arch0arch.cc:279
void build_name(uint idx, lsn_t dir_lsn, char *buffer, uint length)
Construct file name at specific index.
Definition: arch0arch.cc:527
void delete_files(lsn_t begin_lsn)
Delete all files for this archive group.
Definition: arch0arch.cc:301
uint m_count
Current number of files in the archive group.
Definition: arch0arch.h:812
dberr_t write(Arch_File_Ctx *from_file, byte *from_buffer, uint offset, uint size)
Write data to this file context from the given file offset.
Definition: arch0page.cc:450
dberr_t open_new(lsn_t start_lsn, uint64_t new_file_size, uint64_t initial_file_size)
Add a new file and open.
Definition: arch0arch.cc:433
lsn_t fetch_reset_lsn(uint64_t block_num)
Fetch reset lsn of a particular reset point pertaining to a file.
Definition: arch0recv.cc:740
uint64_t get_size() const
Get the logical size of a file.
Definition: arch0arch.h:663
uint m_base_len
Fixed length part of the file.
Definition: arch0arch.h:794
const char * m_path_name
Fixed part of the path to file.
Definition: arch0arch.h:797
void save_reset_point_in_mem(lsn_t lsn, Arch_Page_Pos pos)
Update the reset information in the in-memory structure that we maintain for faster access.
Definition: arch0page.cc:369
void flush()
Flush file.
Definition: arch0arch.h:621
dberr_t open_next(lsn_t start_lsn, uint64_t file_offset, uint64_t file_size)
Open next file for read.
Definition: arch0arch.cc:443
void get_status(std::vector< std::pair< lsn_t, bool > > &status)
Fetch the status of the page tracking system.
Definition: arch0arch.h:748
dberr_t resize_and_overwrite_with_zeros(uint64_t file_size)
Resize file to provided size and overwrite the whole file with 0x00.
Definition: arch0arch.cc:470
dberr_t read(byte *to_buffer, const uint64_t offset, uint size)
Read data from the current file that is open.
Definition: arch0arch.cc:456
uint get_count() const
Get number of files.
Definition: arch0arch.h:675
~Arch_File_Ctx()
Destructor: Close open file and free resources.
Definition: arch0arch.h:539
uint m_name_len
File name buffer length.
Definition: arch0arch.h:790
const char * m_dir_name
Directory name prefix.
Definition: arch0arch.h:800
uint m_index
File index within the archive group.
Definition: arch0arch.h:809
void update_stop_point(uint file_index, lsn_t stop_lsn)
Update stop lsn of a file in the group.
Definition: arch0page.cc:359
Arch_Reset m_reset
Queue of file structure holding reset information pertaining to their respective files in a group.
Definition: arch0arch.h:824
uint64_t get_offset() const
Definition: arch0arch.h:667
Recovery system data structure for the archiver.
Definition: arch0recv.h:258
Contiguous archived data for redo log or page tracking.
Definition: arch0arch.h:843
uint m_ref_count
Number of clients referencing the group.
Definition: arch0arch.h:1258
std::function< dberr_t(uint64_t start_offset, byte *header)> Get_file_header_callback
Function responsible to format the header of a new file which is created, when the stream of data is ...
Definition: arch0arch.h:851
int read_from_file(Arch_Page_Pos *read_pos, uint read_len, byte *read_buff)
Get page IDs from archived file.
Definition: arch0page.cc:2906
dberr_t prepare_file_with_header(uint64_t start_offset, Get_file_header_callback &get_header)
Create a new file and write the header.
Definition: arch0arch.cc:168
void adjust_end_lsn(lsn_t &stop_lsn, uint32_t &blk_len)
Adjust end LSN to end of file.
Definition: arch0log.cc:398
uint get_file_count() const
Get the total number of archived files belonging to this group.
Definition: arch0arch.h:1095
char * m_durable_file_name
File name for the durable file which indicates whether a group was made durable or not.
Definition: arch0arch.h:1250
void get_file_name(uint idx, char *name_buf, uint buf_len)
Get archived file name at specific index in this group.
Definition: arch0arch.h:1160
int mark_durable()
Mark the group durable by creating a file in the respective group directory.
Definition: arch0page.cc:243
dberr_t open_file(Arch_Page_Pos write_pos, bool create_new)
Open the file which was open at the time of a crash, during crash recovery, and set the file offset t...
Definition: arch0page.cc:336
bool is_active() const
Check if archiving is going on for this group.
Definition: arch0arch.h:1015
Arch_Group & operator=(Arch_Group const &)=delete
Disable assignment.
char * m_active_file_name
To know which group was active at the time of a crash/shutdown during recovery we create an empty fil...
Definition: arch0arch.h:1241
bool find_reset_point(lsn_t check_lsn, Arch_Point &reset_point)
Find the appropriate reset LSN that is less than or equal to the given lsn and fetch the reset point.
Definition: arch0arch.h:1057
int mark_active()
Mark the group active by creating a file in the respective group directory.
Definition: arch0page.cc:211
pfs_os_file_t m_durable_file
File descriptor for a file to indicate that the group was made durable or not.
Definition: arch0arch.h:1255
void update_stop_point(Arch_Page_Pos pos, lsn_t stop_lsn)
Update stop lsn of a file in the group.
Definition: arch0arch.h:1135
dberr_t recover(Arch_Recv_Group_Info &group_info, Arch_Dblwr_Ctx *dblwr_ctx)
Recover the information belonging to this group from the archived files.
Definition: arch0recv.cc:473
bool is_referenced() const
Check if any client (durable or not) is attached to the archiver.
Definition: arch0arch.h:1099
uint64_t get_file_size() const
Get the current file size for this group.
Definition: arch0arch.h:1170
uint m_num_active
Number of clients for which archiving is in progress.
Definition: arch0arch.h:1264
int read_data(Arch_Page_Pos cur_pos, byte *buff, uint buff_len)
Parse block for block info (header/data).
Definition: arch0page.cc:2956
dberr_t build_active_file_name()
Construct file name for the active file which indicates whether a group is active or not.
Definition: arch0page.cc:165
Arch_group_uuid m_uuid
UUID generated for this arch group.
Definition: arch0arch.h:1282
Arch_File_Ctx m_file_ctx
Archive file context.
Definition: arch0arch.h:1285
~Arch_Group()
Destructor: Delete all files for non-durable archiving.
Definition: arch0page.cc:86
uint64_t m_file_size
Size of file used when a new file is being created.
Definition: arch0arch.h:1279
uint detach(lsn_t stop_lsn, Arch_Page_Pos *stop_pos)
Detach a client when archiving is stopped by the client.
Definition: arch0arch.h:941
Arch_Group(Arch_Group const &)=delete
Disable copy construction.
static dberr_t write_to_doublewrite_file(Arch_File_Ctx *from_file, byte *from_buffer, uint write_size, Arch_Page_Dblwr_Offset offset)
Write to the doublewrite buffer before writing archived data to a file.
Definition: arch0page.cc:112
void close_file_ctxs()
Definition: arch0arch.h:896
Arch_Page_Pos get_stop_pos() const
Definition: arch0arch.h:1180
uint m_header_len
Header length for the archived files.
Definition: arch0arch.h:1276
ib_mutex_t * m_arch_mutex
Mutex protecting concurrent operations by multiple clients.
Definition: arch0arch.h:1295
dberr_t init_file_ctx(const char *path, const char *base_dir, const char *base_file, uint num_files, uint64_t file_size, Arch_group_uuid uuid)
Initialize the file context for the archive group.
Definition: arch0arch.h:887
pfs_os_file_t m_active_file
File descriptor for a file required to indicate that the group was active at the time of crash during...
Definition: arch0arch.h:1245
void save_reset_point_in_mem(lsn_t lsn, Arch_Page_Pos pos)
Update the reset information in the in-memory structure that we maintain for faster access.
Definition: arch0arch.h:1128
bool is_durable_client_active() const
Check if any client requiring durable archiving is active.
Definition: arch0arch.h:1105
Arch_group_uuid get_uuid() const
Definition: arch0arch.h:1183
void get_status(std::vector< std::pair< lsn_t, bool > > &status)
Fetch the status of the page tracking system.
Definition: arch0arch.h:1188
void release(bool is_durable)
Release the archive group from a client.
Definition: arch0arch.h:961
bool find_stop_point(lsn_t check_lsn, Arch_Point &stop_point, Arch_Page_Pos write_pos)
Find the first stop LSN that is greater than the given LSN and fetch the stop point.
Definition: arch0arch.h:1067
dberr_t write_file_header(byte *from_buffer, uint length)
Write the header (RESET page) to an archived file.
Definition: arch0page.cc:314
static Arch_File_Ctx s_dblwr_file_ctx
Doublewrite buffer file context.
Definition: arch0arch.h:1289
void attach(bool is_durable)
Attach a client to the archive group.
Definition: arch0arch.h:919
lsn_t m_begin_lsn
Start LSN for the archive group.
Definition: arch0arch.h:1267
bool m_is_active
If the group is active.
Definition: arch0arch.h:1236
dberr_t write_to_file(Arch_File_Ctx *from_file, byte *from_buffer, uint length, bool partial_write, bool do_persist, Get_file_header_callback new_file)
Archive data to one or more files.
Definition: arch0arch.cc:187
bool validate_info_in_files()
Check if the information maintained in the memory is the same as the information maintained in the fi...
Definition: arch0page.cc:710
Arch_Group(lsn_t start_lsn, uint header_len, ib_mutex_t *mutex)
Constructor: Initialize members.
Definition: arch0arch.h:857
uint purge(lsn_t purge_lsn, lsn_t &purged_lsn)
Purge archived files until the specified purge LSN.
Definition: arch0page.cc:848
Arch_Page_Pos m_stop_pos
Stop position of the group, if it's not active.
Definition: arch0arch.h:1273
lsn_t get_end_lsn() const
Definition: arch0arch.h:1177
void get_dir_name(char *name_buf, uint buf_len)
Get the directory name for this archive group.
Definition: arch0arch.h:1224
void adjust_copy_length(lsn_t arch_lsn, uint32_t &copy_len)
Adjust redo copy length to end of file.
Definition: arch0log.cc:411
static void shutdown()
Operations to be done at the time of shutdown.
Definition: arch0arch.h:1122
void disable(lsn_t end_lsn)
Mark archive group inactive.
Definition: arch0arch.h:909
static dberr_t init_dblwr_file_ctx(const char *path, const char *base_file, uint num_files, uint64_t file_size)
Initialize the doublewrite buffer file context for the archive group.
Definition: arch0page.cc:147
dberr_t build_durable_file_name()
Construct file name for the durable file which indicates whether a group was made durable or not.
Definition: arch0page.cc:188
lsn_t get_begin_lsn() const
Get start LSN for this group.
Definition: arch0arch.h:1174
int mark_inactive()
Mark the group inactive by deleting the 'active' file.
Definition: arch0page.cc:278
lsn_t m_end_lsn
End lsn for this archive group.
Definition: arch0arch.h:1270
bool is_durable() const
Check if any client requires durable archiving.
Definition: arch0arch.h:1111
uint m_dur_ref_count
Number of clients referencing for durable archiving.
Definition: arch0arch.h:1261
Redo log archiving system.
Definition: arch0arch.h:1315
os_offset_t get_recommended_file_size() const
Get recommended archived redo file size.
Definition: arch0log.cc:204
Arch_Log_Sys(Arch_Log_Sys const &)=delete
Disable copy construction.
Arch_Log_Sys()
Constructor: Initialize members.
Definition: arch0arch.h:1318
void arch_mutex_exit()
Release redo log archiver mutex.
Definition: arch0arch.h:1415
void force_abort()
Force to abort the archiver (state becomes ARCH_STATE_IDLE or ARCH_STATE_ABORT).
Definition: arch0log.cc:489
void update_state_low(Arch_State state)
Update m_state to the given state.
Definition: arch0log.cc:925
Arch_State check_set_state(bool is_abort, lsn_t *archived_lsn, uint *to_archive)
Check and set log archive system state and output the amount of redo log available for archiving.
Definition: arch0log.cc:532
void arch_mutex_enter()
Acquire redo log archiver mutex.
Definition: arch0arch.h:1412
int stop(Arch_Group *group, lsn_t &stop_lsn, byte *log_blk, uint32_t &blk_len)
Stop redo log archiving.
Definition: arch0log.cc:440
lsn_t get_archived_lsn() const
Get LSN up to which redo is archived.
Definition: arch0arch.h:1349
uint m_chunk_size
Chunk size to copy redo data.
Definition: arch0arch.h:1491
Arch_Group * get_arch_group()
Get current redo log archive group.
Definition: arch0arch.h:1365
Arch_Grp_List m_group_list
List of log archive groups.
Definition: arch0arch.h:1485
int wait_archive_complete(lsn_t target_lsn)
Wait for redo log archive up to the target LSN.
Definition: arch0log.cc:764
uint64_t m_start_log_offset
System log file offset where the archiving started.
Definition: arch0arch.h:1497
void release(Arch_Group *group, bool is_durable)
Release the current group from client.
Definition: arch0log.cc:505
Arch_log_consumer m_log_consumer
Redo log consumer that can be registered to prevent consumption of redo log files which still haven't...
Definition: arch0arch.h:1501
ib_mutex_t m_mutex
Mutex to protect concurrent start, stop operations.
Definition: arch0arch.h:1473
dberr_t copy_log(Arch_File_Ctx *file_ctx, lsn_t start_lsn, uint length)
Copy redo log from file context to archiver files.
Definition: arch0log.cc:627
void update_state(Arch_State state)
Acquires log_sys's m_files_mutex, writer_mutex and calls.
Definition: arch0log.cc:918
bool is_active() const
Check if archiving is in progress.
Definition: arch0arch.h:1339
~Arch_Log_Sys()
Destructor: Free mutex.
Definition: arch0arch.h:1327
bool is_init() const
Check if archiver system is in initial state.
Definition: arch0arch.h:1345
Arch_State m_state
Archiver system state.
Definition: arch0arch.h:1479
bool wait_idle()
Wait for archive system to come out of ARCH_STATE_PREPARE_IDLE.
Definition: arch0log.cc:715
Arch_Log_Sys & operator=(Arch_Log_Sys const &)=delete
Disable assignment.
int start(Arch_Group *&group, lsn_t &start_lsn, byte *header, bool is_durable)
Start redo log archiving.
Definition: arch0log.cc:251
Arch_Group * m_current_group
Current archive group.
Definition: arch0arch.h:1488
atomic_lsn_t m_archived_lsn
System has archived log up to this LSN.
Definition: arch0arch.h:1482
uint m_start_log_index
System log file number where the archiving started.
Definition: arch0arch.h:1494
void update_header(byte *header, lsn_t file_start_lsn, lsn_t checkpoint_lsn)
Update checkpoint LSN and related information in redo log header block.
Definition: arch0log.cc:215
bool archive(bool init, Arch_File_Ctx *curr_ctx, lsn_t *arch_lsn, bool *wait)
Archive accumulated redo log in current group.
Definition: arch0log.cc:845
Recovery system data structure for the archiver.
Definition: arch0recv.h:189
Dirty page archive system.
Definition: arch0arch.h:1553
ArchPageData m_data
In memory data buffer.
Definition: arch0arch.h:1840
dberr_t flush_blocks(bool *wait)
Flush the blocks to disk.
Definition: arch0page.cc:2769
void arch_oper_mutex_enter()
Acquire dirty page ID archive operation mutex.
Definition: arch0arch.h:1627
Arch_Grp_List m_group_list
List of log archive groups.
Definition: arch0arch.h:1819
lsn_t get_latest_stop_lsn() const
Definition: arch0arch.h:1760
void get_status(std::vector< std::pair< lsn_t, bool > > &status)
Fetch the status of the page tracking system.
Definition: arch0arch.h:1668
Page_Arch_Client_Ctx * m_ctx
System client.
Definition: arch0arch.h:1875
void arch_mutex_enter()
Acquire dirty page ID archiver mutex.
Definition: arch0arch.h:1620
Arch_Page_Sys & operator=(Arch_Page_Sys const &)=delete
Disable assignment.
uint64_t m_flush_blk_num_with_lsn
Block number set once the flush archiver partially flushes the current active block with reset LSN.
Definition: arch0arch.h:1864
ib_mutex_t m_oper_mutex
Mutex protecting concurrent operation on data.
Definition: arch0arch.h:1834
Arch_Page_Pos m_reset_pos
Position to add new reset element.
Definition: arch0arch.h:1846
Arch_Page_Pos m_flush_pos
Position for start flushing.
Definition: arch0arch.h:1869
uint m_last_reset_file_index
The index of the file the last reset belonged to.
Definition: arch0arch.h:1872
Page_Arch_Client_Ctx * get_sys_client() const
Fetch the system client context.
Definition: arch0arch.h:1757
ib_mutex_t m_mutex
Mutex protecting concurrent start, stop operations.
Definition: arch0arch.h:1813
void post_recovery_init()
Set the latest stop LSN to the checkpoint LSN at the time it's called.
Definition: arch0page.cc:1597
int stop(Arch_Group *group, lsn_t *stop_lsn, Arch_Page_Pos *stop_pos, bool is_durable)
Stop dirty page ID archiving.
Definition: arch0page.cc:2579
dberr_t flush_active_block(Arch_Page_Pos cur_pos, bool partial_reset_block_flush)
Do a partial flush of the current active block.
Definition: arch0page.cc:2719
bool get_pages(Arch_Group *group, Arch_Page_Pos *read_pos, uint read_len, byte *read_buff)
Get page IDs from a specific position.
Definition: arch0page.cc:1791
bool is_gap_small()
Check if the gap from last reset is short.
Definition: arch0page.cc:2144
int recovery_load_and_start(const Arch_Recv_Group_Info &info)
Start dirty page ID archiving during recovery.
Definition: arch0page.cc:2266
void update_stop_info(Arch_Block *cur_blk)
Update the stop point in all the required structures.
Definition: arch0page.cc:3162
bool save_reset_point(bool is_durable)
Definition: arch0page.cc:2970
void track_page(buf_page_t *bpage, lsn_t track_lsn, lsn_t frame_lsn, bool force)
Check and add page ID to archived data.
Definition: arch0page.cc:1687
bool is_active() const
Check if archiver system is active.
Definition: arch0arch.h:1740
Arch_Page_Sys()
Constructor: Initialize elements and create mutex.
Definition: arch0page.cc:1566
void flush_at_checkpoint(lsn_t checkpoint_lsn)
Flush all the unflushed inactive blocks and flush the active block if required.
Definition: arch0page.cc:1609
void set_tracking_buf_pool(lsn_t tracking_lsn)
Enable tracking pages in all buffer pools.
Definition: arch0page.cc:2248
void set_read_only_mode()
Set the state of the archiver system to read only.
Definition: arch0arch.h:1731
Arch_Group * m_current_group
Current archive group.
Definition: arch0arch.h:1837
~Arch_Page_Sys()
Destructor: Free memory buffer and mutexes.
Definition: arch0page.cc:1579
int start(Arch_Group **group, lsn_t *start_lsn, Arch_Page_Pos *start_pos, bool is_durable, bool restart, bool recovery)
Start dirty page ID archiving.
Definition: arch0page.cc:2326
Arch_Page_Pos m_last_pos
Position where last client started archiving.
Definition: arch0arch.h:1822
ib_mutex_t * get_oper_mutex()
Definition: arch0arch.h:1753
uint64_t m_request_blk_num_with_lsn
Block number set to explicitly request the flush archiver to partially flush the current active block...
Definition: arch0arch.h:1858
void track_initial_pages()
Track pages for which IO is already started.
Definition: arch0page.cc:2167
bool wait_idle()
Wait for archive system to come out of ARCH_STATE_PREPARE_IDLE.
Definition: arch0page.cc:2095
Arch_Page_Pos m_request_flush_pos
Position set to explicitly request the flush archiver to flush until this position.
Definition: arch0arch.h:1852
dberr_t recover()
Recover the archiver system at the time of startup.
Definition: arch0recv.cc:37
void release(Arch_Group *group, bool is_durable, Arch_Page_Pos start_pos)
Release the current group from client.
Definition: arch0page.cc:2665
void arch_oper_mutex_exit()
Release page ID archiver operatiion mutex.
Definition: arch0arch.h:1630
lsn_t m_latest_purged_lsn
LSN until where the groups are purged.
Definition: arch0arch.h:1831
void arch_mutex_exit()
Release page ID archiver mutex.
Definition: arch0arch.h:1623
bool is_abort() const
Definition: arch0arch.h:1745
void print()
Print information related to the archiver for debugging purposes.
Definition: arch0page.cc:3175
uint purge(lsn_t *purge_lsn)
Purge the archived files until the specified purge LSN.
Definition: arch0page.cc:3101
dberr_t flush_inactive_blocks(Arch_Page_Pos &cur_pos, Arch_Page_Pos end_pos)
Flush all the blocks which are ready to be flushed but not flushed.
Definition: arch0page.cc:2689
Arch_Page_Pos m_write_pos
Position to add new page ID.
Definition: arch0arch.h:1843
lsn_t m_latest_stop_lsn
Latest LSN until where the tracked pages have been flushed.
Definition: arch0arch.h:1828
bool is_init() const
Check if archiver system is in initial state.
Definition: arch0arch.h:1735
Arch_State m_state
Archiver system state.
Definition: arch0arch.h:1816
bool archive(bool *wait)
Archive dirty page IDs in current group.
Definition: arch0page.cc:2829
int fetch_group_within_lsn_range(lsn_t &start_id, lsn_t &stop_id, Arch_Group **group)
Get the group which has tracked pages between the start_id and stop_id.
Definition: arch0page.cc:3048
Arch_Page_Sys(Arch_Page_Sys const &)=delete
Disable copy construction.
bool wait_for_reset_info_flush(uint64_t request_block)
Wait for reset info to be flushed to disk.
Definition: arch0page.cc:3027
ib_mutex_t * get_mutex()
Get the mutex protecting concurrent start, stop operations required for initialising group during rec...
Definition: arch0arch.h:1750
bool get_num_pages(Arch_Page_Pos start_pos, Arch_Page_Pos stop_pos, uint64_t &num_pages)
Given start and stop position find number of pages tracked between them.
Definition: arch0page.cc:1973
lsn_t m_last_lsn
LSN when last client started archiving.
Definition: arch0arch.h:1825
Info related to each group parsed at different stages of page archive recovery.
Definition: arch0recv.h:42
Definition: arch0arch.h:1305
lsn_t get_consumed_lsn() const override
Definition: arch0log.cc:948
const std::string & get_name() const override
Definition: arch0log.cc:943
void consumption_requested() override
Request the log consumer to consume faster.
Definition: arch0log.cc:958
Guard to release resources safely.
Definition: arch0arch.h:275
std::function< void()> m_cleanup
Function to release the resource.
Definition: arch0arch.h:295
void cleanup()
Manually release the resource.
Definition: arch0arch.h:288
Arch_scope_guard(std::function< void()> function)
Attach a function to the guard which releases some resource.
Definition: arch0arch.h:278
~Arch_scope_guard()
Release the resources automatically at the time of destruction.
Definition: arch0arch.h:281
Definition: log0consumer.h:40
Dirty page archiver client context.
Definition: arch0page.h:170
Definition: buf0buf.h:1153
int page
Definition: ctype-mb.cc:1224
dberr_t
Definition: db0err.h:39
constexpr lsn_t LSN_MAX
Maximum possible lsn value is slightly higher than the maximum sn value, because lsn sequence enumera...
Definition: log0constants.h:159
std::atomic< lsn_t > atomic_lsn_t
Alias for atomic based on lsn_t.
Definition: log0types.h:82
uint64_t lsn_t
Type used for all log sequence number storage and arithmetic.
Definition: log0types.h:63
static my_off_t start_offset
Definition: myisamlog.cc:101
static size_t file_size
Definition: mysql_config_editor.cc:72
static char * path
Definition: mysqldump.cc:149
Definition: buf0block_hint.cc:30
constexpr value_type read_only
Definition: classic_protocol_constants.h:213
Definition: os0file.h:89
bool length(const dd::Spatial_reference_system *srs, const Geometry *g1, double *length, bool *null) noexcept
Computes the length of linestrings and multilinestrings.
Definition: length.cc:76
std::string file_name(Log_file_id file_id)
Provides name of the log file with the given file id, e.g.
Definition: log0pre_8_0_30.cc:94
static int wait(mysql_cond_t *that, mysql_mutex_t *mutex_arg, const char *, unsigned int)
Definition: mysql_cond_v1_native.cc:63
size_t size(const char *const c)
Definition: base64.h:46
mutable_buffer buffer(void *p, size_t n) noexcept
Definition: buffer.h:418
std::vector< T, ut::allocator< T > > vector
Specialization of vector which uses allocator.
Definition: ut0new.h:2876
void free(void *ptr) noexcept
Releases storage which has been dynamically allocated through any of the ut::malloc*(),...
Definition: ut0new.h:719
#define OS_FILE_PREFIX
Prefix all files and directory created under data directory with special string so that it never conf...
Definition: os0file.h:68
constexpr uint32_t OS_FILE_LOG_BLOCK_SIZE
The next value should be smaller or equal to the smallest sector size used on any disk.
Definition: os0file.h:192
#define os_file_close(file)
Definition: os0file.h:1308
os_file_size_t os_file_get_size(const char *filename)
Gets a file size.
Definition: os0file.cc:3413
#define os_file_flush(file)
Definition: os0file.h:1330
static constexpr os_fd_t OS_FILE_CLOSED
Definition: os0file.h:151
uint64_t os_offset_t
File offset in bytes.
Definition: os0file.h:87
int(* Page_Track_Callback)(MYSQL_THD thd, const unsigned char *buffer, size_t buf_len, int num_pages, void *user_ctx)
Page tracking callback function.
Definition: page_track_service.h:66
required uint32 status
Definition: replication_asynchronous_connection_failover.proto:61
required string type
Definition: replication_group_member_actions.proto:34
Page archiver in memory data.
Definition: arch0arch.h:1508
Arch_Block * m_partial_flush_block
Temporary block used to copy active block for partial flush.
Definition: arch0arch.h:1537
uint m_block_size
Block size in bytes.
Definition: arch0arch.h:1540
Arch_Block * get_block(Arch_Page_Pos *pos, Arch_Blk_Type type)
Get the block for a position.
Definition: arch0page.cc:1546
bool init()
Allocate buffer and initialize blocks.
Definition: arch0page.cc:1454
uint m_num_data_blocks
Total number of blocks.
Definition: arch0arch.h:1543
Arch_Block * get_partial_flush_block() const
Definition: arch0arch.h:1526
byte * m_buffer
In memory buffer.
Definition: arch0arch.h:1546
Arch_Block * m_reset_block
Reset block.
Definition: arch0arch.h:1534
Arch_Block_Vec m_data_blocks
Vector of data blocks.
Definition: arch0arch.h:1531
void clean()
Delete blocks and buffer.
Definition: arch0page.cc:1523
ArchPageData()=default
Constructor.
Position in page ID archiving system.
Definition: arch0arch.h:299
bool operator<(Arch_Page_Pos pos)
Definition: arch0arch.h:312
uint64_t m_block_num
Unique block number.
Definition: arch0arch.h:307
void set_next()
Position in the beginning of next block.
Definition: arch0page.cc:1447
void init()
Initialize a position.
Definition: arch0page.cc:1441
uint m_offset
Offset within a block.
Definition: arch0arch.h:310
Structure which represents a point in a file.
Definition: arch0arch.h:322
Arch_Page_Pos pos
Position of the point.
Definition: arch0arch.h:327
lsn_t lsn
LSN of the point.
Definition: arch0arch.h:324
Definition: arch0arch.h:331
lsn_t m_lsn
Definition: arch0arch.h:340
uint m_file_index
Definition: arch0arch.h:336
void init()
Definition: arch0page.cc:78
std::vector< Arch_Point > m_start_point
Definition: arch0arch.h:343
InnoDB condition variable.
Definition: os0event.cc:63
Sparse file size information.
Definition: os0file.h:580
Common file descriptor for file IO instrumentation with PFS on windows and other platforms.
Definition: os0file.h:172
os_file_t m_file
Definition: os0file.h:182
@ LATCH_ID_LOG_ARCH
Definition: sync0types.h:393
constexpr uint32_t UNIV_PAGE_SIZE_DEF
Default page size for InnoDB tablespaces.
Definition: univ.i:325
#define IF_DEBUG(...)
Definition: univ.i:674
static uint64_t ut_uint64_align_down(uint64_t n, ulint align_no)
Rounds a 64-bit integer downward to a multiple of a power of 2.
#define ut_ad(EXPR)
Debug assertion.
Definition: ut0dbg.h:105
Memory primitives.
Policy based mutexes.
#define mutex_own(M)
Checks that the current thread owns the mutex.
Definition: ut0mutex.h:165
#define mutex_exit(M)
Definition: ut0mutex.h:123
#define mutex_free(M)
Definition: ut0mutex.h:125
#define mutex_enter(M)
Definition: ut0mutex.h:117
#define mutex_create(I, M)
Definition: ut0mutex.h:110
static uint64_t lsn
Definition: xcom_base.cc:446