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