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