MySQL 9.0.0
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 /** @} */
150
151 /**************************************************/ /**
152
153 @name Users <=> writer
154
155 *******************************************************/
156
157 /** @{ */
158
159 /** Maximum sn up to which there is free space in both the log buffer
160 and the log files. This is limitation for the end of any write to the
161 log buffer. Threads, which are limited need to wait, and possibly they
162 hold latches of dirty pages making a deadlock possible.
163 Protected by: writer_mutex (writes). */
165
166 /** Up to this lsn, data has been written to disk (fsync not required).
167 Protected by: writer_mutex (writes). */
169
170 /** Unaligned pointer to array with events, which are used for
171 notifications sent from the log write notifier thread to user threads.
172 The notifications are sent when write_lsn is advanced. User threads
173 wait for write_lsn >= lsn, for some lsn. Log writer advances the
174 write_lsn and notifies the log write notifier, which notifies all users
175 interested in nearby lsn values (lsn belonging to the same log block).
176 Note that false wake-ups are possible, in which case user threads
177 simply retry waiting. */
179
180 /** Number of entries in the array with writer_events. */
182
183 /** Approx. number of requests to write/flush redo since startup. */
185 std::atomic<uint64_t> write_to_file_requests_total;
186
187 /** How often redo write/flush is requested in average.
188 Measures in microseconds. Log threads do not spin when
189 the write/flush requests are not frequent. */
191 std::atomic<std::chrono::microseconds> write_to_file_requests_interval;
192 static_assert(decltype(write_to_file_requests_interval)::is_always_lock_free);
193
194 /** @} */
195
196 /**************************************************/ /**
197
198 @name Users <=> flusher
199
200 *******************************************************/
201
202 /** @{ */
203
204 /** Unaligned pointer to array with events, which are used for
205 notifications sent from the log flush notifier thread to user threads.
206 The notifications are sent when flushed_to_disk_lsn is advanced.
207 User threads wait for flushed_to_disk_lsn >= lsn, for some lsn.
208 Log flusher advances the flushed_to_disk_lsn and notifies the
209 log flush notifier, which notifies all users interested in nearby lsn
210 values (lsn belonging to the same log block). Note that false
211 wake-ups are possible, in which case user threads simply retry
212 waiting. */
214
215 /** Number of entries in the array with events. */
217
218 /** This event is in the reset state when a flush is running;
219 a thread should wait for this without owning any of redo mutexes,
220 but NOTE that to reset this event, the thread MUST own the writer_mutex */
222
223 /** Up to this lsn data has been flushed to disk (fsynced). */
225
226 /** @} */
227
228 /**************************************************/ /**
229
230 @name Log flusher thread
231
232 *******************************************************/
233
234 /** @{ */
235
236 /** Last flush start time. Updated just before fsync starts. */
238
239 /** Last flush end time. Updated just after fsync is finished.
240 If smaller than start time, then flush operation is pending. */
242
243 /** Flushing average time (in microseconds). */
245
246 /** Mutex which can be used to pause log flusher thread. */
247 mutable ib_mutex_t flusher_mutex;
248
250
251 /** @} */
252
253 /**************************************************/ /**
254
255 @name Log writer thread
256
257 *******************************************************/
258
259 /** @{ */
260
261 /** Size of buffer used for the write-ahead (in bytes). */
263
264 /** Aligned buffer used for some of redo log writes. Data is copied
265 there from the log buffer and written to disk, in following cases:
266 - when writing ahead full kernel page to avoid read-on-write issue,
267 - to copy, prepare and write the incomplete block of the log buffer
268 (because mini-transactions might be writing new redo records to
269 the block in parallel, when the block is being written to disk) */
272
273 /** Up to this file offset in the log files, the write-ahead
274 has been done or is not required (for any other reason). */
276
277 /** File within which write_lsn is located, so the newest file in m_files
278 in the same time - updates are protected by the m_files_mutex. This field
279 exists, because the log_writer thread needs to locate offsets each time
280 it writes data blocks to disk, but we do not want to acquire and release
281 the m_files_mutex for each such write, because that would slow down the
282 log_writer thread a lot. Instead of that, the log_writer uses this object
283 to locate the offsets.
284
285 Updates of this field require two mutexes: writer_mutex and m_files_mutex.
286 Its m_id is updated only when the write_lsn moves to the next log file. */
288
289 /** Handle for the opened m_current_file. The log_writer uses this handle
290 to do writes (protected by writer_mutex). The log_flusher uses this handle
291 to do fsyncs (protected by flusher_mutex). Both these threads might use
292 this handle in parallel. The required synchronization between writes and
293 fsyncs will happen on the OS side. When m_current_file is re-pointed to
294 other file, this field is also updated, in the same critical section.
295 Updates of this field are protected by: writer_mutex, m_files_mutex
296 and flusher_mutex acquired all together. The reason for flusher_mutex
297 is to avoid a need to acquire / release m_files_mutex in the log_flusher
298 thread for each fsync. Instead of that, the log_flusher thread keeps the
299 log_flusher_mutex, which is released less often, but still prevents from
300 updates of this field. */
302
303 /** True iff the log writer has entered extra writer margin and still
304 hasn't exited since then. Each time the log_writer enters that margin,
305 it pauses all user threads at log_free_check() calls and emits warning
306 to the log. When the writer exits the extra margin, notice is emitted.
307 Protected by: log_limits_mutex and writer_mutex. */
309
310#endif /* !UNIV_HOTBACKUP */
311
312 /** Number of performed IO operations (only for printing stats). */
313 uint64_t n_log_ios;
314
315#ifndef UNIV_HOTBACKUP
316
317 /** Mutex which can be used to pause log writer thread. */
318 mutable ib_mutex_t writer_mutex;
319
320#ifdef UNIV_DEBUG
321 /** THD used by the log_writer thread. */
323#endif /* UNIV_DEBUG */
324
326
327 /** A recently seen value of log_consumer_get_oldest()->get_consumed_lsn().
328 It serves as a lower bound for future values of this expression, because it is
329 guaranteed to be monotonic in time: each individual consumer can only go
330 forward, and new consumers must start at least from checkpoint lsn, and the
331 checkpointer is always one of the consumers.
332 Protected by: writer_mutex. */
334
335 /** @} */
336
337 /**************************************************/ /**
338
339 @name Log closing
340
341 *******************************************************/
342
343 /** @{ */
344
345 /** Event used by threads to wait for recent_written.tail() to advance.
346 Protected by: closer_mutex. */
348
349 /** Mutex protecting closer_event, current_ready_waiting_lsn, and
350 current_ready_waiting_sig_count. */
351 mutable ib_mutex_t closer_mutex;
352
353 /** Some threads waiting for the ready for write lsn by closer_event.
354 Protected by: closer_mutex. */
356
357 /** current_ready_waiting_lsn is waited using this sig_count.
358 Protected by: 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 /** Mutex which can be used to pause log governor thread. */
445 alignas(ut::INNODB_CACHE_LINE_SIZE) mutable ib_mutex_t
447
448 /** Event used by other threads to wait until log files governor finished
449 its next iteration. This is useful when some sys_var gets changed to wait
450 until log files governor re-computed everything and then check if the
451 concurrency_margin is safe to emit warning if needed (the warning would
452 still belong to the sys_var's SET GLOBAL statement then). */
454
455 /** False if log files governor thread is allowed to add new redo records.
456 This is set as intention, to tell the log files governor about what it is
457 allowed to do. To ensure that the log_files_governor is aware of what has
458 been told, user needs to wait on @see m_no_more_dummy_records_promised. */
460
461 /** False if the log files governor thread is allowed to add new dummy redo
462 records. This is set to true only by the log_files_governor thread, and
463 after it observed @see m_no_more_dummy_records_requested being true.
464 It can be used to wait until the log files governor thread promises not to
465 generate any more dummy redo records. */
467
468#ifdef UNIV_DEBUG
469 /** THD used by the log_files_governor thread. */
471#endif /* UNIV_DEBUG */
472
473 /** Event used for waiting on next file available. Used by log writer
474 thread to wait when it needs to produce a next log file but there are
475 no free (consumed) log files available. */
477
478 /** Buffer that contains encryption meta data encrypted with master key.
479 Protected by: m_files_mutex */
481
482#endif /* !UNIV_HOTBACKUP */
483
484 /** Encryption metadata. This member is passed to Log_file_handle objects
485 created for redo log files. In particular, the m_current_file_handle has
486 a reference to this field. When encryption metadata is updated, it needs
487 to be written to the redo log file's header. Also, each write performed
488 by the log_writer thread needs to use m_encryption_metadata (it's passed
489 by reference to the m_current_file_handle) and the log_writer does not
490 acquire m_files_mutex for its writes (it is a hot path and it's better to
491 keep it shorter). Therefore it's been decided that updates of this field
492 require both m_files_mutex and writer_mutex.
493 Protected by: m_files_mutex, writer_mutex */
495
496#ifndef UNIV_HOTBACKUP
497
498 /** @} */
499
500 /**************************************************/ /**
501
502 @name Consumers
503
504 *******************************************************/
505
506 /** @{ */
507
508 /** Set of registered redo log consumers. Note, that this object
509 is not responsible for freeing them (does not claim to be owner).
510 If you wanted to register or unregister a redo log consumer, then
511 please use following functions: @see log_consumer_register() and
512 @see log_consumer_unregister(). The details of implementation
513 related to redo log consumers can be found in log0consumer.cc.
514 Protected by: m_files_mutex (unless it is the startup phase or
515 the shutdown phase). */
517
518 /** @} */
519
520 /**************************************************/ /**
521
522 @name Maintenance
523
524 *******************************************************/
525
526 /** @{ */
527
528 /** Used for stopping the log background threads. */
530
531 /** Event used for pausing the log writer threads. */
533
534 /** Used for resuming write notifier thread */
536
537 /** Used for resuming flush notifier thread */
539
540 /** Number of total I/O operations performed when we printed
541 the statistics last time. */
542 mutable uint64_t n_log_ios_old;
543
544 /** Wall time when we printed the statistics last time. */
545 mutable time_t last_printout_time;
546
547 /** @} */
548
549 /**************************************************/ /**
550
551 @name Recovery
552
553 *******************************************************/
554
555 /** @{ */
556
557 /** Lsn from which recovery has been started. */
559
560 /** Format of the redo log: e.g., Log_format::CURRENT. */
562
563 /** Log creator name */
564 std::string m_creator_name;
565
566 /** Log flags */
568
569 /** Log UUID */
571
572 /** Used only in recovery: recovery scan succeeded up to this lsn. */
574
575#ifdef UNIV_DEBUG
576
577 /** When this is set, writing to the redo log should be disabled.
578 We check for this in functions that write to the redo log. */
580
581#endif /* UNIV_DEBUG */
582
583 /** @} */
584
585 /**************************************************/ /**
586
587 @name Fields protected by the log_limits_mutex.
588 Related to free space in the redo log.
589
590 *******************************************************/
591
592 /** @{ */
593
594 /** Mutex which protects fields: available_for_checkpoint_lsn,
595 requested_checkpoint_lsn. It also synchronizes updates of:
596 free_check_limit_lsn, concurrency_margin, dict_persist_margin.
597 It protects reads and writes of m_writer_inside_extra_margin.
598 It also protects the srv_checkpoint_disabled (together with the
599 checkpointer_mutex). */
600 alignas(ut::INNODB_CACHE_LINE_SIZE) mutable ib_mutex_t limits_mutex;
601
602 /** A new checkpoint could be written for this lsn value.
603 Up to this lsn value, all dirty pages have been added to flush
604 lists and flushed. Updated in the log checkpointer thread by
605 taking minimum oldest_modification out of the last dirty pages
606 from each flush list minus buf_flush_list_added->order_lag(). However
607 it will not be bigger than the current value of
608 buf_flush_list_added->smallest_not_added_lsn().
609 Read by: user threads when requesting fuzzy checkpoint
610 Read by: log_print() (printing status of redo)
611 Updated by: log_checkpointer
612 Protected by: limits_mutex. */
614
615 /** When this is larger than the latest checkpoint, the log checkpointer
616 thread will be forced to write a new checkpoint (unless the new latest
617 checkpoint lsn would still be smaller than this value).
618 Read by: log_checkpointer
619 Updated by: user threads (log_free_check() or for sharp checkpoint)
620 Protected by: limits_mutex. */
622
623 /** Maximum lsn allowed for checkpoint by dict_persist or zero.
624 This will be set by dict_persist_to_dd_table_buffer(), which should
625 be always called before really making a checkpoint.
626 If non-zero, up to this lsn value, dynamic metadata changes have been
627 written back to mysql.innodb_dynamic_metadata under dict_persist->mutex
628 protection. All dynamic metadata changes after this lsn have to
629 be kept in redo logs, but not discarded. If zero, just ignore it.
630 Updated by: DD (when persisting dynamic meta data)
631 Updated by: log_checkpointer (reset when checkpoint is written)
632 Protected by: limits_mutex. */
634
635 /** If should perform checkpoints every innodb_log_checkpoint_every ms.
636 Disabled during startup / shutdown. Enabled in srv_start_threads.
637 Updated by: starting thread (srv_start_threads)
638 Read by: log_checkpointer */
640
641 /** If checkpoints are allowed. When this is set to false, neither new
642 checkpoints might be written nor lsn available for checkpoint might be
643 updated. This is useful in recovery period, when neither flush lists can
644 be trusted nor DD dynamic metadata redo records might be reclaimed.
645 This is never set from true to false after log_start(). */
646 std::atomic_bool m_allow_checkpoints;
647
648 /** Maximum lsn up to which there is free space in the redo log.
649 Threads check this limit and compare to current lsn, when they
650 are outside mini-transactions and hold no latches. The formula used
651 to compute the limitation takes into account maximum size of mtr and
652 thread concurrency to include proper margins and avoid issues with
653 race condition (in which all threads check the limitation and then
654 all proceed with their mini-transactions). Also extra margin is
655 there for dd table buffer cache (dict_persist_margin).
656 Read by: user threads (log_free_check())
657 Updated by: log_checkpointer (after update of checkpoint_lsn)
658 Updated by: log_writer (after pausing/resuming user threads)
659 Updated by: DD (after update of dict_persist_margin)
660 Protected by (updates only): limits_mutex. */
662
663 /** Margin used in calculation of @see free_check_limit_lsn.
664 Protected by (updates only): limits_mutex. */
666
667 /** True iff current concurrency_margin isn't truncated because of too small
668 redo log capacity.
669 Protected by (updates only): limits_mutex. */
670 std::atomic<bool> concurrency_margin_is_safe;
671
672 /** Margin used in calculation of @see free_check_limit_lsn.
673 Read by: page_cleaners, log_checkpointer
674 Updated by: DD
675 Protected by (updates only): limits_mutex. */
677
678 /** @} */
679
680 /**************************************************/ /**
681
682 @name Log checkpointer thread
683
684 *******************************************************/
685
686 /** @{ */
687
688 /** Event used by the log checkpointer thread to wait for requests. */
690
691 /** Mutex which can be used to pause log checkpointer thread.
692 This is used by log_position_lock() together with log_buffer_x_lock(),
693 to pause any changes to current_lsn or last_checkpoint_lsn. */
694 mutable ib_mutex_t checkpointer_mutex;
695
696 /** Latest checkpoint lsn.
697 Read by: user threads, log_print (no protection)
698 Read by: log_writer (under writer_mutex)
699 Updated by: log_checkpointer (under both mutexes)
700 Protected by (updates only): checkpointer_mutex + writer_mutex. */
702
703 /** Next checkpoint header to use.
704 Updated by: log_checkpointer
705 Protected by: checkpointer_mutex */
707
708 /** Event signaled when last_checkpoint_lsn is advanced by
709 the log_checkpointer thread. */
711
712 /** Latest checkpoint wall time.
713 Used by (private): log_checkpointer. */
715
716 /** Redo log consumer which is always registered and which is responsible
717 for protecting redo log records at lsn >= last_checkpoint_lsn. */
719
720#ifdef UNIV_DEBUG
721 /** THD used by the log_checkpointer thread. */
723#endif /* UNIV_DEBUG */
724
725 /** @} */
726
727#endif /* !UNIV_HOTBACKUP */
728};
729
730/** Redo log system (singleton). */
731extern log_t *log_sys;
732
733#ifdef UNIV_PFS_MEMORY
734/* PFS key for the redo log buffer's memory */
736#endif /* UNIV_PFS_MEMORY */
737
738#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:36
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:431
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:196
uint64_t os_offset_t
File offset in bytes.
Definition: os0file.h:87
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:714
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:244
lsn_t recovered_lsn
Lsn from which recovery has been started.
Definition: log0sys.h:558
lsn_t dict_max_allowed_checkpoint_lsn
Maximum lsn allowed for checkpoint by dict_persist or zero.
Definition: log0sys.h:633
os_event_t flusher_event
Definition: log0sys.h:249
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:271
os_event_t next_checkpoint_event
Event signaled when last_checkpoint_lsn is advanced by the log_checkpointer thread.
Definition: log0sys.h:710
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:453
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:722
bool periodical_checkpoints_enabled
If should perform checkpoints every innodb_log_checkpoint_every ms.
Definition: log0sys.h:639
ib_mutex_t limits_mutex
Mutex which protects fields: available_for_checkpoint_lsn, requested_checkpoint_lsn.
Definition: log0sys.h:600
Log_format m_format
Format of the redo log: e.g., Log_format::CURRENT.
Definition: log0sys.h:561
uint64_t n_log_ios_old
Number of total I/O operations performed when we printed the statistics last time.
Definition: log0sys.h:542
std::string m_creator_name
Log creator name.
Definition: log0sys.h:564
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:287
lsn_t m_scanned_lsn
Used only in recovery: recovery scan succeeded up to this lsn.
Definition: log0sys.h:573
std::atomic< uint64_t > write_to_file_requests_total
Approx.
Definition: log0sys.h:185
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:694
std::atomic< std::chrono::microseconds > write_to_file_requests_interval
How often redo write/flush is requested in average.
Definition: log0sys.h:191
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:466
Log_clock_point last_flush_start_time
Last flush start time.
Definition: log0sys.h:237
Log_files_dict m_files
The in-memory dictionary of log files.
Definition: log0sys.h:419
ib_mutex_t governor_iteration_mutex
Mutex which can be used to pause log governor thread.
Definition: log0sys.h:446
os_event_t checkpointer_event
Event used by the log checkpointer thread to wait for requests.
Definition: log0sys.h:689
int64_t current_ready_waiting_sig_count
current_ready_waiting_lsn is waited using this sig_count.
Definition: log0sys.h:359
Log_checkpoint_header_no next_checkpoint_header_no
Next checkpoint header to use.
Definition: log0sys.h:706
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:275
std::atomic_bool should_stop_threads
Used for stopping the log background threads.
Definition: log0sys.h:529
ut::unordered_set< Log_consumer * > m_consumers
Set of registered redo log consumers.
Definition: log0sys.h:516
ib_mutex_t closer_mutex
Mutex protecting closer_event, current_ready_waiting_lsn, and current_ready_waiting_sig_count.
Definition: log0sys.h:351
atomic_sn_t concurrency_margin
Margin used in calculation of.
Definition: log0sys.h:665
atomic_lsn_t free_check_limit_lsn
Maximum lsn up to which there is free space in the redo log.
Definition: log0sys.h:661
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:164
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:480
atomic_lsn_t write_notifier_resume_lsn
Used for resuming write notifier thread.
Definition: log0sys.h:535
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:579
uint32_t write_ahead_buf_size
Size of buffer used for the write-ahead (in bytes).
Definition: log0sys.h:262
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:459
os_event_t writer_event
Definition: log0sys.h:325
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:322
Encryption_metadata m_encryption_metadata
Encryption metadata.
Definition: log0sys.h:494
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:355
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:538
std::atomic_bool m_allow_checkpoints
If checkpoints are allowed.
Definition: log0sys.h:646
Log_clock_point last_flush_end_time
Last flush end time.
Definition: log0sys.h:241
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:621
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:701
size_t flush_events_size
Number of entries in the array with events.
Definition: log0sys.h:216
lsn_t m_oldest_need_lsn_lowerbound
A recently seen value of log_consumer_get_oldest()->get_consumed_lsn().
Definition: log0sys.h:333
ib_mutex_t writer_mutex
Mutex which can be used to pause log writer thread.
Definition: log0sys.h:318
THD * m_files_governor_thd
THD used by the log_files_governor thread.
Definition: log0sys.h:470
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:213
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:670
atomic_lsn_t flushed_to_disk_lsn
Up to this lsn data has been flushed to disk (fsynced).
Definition: log0sys.h:224
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:221
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:570
os_event_t m_file_removed_event
Event used for waiting on next file available.
Definition: log0sys.h:476
Log_file_handle m_current_file_handle
Handle for the opened m_current_file.
Definition: log0sys.h:301
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 threads to wait for recent_written.tail() to advance.
Definition: log0sys.h:347
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:718
atomic_sn_t dict_persist_margin
Margin used in calculation of.
Definition: log0sys.h:676
Log_flags m_log_flags
Log flags.
Definition: log0sys.h:567
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:532
time_t last_printout_time
Wall time when we printed the statistics last time.
Definition: log0sys.h:545
ib_mutex_t flusher_mutex
Mutex which can be used to pause log flusher thread.
Definition: log0sys.h:247
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:178
lsn_t available_for_checkpoint_lsn
A new checkpoint could be written for this lsn value.
Definition: log0sys.h:613
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:313
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:181
atomic_lsn_t write_lsn
Up to this lsn, data has been written to disk (fsync not required).
Definition: log0sys.h:168
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:308
InnoDB condition variable.
Definition: os0event.cc:63
The structure used in the spin lock implementation of a read-write lock.
Definition: sync0rw.h:363
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...