MySQL 8.0.40
Source Code Documentation
log0sys.h
Go to the documentation of this file.
1/*****************************************************************************
2
3Copyright (c) 2013, 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/**************************************************/ /**
29 @file include/log0sys.h
30
31 Redo log - the log_sys.
32
33 *******************************************************/
34
35#ifndef log0sys_h
36#define log0sys_h
37
38#include "univ.i"
39
40/* Log_consumer */
41#include "log0consumer.h"
42
43/* Log_files_capacity */
44#include "log0files_capacity.h"
45
46/* Log_files_dict */
47#include "log0files_dict.h"
48
49/* lsn_t, Log_clock, ... */
50#include "log0types.h"
51
52/* os_event_t */
53#include "os0event.h"
54
55/* OS_FILE_LOG_BLOCK_SIZE, os_offset_t */
56#include "os0file.h"
57
58/* rw_lock_t */
59#include "sync0rw.h"
60
61/* ut::INNODB_CACHE_LINE_SIZE */
62#include "ut0cpu_cache.h"
63
64/* Link_buf */
65#include "ut0link_buf.h"
66
67/* ib_mutex_t */
68#include "ut0mutex.h"
69
70/* aligned_array_pointer, ut::vector */
71#include "ut0new.h"
72
73class THD;
74
75/** Redo log - single data structure with state of the redo log system.
76In future, one could consider splitting this to multiple data structures. */
77struct alignas(ut::INNODB_CACHE_LINE_SIZE) log_t {
78#ifndef UNIV_HOTBACKUP
79
80 /**************************************************/ /**
81
82 @name Users writing to log buffer
83
84 *******************************************************/
85
86 /** @{ */
87
88 /** Event used for locking sn */
90
91#ifdef UNIV_DEBUG
92 /** The rw_lock instance only for the debug info list */
93 /* NOTE: Just "rw_lock_t sn_lock_inst;" and direct minimum initialization
94 seem to hit the bug of Sun Studio of Solaris. */
96#endif /* UNIV_DEBUG */
97
98 /** Current sn value. Used to reserve space in the redo log,
99 and used to acquire an exclusive access to the log buffer.
100 Represents number of data bytes that have ever been reserved.
101 Bytes of headers and footers of log blocks are not included.
102 Its highest bit is used for locking the access to the log buffer. */
104
105 /** Intended sn value while x-locked. */
107
108 /** Mutex which can be used for x-lock sn value */
109 mutable ib_mutex_t sn_x_lock_mutex;
110
111 /** Aligned log buffer. Committing mini-transactions write there
112 redo records, and the log_writer thread writes the log buffer to
113 disk in background.
114 Protected by: locking sn not to add. */
117
118 /** Size of the log buffer expressed in number of data bytes,
119 that is excluding bytes for headers and footers of log blocks. */
121
122 /** Size of the log buffer expressed in number of total bytes,
123 that is including bytes for headers and footers of log blocks. */
124 size_t buf_size;
125
126#ifdef UNIV_PFS_RWLOCK
127 /** The instrumentation hook.
128 @remarks This field is rarely modified, so can not be the cause of
129 frequent cache line invalidations. However, user threads read it only during
130 mtr.commit(), which in some scenarios happens rarely enough, that the cache
131 line containing pfs_psi is evicted between mtr.commit()s causing a cache miss,
132 a stall and in consequence MACHINE_CLEARS during mtr.commit(). As this miss
133 seems inevitable, we at least want to make it really worth it. So, we put the
134 pfs_psi in the same cache line which contains buf, buf_size_sn and buf_size,
135 which are also needed during mtr.commit(). This way instead of two separate
136 cache misses, we have just one.
137 TBD: We could additionally use `lfence` to limit MACHINE_CLEARS.*/
139#endif /* UNIV_PFS_RWLOCK */
140
141 /** The recent written buffer.
142 Protected by: locking sn not to add. */
144
145 /** Used for pausing the log writer threads.
146 When paused, each user thread should write log as in the former version. */
147 std::atomic_bool writer_threads_paused;
148
149 /** Some threads waiting for the ready for write lsn by closer_event. */
151
152 /** current_ready_waiting_lsn is waited using this sig_count. */
154
155 /** The recent closed buffer.
156 Protected by: locking sn not to add. */
158
159 /** @} */
160
161 /**************************************************/ /**
162
163 @name Users <=> writer
164
165 *******************************************************/
166
167 /** @{ */
168
169 /** Maximum sn up to which there is free space in both the log buffer
170 and the log files. This is limitation for the end of any write to the
171 log buffer. Threads, which are limited need to wait, and possibly they
172 hold latches of dirty pages making a deadlock possible.
173 Protected by: writer_mutex (writes). */
175
176 /** Up to this lsn, data has been written to disk (fsync not required).
177 Protected by: writer_mutex (writes). */
179
180 /** Unaligned pointer to array with events, which are used for
181 notifications sent from the log write notifier thread to user threads.
182 The notifications are sent when write_lsn is advanced. User threads
183 wait for write_lsn >= lsn, for some lsn. Log writer advances the
184 write_lsn and notifies the log write notifier, which notifies all users
185 interested in nearby lsn values (lsn belonging to the same log block).
186 Note that false wake-ups are possible, in which case user threads
187 simply retry waiting. */
189
190 /** Number of entries in the array with writer_events. */
192
193 /** Approx. number of requests to write/flush redo since startup. */
195 std::atomic<uint64_t> write_to_file_requests_total;
196
197 /** How often redo write/flush is requested in average.
198 Measures in microseconds. Log threads do not spin when
199 the write/flush requests are not frequent. */
201 std::atomic<std::chrono::microseconds> write_to_file_requests_interval;
202 static_assert(decltype(write_to_file_requests_interval)::is_always_lock_free);
203
204 /** @} */
205
206 /**************************************************/ /**
207
208 @name Users <=> flusher
209
210 *******************************************************/
211
212 /** @{ */
213
214 /** Unaligned pointer to array with events, which are used for
215 notifications sent from the log flush notifier thread to user threads.
216 The notifications are sent when flushed_to_disk_lsn is advanced.
217 User threads wait for flushed_to_disk_lsn >= lsn, for some lsn.
218 Log flusher advances the flushed_to_disk_lsn and notifies the
219 log flush notifier, which notifies all users interested in nearby lsn
220 values (lsn belonging to the same log block). Note that false
221 wake-ups are possible, in which case user threads simply retry
222 waiting. */
224
225 /** Number of entries in the array with events. */
227
228 /** This event is in the reset state when a flush is running;
229 a thread should wait for this without owning any of redo mutexes,
230 but NOTE that to reset this event, the thread MUST own the writer_mutex */
232
233 /** Up to this lsn data has been flushed to disk (fsynced). */
235
236 /** @} */
237
238 /**************************************************/ /**
239
240 @name Log flusher thread
241
242 *******************************************************/
243
244 /** @{ */
245
246 /** Last flush start time. Updated just before fsync starts. */
248
249 /** Last flush end time. Updated just after fsync is finished.
250 If smaller than start time, then flush operation is pending. */
252
253 /** Flushing average time (in microseconds). */
255
256 /** Mutex which can be used to pause log flusher thread. */
257 mutable ib_mutex_t flusher_mutex;
258
260
261 /** @} */
262
263 /**************************************************/ /**
264
265 @name Log writer thread
266
267 *******************************************************/
268
269 /** @{ */
270
271 /** Size of buffer used for the write-ahead (in bytes). */
273
274 /** Aligned buffer used for some of redo log writes. Data is copied
275 there from the log buffer and written to disk, in following cases:
276 - when writing ahead full kernel page to avoid read-on-write issue,
277 - to copy, prepare and write the incomplete block of the log buffer
278 (because mini-transactions might be writing new redo records to
279 the block in parallel, when the block is being written to disk) */
282
283 /** Up to this file offset in the log files, the write-ahead
284 has been done or is not required (for any other reason). */
286
287 /** File within which write_lsn is located, so the newest file in m_files
288 in the same time - updates are protected by the m_files_mutex. This field
289 exists, because the log_writer thread needs to locate offsets each time
290 it writes data blocks to disk, but we do not want to acquire and release
291 the m_files_mutex for each such write, because that would slow down the
292 log_writer thread a lot. Instead of that, the log_writer uses this object
293 to locate the offsets.
294
295 Updates of this field require two mutexes: writer_mutex and m_files_mutex.
296 Its m_id is updated only when the write_lsn moves to the next log file. */
298
299 /** Handle for the opened m_current_file. The log_writer uses this handle
300 to do writes (protected by writer_mutex). The log_flusher uses this handle
301 to do fsyncs (protected by flusher_mutex). Both these threads might use
302 this handle in parallel. The required synchronization between writes and
303 fsyncs will happen on the OS side. When m_current_file is repointed to
304 other file, this field is also updated, in the same critical section.
305 Updates of this field are protected by: writer_mutex, m_files_mutex
306 and flusher_mutex acquired all together. The reason for flusher_mutex
307 is to avoid a need to acquire / release m_files_mutex in the log_flusher
308 thread for each fsync. Instead of that, the log_flusher thread keeps the
309 log_flusher_mutex, which is released less often, but still prevents from
310 updates of this field. */
312
313 /** True iff the log writer has entered extra writer margin and still
314 hasn't exited since then. Each time the log_writer enters that margin,
315 it pauses all user threads at log_free_check() calls and emits warning
316 to the log. When the writer exits the extra margin, notice is emitted.
317 Protected by: log_limits_mutex and writer_mutex. */
319
320#endif /* !UNIV_HOTBACKUP */
321
322 /** Number of performed IO operations (only for printing stats). */
323 uint64_t n_log_ios;
324
325#ifndef UNIV_HOTBACKUP
326
327 /** Mutex which can be used to pause log writer thread. */
328 mutable ib_mutex_t writer_mutex;
329
330#ifdef UNIV_DEBUG
331 /** THD used by the log_writer thread. */
333#endif /* UNIV_DEBUG */
334
336
337 /** A recently seen value of log_consumer_get_oldest()->get_consumed_lsn().
338 It serves as a lower bound for future values of this expression, because it is
339 guaranteed to be monotonic in time: each individual consumer can only go
340 forward, and new consumers must start at least from checkpoint lsn, and the
341 checkpointer is always one of the consumers.
342 Protected by: writer_mutex. */
344
345 /** @} */
346
347 /**************************************************/ /**
348
349 @name Log closer thread
350
351 *******************************************************/
352
353 /** @{ */
354
355 /** Event used by the log closer thread to wait for tasks. */
357
358 /** Mutex which can be used to pause log closer thread. */
359 mutable ib_mutex_t closer_mutex;
360
361 /** @} */
362
363 /**************************************************/ /**
364
365 @name Log flusher <=> flush_notifier
366
367 *******************************************************/
368
369 /** @{ */
370
371 /** Event used by the log flusher thread to notify the log flush
372 notifier thread, that it should proceed with notifying user threads
373 waiting for the advanced flushed_to_disk_lsn (because it has been
374 advanced). */
376
377 /** The next flushed_to_disk_lsn can be waited using this sig_count. */
379
380 /** Mutex which can be used to pause log flush notifier thread. */
381 mutable ib_mutex_t flush_notifier_mutex;
382
383 /** @} */
384
385 /**************************************************/ /**
386
387 @name Log writer <=> write_notifier
388
389 *******************************************************/
390
391 /** @{ */
392
393 /** Mutex which can be used to pause log write notifier thread. */
395
396 /** Event used by the log writer thread to notify the log write
397 notifier thread, that it should proceed with notifying user threads
398 waiting for the advanced write_lsn (because it has been advanced). */
400
401 /** @} */
402
403 /**************************************************/ /**
404
405 @name Log files management
406
407 *******************************************************/
408
409 /** @{ */
410
411 /** Mutex protecting set of existing log files and their meta data. */
412 alignas(ut::INNODB_CACHE_LINE_SIZE) mutable ib_mutex_t m_files_mutex;
413
414 /** Context for all operations on redo log files from log0files_io.h. */
416
417 /** The in-memory dictionary of log files.
418 Protected by: m_files_mutex. */
420
421 /** Number of existing unused files (those with _tmp suffix).
422 Protected by: m_files_mutex. */
424
425 /** Size of each unused redo log file, to which recently all unused
426 redo log files became resized. Expressed in bytes. */
428
429 /** Capacity limits for the redo log. Responsible for resize.
430 Mutex protection is decided per each Log_files_capacity method. */
432
433 /** True iff log_writer is waiting for a next log file available.
434 Protected by: m_files_mutex. */
436
437 /** Statistics related to redo log files consumption and creation.
438 Protected by: m_files_mutex. */
440
441 /** Event used by log files governor thread to wait. */
443
444 /** Event used by other threads to wait until log files governor finished
445 its next iteration. This is useful when some sys_var gets changed to wait
446 until log files governor re-computed everything and then check if the
447 concurrency_margin is safe to emit warning if needed (the warning would
448 still belong to the sys_var's SET GLOBAL statement then). */
450
451 /** False if log files governor thread is allowed to add new redo records.
452 This is set as intention, to tell the log files governor about what it is
453 allowed to do. To ensure that the log_files_governor is aware of what has
454 been told, user needs to wait on @see m_no_more_dummy_records_promised. */
456
457 /** False if the log files governor thread is allowed to add new dummy redo
458 records. This is set to true only by the log_files_governor thread, and
459 after it observed @see m_no_more_dummy_records_requested being true.
460 It can be used to wait until the log files governor thread promises not to
461 generate any more dummy redo records. */
463
464#ifdef UNIV_DEBUG
465 /** THD used by the log_files_governor thread. */
467#endif /* UNIV_DEBUG */
468
469 /** Event used for waiting on next file available. Used by log writer
470 thread to wait when it needs to produce a next log file but there are
471 no free (consumed) log files available. */
473
474 /** Buffer that contains encryption meta data encrypted with master key.
475 Protected by: m_files_mutex */
477
478#endif /* !UNIV_HOTBACKUP */
479
480 /** Encryption metadata. This member is passed to Log_file_handle objects
481 created for redo log files. In particular, the m_current_file_handle has
482 a reference to this field. When encryption metadata is updated, it needs
483 to be written to the redo log file's header. Also, each write performed
484 by the log_writer thread needs to use m_encryption_metadata (it's passed
485 by reference to the m_current_file_handle) and the log_writer does not
486 acquire m_files_mutex for its writes (it is a hot path and it's better to
487 keep it shorter). Therefore it's been decided that updates of this field
488 require both m_files_mutex and writer_mutex.
489 Protected by: m_files_mutex, writer_mutex */
491
492#ifndef UNIV_HOTBACKUP
493
494 /** @} */
495
496 /**************************************************/ /**
497
498 @name Consumers
499
500 *******************************************************/
501
502 /** @{ */
503
504 /** Set of registered redo log consumers. Note, that this object
505 is not responsible for freeing them (does not claim to be owner).
506 If you wanted to register or unregister a redo log consumer, then
507 please use following functions: @see log_consumer_register() and
508 @see log_consumer_unregister(). The details of implementation
509 related to redo log consumers can be found in log0consumer.cc.
510 Protected by: m_files_mutex (unless it is the startup phase or
511 the shutdown phase). */
513
514 /** @} */
515
516 /**************************************************/ /**
517
518 @name Maintenance
519
520 *******************************************************/
521
522 /** @{ */
523
524 /** Used for stopping the log background threads. */
526
527 /** Event used for pausing the log writer threads. */
529
530 /** Used for resuming write notifier thread */
532
533 /** Used for resuming flush notifier thread */
535
536 /** Number of total I/O operations performed when we printed
537 the statistics last time. */
538 mutable uint64_t n_log_ios_old;
539
540 /** Wall time when we printed the statistics last time. */
541 mutable time_t last_printout_time;
542
543 /** @} */
544
545 /**************************************************/ /**
546
547 @name Recovery
548
549 *******************************************************/
550
551 /** @{ */
552
553 /** Lsn from which recovery has been started. */
555
556 /** Format of the redo log: e.g., Log_format::CURRENT. */
558
559 /** Log creator name */
560 std::string m_creator_name;
561
562 /** Log flags */
564
565 /** Log UUID */
567
568 /** Used only in recovery: recovery scan succeeded up to this lsn. */
570
571#ifdef UNIV_DEBUG
572
573 /** When this is set, writing to the redo log should be disabled.
574 We check for this in functions that write to the redo log. */
576
577#endif /* UNIV_DEBUG */
578
579 /** @} */
580
581 /**************************************************/ /**
582
583 @name Fields protected by the log_limits_mutex.
584 Related to free space in the redo log.
585
586 *******************************************************/
587
588 /** @{ */
589
590 /** Mutex which protects fields: available_for_checkpoint_lsn,
591 requested_checkpoint_lsn. It also synchronizes updates of:
592 free_check_limit_lsn, concurrency_margin, dict_persist_margin.
593 It protects reads and writes of m_writer_inside_extra_margin.
594 It also protects the srv_checkpoint_disabled (together with the
595 checkpointer_mutex). */
596 alignas(ut::INNODB_CACHE_LINE_SIZE) mutable ib_mutex_t limits_mutex;
597
598 /** A new checkpoint could be written for this lsn value.
599 Up to this lsn value, all dirty pages have been added to flush
600 lists and flushed. Updated in the log checkpointer thread by
601 taking minimum oldest_modification out of the last dirty pages
602 from each flush list. However it will not be bigger than the
603 current value of log.buf_dirty_pages_added_up_to_lsn.
604 Read by: user threads when requesting fuzzy checkpoint
605 Read by: log_print() (printing status of redo)
606 Updated by: log_checkpointer
607 Protected by: limits_mutex. */
609
610 /** When this is larger than the latest checkpoint, the log checkpointer
611 thread will be forced to write a new checkpoint (unless the new latest
612 checkpoint lsn would still be smaller than this value).
613 Read by: log_checkpointer
614 Updated by: user threads (log_free_check() or for sharp checkpoint)
615 Protected by: limits_mutex. */
617
618 /** Maximum lsn allowed for checkpoint by dict_persist or zero.
619 This will be set by dict_persist_to_dd_table_buffer(), which should
620 be always called before really making a checkpoint.
621 If non-zero, up to this lsn value, dynamic metadata changes have been
622 written back to mysql.innodb_dynamic_metadata under dict_persist->mutex
623 protection. All dynamic metadata changes after this lsn have to
624 be kept in redo logs, but not discarded. If zero, just ignore it.
625 Updated by: DD (when persisting dynamic meta data)
626 Updated by: log_checkpointer (reset when checkpoint is written)
627 Protected by: limits_mutex. */
629
630 /** If should perform checkpoints every innodb_log_checkpoint_every ms.
631 Disabled during startup / shutdown. Enabled in srv_start_threads.
632 Updated by: starting thread (srv_start_threads)
633 Read by: log_checkpointer */
635
636 /** If checkpoints are allowed. When this is set to false, neither new
637 checkpoints might be written nor lsn available for checkpoint might be
638 updated. This is useful in recovery period, when neither flush lists can
639 be trusted nor DD dynamic metadata redo records might be reclaimed.
640 This is never set from true to false after log_start(). */
641 std::atomic_bool m_allow_checkpoints;
642
643 /** Maximum lsn up to which there is free space in the redo log.
644 Threads check this limit and compare to current lsn, when they
645 are outside mini-transactions and hold no latches. The formula used
646 to compute the limitation takes into account maximum size of mtr and
647 thread concurrency to include proper margins and avoid issues with
648 race condition (in which all threads check the limitation and then
649 all proceed with their mini-transactions). Also extra margin is
650 there for dd table buffer cache (dict_persist_margin).
651 Read by: user threads (log_free_check())
652 Updated by: log_checkpointer (after update of checkpoint_lsn)
653 Updated by: log_writer (after pausing/resuming user threads)
654 Updated by: DD (after update of dict_persist_margin)
655 Protected by (updates only): limits_mutex. */
657
658 /** Margin used in calculation of @see free_check_limit_lsn.
659 Protected by (updates only): limits_mutex. */
661
662 /** True iff current concurrency_margin isn't truncated because of too small
663 redo log capacity.
664 Protected by (updates only): limits_mutex. */
665 std::atomic<bool> concurrency_margin_is_safe;
666
667 /** Margin used in calculation of @see free_check_limit_lsn.
668 Read by: page_cleaners, log_checkpointer
669 Updated by: DD
670 Protected by (updates only): limits_mutex. */
672
673 /** @} */
674
675 /**************************************************/ /**
676
677 @name Log checkpointer thread
678
679 *******************************************************/
680
681 /** @{ */
682
683 /** Event used by the log checkpointer thread to wait for requests. */
685
686 /** Mutex which can be used to pause log checkpointer thread.
687 This is used by log_position_lock() together with log_buffer_x_lock(),
688 to pause any changes to current_lsn or last_checkpoint_lsn. */
689 mutable ib_mutex_t checkpointer_mutex;
690
691 /** Latest checkpoint lsn.
692 Read by: user threads, log_print (no protection)
693 Read by: log_writer (under writer_mutex)
694 Updated by: log_checkpointer (under both mutexes)
695 Protected by (updates only): checkpointer_mutex + writer_mutex. */
697
698 /** Next checkpoint header to use.
699 Updated by: log_checkpointer
700 Protected by: checkpointer_mutex */
702
703 /** Event signaled when last_checkpoint_lsn is advanced by
704 the log_checkpointer thread. */
706
707 /** Latest checkpoint wall time.
708 Used by (private): log_checkpointer. */
710
711 /** Redo log consumer which is always registered and which is responsible
712 for protecting redo log records at lsn >= last_checkpoint_lsn. */
714
715#ifdef UNIV_DEBUG
716 /** THD used by the log_checkpointer thread. */
718#endif /* UNIV_DEBUG */
719
720 /** @} */
721
722#endif /* !UNIV_HOTBACKUP */
723};
724
725/** Redo log system (singleton). */
726extern log_t *log_sys;
727
728#ifdef UNIV_PFS_MEMORY
729/* PFS key for the redo log buffer's memory */
731#endif /* UNIV_PFS_MEMORY */
732
733#endif /* !log0sys_h */
Definition: log0consumer.h:82
Handle which allows to do reads / writes for the opened file.
Definition: log0types.h:309
Responsible for the redo log capacity computations.
Definition: log0files_capacity.h:56
In-memory dictionary of meta data of existing log files.
Definition: log0files_dict.h:57
For each client connection we create a separate thread with THD serving as a thread/connection descri...
Definition: sql_lexer_thd.h:34
Lightweight convenience wrapper which manages a dynamically allocated array of over-aligned types.
Definition: ut0new.h:2018
unsigned int PSI_memory_key
Instrumented memory key.
Definition: psi_memory_bits.h:49
Redo log functions and types related to the log consumption.
Redo log management of capacity.
In-memory dictionary of log files (keeps their meta data).
PSI_memory_key log_buffer_memory_key
log_t * log_sys
Redo log system (singleton).
Definition: log0log.cc:435
Redo log basic types.
Log_checkpoint_header_no
Enumerates checkpoint headers in the redo log file.
Definition: log0types.h:95
std::chrono::time_point< Log_clock > Log_clock_point
Time point defined by the Log_clock.
Definition: log0types.h:135
uint32_t Log_uuid
Number which tries to uniquely identify a created set of redo log files.
Definition: log0types.h:76
Log_format
Supported redo log formats.
Definition: log0types.h:138
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
std::atomic< sn_t > atomic_sn_t
Alias for atomic based on sn_t.
Definition: log0types.h:89
uint32_t Log_flags
Log flags (stored in file header of log file).
Definition: log0types.h:69
Definition: buf0block_hint.cc:30
constexpr size_t INNODB_CACHE_LINE_SIZE
CPU cache line size.
Definition: ut0cpu_cache.h:41
std::unordered_set< Key, std::hash< Key >, std::equal_to< Key >, ut::allocator< Key > > unordered_set
Definition: ut0new.h:2888
The interface to the operating system condition variables.
The interface to the operating system file io.
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:189
uint64_t os_offset_t
File offset in bytes.
Definition: os0file.h:84
Encryption metadata.
Definition: os0enc.h:445
Meta information about single log file.
Definition: log0types.h:454
Configures path to the root directory, where redo subdirectory might be located (or redo log files if...
Definition: log0types.h:204
Runtime statistics related to redo log files management.
Definition: log0types.h:577
Interface for an instrumented rwlock.
Definition: psi_rwlock_bits.h:71
Redo log - single data structure with state of the redo log system.
Definition: log0sys.h:77
Log_clock_point last_checkpoint_time
Latest checkpoint wall time.
Definition: log0sys.h:709
size_t m_unused_files_count
Number of existing unused files (those with _tmp suffix).
Definition: log0sys.h:423
double flush_avg_time
Flushing average time (in microseconds).
Definition: log0sys.h:254
lsn_t recovered_lsn
Lsn from which recovery has been started.
Definition: log0sys.h:554
lsn_t dict_max_allowed_checkpoint_lsn
Maximum lsn allowed for checkpoint by dict_persist or zero.
Definition: log0sys.h:628
os_event_t flusher_event
Definition: log0sys.h:259
ut::aligned_array_pointer< byte, LOG_WRITE_AHEAD_BUFFER_ALIGNMENT > write_ahead_buf
Aligned buffer used for some of redo log writes.
Definition: log0sys.h:281
os_event_t next_checkpoint_event
Event signaled when last_checkpoint_lsn is advanced by the log_checkpointer thread.
Definition: log0sys.h:705
os_event_t m_files_governor_iteration_event
Event used by other threads to wait until log files governor finished its next iteration.
Definition: log0sys.h:449
atomic_sn_t sn
Current sn value.
Definition: log0sys.h:103
THD * m_checkpointer_thd
THD used by the log_checkpointer thread.
Definition: log0sys.h:717
bool periodical_checkpoints_enabled
If should perform checkpoints every innodb_log_checkpoint_every ms.
Definition: log0sys.h:634
ib_mutex_t limits_mutex
Mutex which protects fields: available_for_checkpoint_lsn, requested_checkpoint_lsn.
Definition: log0sys.h:596
Log_format m_format
Format of the redo log: e.g., Log_format::CURRENT.
Definition: log0sys.h:557
uint64_t n_log_ios_old
Number of total I/O operations performed when we printed the statistics last time.
Definition: log0sys.h:538
std::string m_creator_name
Log creator name.
Definition: log0sys.h:560
Log_file m_current_file
File within which write_lsn is located, so the newest file in m_files in the same time - updates are ...
Definition: log0sys.h:297
lsn_t m_scanned_lsn
Used only in recovery: recovery scan succeeded up to this lsn.
Definition: log0sys.h:569
std::atomic< uint64_t > write_to_file_requests_total
Approx.
Definition: log0sys.h:195
os_event_t sn_lock_event
Event used for locking sn.
Definition: log0sys.h:89
ib_mutex_t checkpointer_mutex
Mutex which can be used to pause log checkpointer thread.
Definition: log0sys.h:689
std::atomic< std::chrono::microseconds > write_to_file_requests_interval
How often redo write/flush is requested in average.
Definition: log0sys.h:201
atomic_sn_t buf_size_sn
Size of the log buffer expressed in number of data bytes, that is excluding bytes for headers and foo...
Definition: log0sys.h:120
std::atomic_bool m_no_more_dummy_records_promised
False if the log files governor thread is allowed to add new dummy redo records.
Definition: log0sys.h:462
Log_clock_point last_flush_start_time
Last flush start time.
Definition: log0sys.h:247
Log_files_dict m_files
The in-memory dictionary of log files.
Definition: log0sys.h:419
os_event_t checkpointer_event
Event used by the log checkpointer thread to wait for requests.
Definition: log0sys.h:684
int64_t current_ready_waiting_sig_count
current_ready_waiting_lsn is waited using this sig_count.
Definition: log0sys.h:153
Log_checkpoint_header_no next_checkpoint_header_no
Next checkpoint header to use.
Definition: log0sys.h:701
atomic_sn_t sn_locked
Intended sn value while x-locked.
Definition: log0sys.h:106
os_offset_t write_ahead_end_offset
Up to this file offset in the log files, the write-ahead has been done or is not required (for any ot...
Definition: log0sys.h:285
std::atomic_bool should_stop_threads
Used for stopping the log background threads.
Definition: log0sys.h:525
ut::unordered_set< Log_consumer * > m_consumers
Set of registered redo log consumers.
Definition: log0sys.h:512
ib_mutex_t closer_mutex
Mutex which can be used to pause log closer thread.
Definition: log0sys.h:359
atomic_sn_t concurrency_margin
Margin used in calculation of.
Definition: log0sys.h:660
atomic_lsn_t free_check_limit_lsn
Maximum lsn up to which there is free space in the redo log.
Definition: log0sys.h:656
atomic_sn_t buf_limit_sn
Maximum sn up to which there is free space in both the log buffer and the log files.
Definition: log0sys.h:174
std::atomic_bool writer_threads_paused
Used for pausing the log writer threads.
Definition: log0sys.h:147
byte m_encryption_buf[OS_FILE_LOG_BLOCK_SIZE]
Buffer that contains encryption meta data encrypted with master key.
Definition: log0sys.h:476
atomic_lsn_t write_notifier_resume_lsn
Used for resuming write notifier thread.
Definition: log0sys.h:531
os_offset_t m_unused_file_size
Size of each unused redo log file, to which recently all unused redo log files became resized.
Definition: log0sys.h:427
bool disable_redo_writes
When this is set, writing to the redo log should be disabled.
Definition: log0sys.h:575
uint32_t write_ahead_buf_size
Size of buffer used for the write-ahead (in bytes).
Definition: log0sys.h:272
std::atomic_bool m_no_more_dummy_records_requested
False if log files governor thread is allowed to add new redo records.
Definition: log0sys.h:455
os_event_t writer_event
Definition: log0sys.h:335
ib_mutex_t m_files_mutex
Mutex protecting set of existing log files and their meta data.
Definition: log0sys.h:412
THD * m_writer_thd
THD used by the log_writer thread.
Definition: log0sys.h:332
Encryption_metadata m_encryption_metadata
Encryption metadata.
Definition: log0sys.h:490
int64_t current_flush_sig_count
The next flushed_to_disk_lsn can be waited using this sig_count.
Definition: log0sys.h:378
lsn_t current_ready_waiting_lsn
Some threads waiting for the ready for write lsn by closer_event.
Definition: log0sys.h:150
bool m_requested_files_consumption
True iff log_writer is waiting for a next log file available.
Definition: log0sys.h:435
atomic_lsn_t flush_notifier_resume_lsn
Used for resuming flush notifier thread.
Definition: log0sys.h:534
std::atomic_bool m_allow_checkpoints
If checkpoints are allowed.
Definition: log0sys.h:641
Log_clock_point last_flush_end_time
Last flush end time.
Definition: log0sys.h:251
lsn_t requested_checkpoint_lsn
When this is larger than the latest checkpoint, the log checkpointer thread will be forced to write a...
Definition: log0sys.h:616
os_event_t write_notifier_event
Event used by the log writer thread to notify the log write notifier thread, that it should proceed w...
Definition: log0sys.h:399
Log_files_context m_files_ctx
Context for all operations on redo log files from log0files_io.h.
Definition: log0sys.h:415
os_event_t flush_notifier_event
Event used by the log flusher thread to notify the log flush notifier thread, that it should proceed ...
Definition: log0sys.h:375
struct PSI_rwlock * pfs_psi
The instrumentation hook.
Definition: log0sys.h:138
atomic_lsn_t last_checkpoint_lsn
Latest checkpoint lsn.
Definition: log0sys.h:696
size_t flush_events_size
Number of entries in the array with events.
Definition: log0sys.h:226
lsn_t m_oldest_need_lsn_lowerbound
A recently seen value of log_consumer_get_oldest()->get_consumed_lsn().
Definition: log0sys.h:343
ib_mutex_t writer_mutex
Mutex which can be used to pause log writer thread.
Definition: log0sys.h:328
THD * m_files_governor_thd
THD used by the log_files_governor thread.
Definition: log0sys.h:466
os_event_t * flush_events
Unaligned pointer to array with events, which are used for notifications sent from the log flush noti...
Definition: log0sys.h:223
os_event_t m_files_governor_event
Event used by log files governor thread to wait.
Definition: log0sys.h:442
std::atomic< bool > concurrency_margin_is_safe
True iff current concurrency_margin isn't truncated because of too small redo log capacity.
Definition: log0sys.h:665
atomic_lsn_t flushed_to_disk_lsn
Up to this lsn data has been flushed to disk (fsynced).
Definition: log0sys.h:234
ib_mutex_t flush_notifier_mutex
Mutex which can be used to pause log flush notifier thread.
Definition: log0sys.h:381
os_event_t old_flush_event
This event is in the reset state when a flush is running; a thread should wait for this without ownin...
Definition: log0sys.h:231
ib_mutex_t write_notifier_mutex
Mutex which can be used to pause log write notifier thread.
Definition: log0sys.h:394
Log_uuid m_log_uuid
Log UUID.
Definition: log0sys.h:566
os_event_t m_file_removed_event
Event used for waiting on next file available.
Definition: log0sys.h:472
Log_file_handle m_current_file_handle
Handle for the opened m_current_file.
Definition: log0sys.h:311
ib_mutex_t sn_x_lock_mutex
Mutex which can be used for x-lock sn value.
Definition: log0sys.h:109
Log_files_capacity m_capacity
Capacity limits for the redo log.
Definition: log0sys.h:431
os_event_t closer_event
Event used by the log closer thread to wait for tasks.
Definition: log0sys.h:356
size_t buf_size
Size of the log buffer expressed in number of total bytes, that is including bytes for headers and fo...
Definition: log0sys.h:124
Log_checkpoint_consumer m_checkpoint_consumer
Redo log consumer which is always registered and which is responsible for protecting redo log records...
Definition: log0sys.h:713
atomic_sn_t dict_persist_margin
Margin used in calculation of.
Definition: log0sys.h:671
Log_flags m_log_flags
Log flags.
Definition: log0sys.h:563
rw_lock_t * sn_lock_inst
The rw_lock instance only for the debug info list.
Definition: log0sys.h:95
os_event_t writer_threads_resume_event
Event used for pausing the log writer threads.
Definition: log0sys.h:528
time_t last_printout_time
Wall time when we printed the statistics last time.
Definition: log0sys.h:541
ib_mutex_t flusher_mutex
Mutex which can be used to pause log flusher thread.
Definition: log0sys.h:257
os_event_t * write_events
Unaligned pointer to array with events, which are used for notifications sent from the log write noti...
Definition: log0sys.h:188
lsn_t available_for_checkpoint_lsn
A new checkpoint could be written for this lsn value.
Definition: log0sys.h:608
Link_buf< lsn_t > recent_written
The recent written buffer.
Definition: log0sys.h:143
uint64_t n_log_ios
Number of performed IO operations (only for printing stats).
Definition: log0sys.h:323
Log_files_stats m_files_stats
Statistics related to redo log files consumption and creation.
Definition: log0sys.h:439
size_t write_events_size
Number of entries in the array with writer_events.
Definition: log0sys.h:191
Link_buf< lsn_t > recent_closed
The recent closed buffer.
Definition: log0sys.h:157
atomic_lsn_t write_lsn
Up to this lsn, data has been written to disk (fsync not required).
Definition: log0sys.h:178
bool m_writer_inside_extra_margin
True iff the log writer has entered extra writer margin and still hasn't exited since then.
Definition: log0sys.h:318
InnoDB condition variable.
Definition: os0event.cc:63
The structure used in the spin lock implementation of a read-write lock.
Definition: sync0rw.h:360
The read-write lock (for threads, not for database transactions)
Version control for database, common definitions, and include files.
Utilities related to CPU cache.
Policy based mutexes.
Dynamic memory allocation routines and custom allocators specifically crafted to support memory instr...