Debian Codegraph @

storage/innobase/include/srv0srv.h

raw
1 /*****************************************************************************
2
3 Copyright (c) 1995, 2026, Oracle and/or its affiliates.
4 Copyright (c) 2008, 2009, Google Inc.
5 Copyright (c) 2009, Percona Inc.
6
7 Portions of this file contain modifications contributed and copyrighted by
8 Google, Inc. Those modifications are gratefully acknowledged and are described
9 briefly in the InnoDB documentation. The contributions by Google are
10 incorporated with their permission, and subject to the conditions contained in
11 the file COPYING.Google.
12
13 Portions of this file contain modifications contributed and copyrighted
14 by Percona Inc.. Those modifications are
15 gratefully acknowledged and are described briefly in the InnoDB
16 documentation. The contributions by Percona Inc. are incorporated with
17 their permission, and subject to the conditions contained in the file
18 COPYING.Percona.
19
20 This program is free software; you can redistribute it and/or modify it under
21 the terms of the GNU General Public License, version 2.0, as published by the
22 Free Software Foundation.
23
24 This program is designed to work with certain software (including
25 but not limited to OpenSSL) that is licensed under separate terms,
26 as designated in a particular file or component or in included license
27 documentation. The authors of MySQL hereby grant you an additional
28 permission to link the program and your derivative works with the
29 separately licensed software that they have either included with
30 the program or referenced in the documentation.
31
32 This program is distributed in the hope that it will be useful, but WITHOUT
33 ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
34 FOR A PARTICULAR PURPOSE. See the GNU General Public License, version 2.0,
35 for more details.
36
37 You should have received a copy of the GNU General Public License along with
38 this program; if not, write to the Free Software Foundation, Inc.,
39 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
40
41 *****************************************************************************/
42
43 /** @file include/srv0srv.h
44 The server main program
45
46 Created 10/10/1995 Heikki Tuuri
47 *******************************************************/
48
49 #ifndef srv0srv_h
50 #define srv0srv_h
51
52 #include "buf0checksum.h"
53 #include "fil0fil.h"
54 #include "mysql/psi/mysql_stage.h"
55 #include "univ.i"
56
57 #ifndef UNIV_HOTBACKUP
58 #include "log0ddl.h"
59 #include "os0event.h"
60 #include "os0file.h"
61 #include "os0thread.h"
62 #include "que0types.h"
63 #include "srv0conc.h"
64 #include "trx0types.h"
65 #include "ut0counter.h"
66
67 #include <cstdint>
68 #include <future>
69
70 /* Global counters used inside InnoDB. */
71 struct srv_stats_t {
72 typedef ib_counter_t<ulint, 64> ulint_ctr_64_t;
73 typedef ib_counter_t<lsn_t, 1, single_indexer_t> lsn_ctr_1_t;
74 typedef ib_counter_t<ulint, 1, single_indexer_t> ulint_ctr_1_t;
75 typedef ib_counter_t<lint, 1, single_indexer_t> lint_ctr_1_t;
76 typedef ib_counter_t<int64_t, 1, single_indexer_t> int64_ctr_1_t;
77
78 /** Count the amount of data written in total (in bytes) */
79 ulint_ctr_1_t data_written;
80
81 /** Number of the log write requests done */
82 ulint_ctr_1_t log_write_requests;
83
84 /** Number of physical writes to the log performed */
85 ulint_ctr_1_t log_writes;
86
87 /** Amount of data written to the log files in bytes */
88 lsn_ctr_1_t os_log_written;
89
90 /** Number of writes being done to the log files */
91 lint_ctr_1_t os_log_pending_writes;
92
93 /** We increase this counter, when we don't have enough
94 space in the log buffer and have to flush it */
95 ulint_ctr_1_t log_waits;
96
97 /** Count the number of times the doublewrite buffer was flushed */
98 ulint_ctr_1_t dblwr_writes;
99
100 /** Store the number of pages that have been flushed to the
101 doublewrite buffer */
102 ulint_ctr_1_t dblwr_pages_written;
103
104 /** Store the number of write requests issued */
105 ulint_ctr_1_t buf_pool_write_requests;
106
107 /** Store the number of times when we had to wait for a free page
108 in the buffer pool. It happens when the buffer pool is full and we
109 need to make a flush, in order to be able to read or create a page. */
110 ulint_ctr_1_t buf_pool_wait_free;
111
112 /** Count the number of pages that were written from buffer
113 pool to the disk */
114 ulint_ctr_1_t buf_pool_flushed;
115
116 /** Number of buffer pool reads that led to the reading of
117 a disk page */
118 ulint_ctr_1_t buf_pool_reads;
119
120 /** Number of data read in total (in bytes) */
121 ulint_ctr_1_t data_read;
122
123 /** Wait time of database locks */
124 int64_ctr_1_t n_lock_wait_time;
125
126 /** Number of database lock waits */
127 ulint_ctr_1_t n_lock_wait_count;
128
129 /** Number of threads currently waiting on database locks */
130 lint_ctr_1_t n_lock_wait_current_count;
131
132 /** Number of rows read. */
133 ulint_ctr_64_t n_rows_read;
134
135 /** Number of rows updated */
136 ulint_ctr_64_t n_rows_updated;
137
138 /** Number of rows deleted */
139 ulint_ctr_64_t n_rows_deleted;
140
141 /** Number of rows inserted */
142 ulint_ctr_64_t n_rows_inserted;
143
144 /** Number of system rows read. */
145 ulint_ctr_64_t n_system_rows_read;
146
147 /** Number of system rows updated */
148 ulint_ctr_64_t n_system_rows_updated;
149
150 /** Number of system rows deleted */
151 ulint_ctr_64_t n_system_rows_deleted;
152
153 /** Number of system rows inserted */
154 ulint_ctr_64_t n_system_rows_inserted;
155
156 /** Number of sampled pages read */
157 ulint_ctr_64_t n_sampled_pages_read;
158
159 /** Number of sampled pages skipped */
160 ulint_ctr_64_t n_sampled_pages_skipped;
161 };
162
163 /** Structure which keeps shared future objects for InnoDB background
164 threads. One should use these objects to check if threads exited. */
165 struct Srv_threads {
166 /** Monitor thread (prints info). */
167 IB_thread m_monitor;
168
169 /** Error monitor thread. */
170 IB_thread m_error_monitor;
171
172 /** Redo files governor thread. */
173 IB_thread m_log_files_governor;
174
175 /** Redo checkpointer thread. */
176 IB_thread m_log_checkpointer;
177
178 /** Redo writer thread. */
179 IB_thread m_log_writer;
180
181 /** Redo flusher thread. */
182 IB_thread m_log_flusher;
183
184 /** Redo write notifier thread. */
185 IB_thread m_log_write_notifier;
186
187 /** Redo flush notifier thread. */
188 IB_thread m_log_flush_notifier;
189
190 /** Redo log archiver (used by backup). */
191 IB_thread m_backup_log_archiver;
192
193 /** Buffer pool dump thread. */
194 IB_thread m_buf_dump;
195
196 /** Buffer pool resize thread. */
197 IB_thread m_buf_resize;
198
199 /** Dict stats background thread. */
200 IB_thread m_dict_stats;
201
202 /** Thread detecting lock wait timeouts. */
203 IB_thread m_lock_wait_timeout;
204
205 /** The master thread. */
206 IB_thread m_master;
207
208 /** The ts_alter_encrypt thread. */
209 IB_thread m_ts_alter_encrypt;
210
211 /** Thread doing rollbacks during recovery. */
212 IB_thread m_trx_recovery_rollback;
213
214 /** Thread writing recovered pages during recovery. */
215 IB_thread m_recv_writer;
216
217 /** Purge coordinator (also being a worker) */
218 IB_thread m_purge_coordinator;
219
220 /** Number of purge workers and size of array below. */
221 size_t m_purge_workers_n;
222
223 /** Purge workers. Note that the m_purge_workers[0] is the same shared
224 state as m_purge_coordinator. */
225 IB_thread *m_purge_workers;
226
227 /** Page cleaner coordinator (also being a worker). */
228 IB_thread m_page_cleaner_coordinator;
229
230 /** Number of page cleaner workers and size of array below. */
231 size_t m_page_cleaner_workers_n;
232
233 /** Page cleaner workers. Note that m_page_cleaner_workers[0] is the
234 same shared state as m_page_cleaner_coordinator. */
235 IB_thread *m_page_cleaner_workers;
236
237 /** Archiver's log archiver (used by Clone). */
238 IB_thread m_log_archiver;
239
240 /** Archiver's page archiver (used by Clone). */
241 IB_thread m_page_archiver;
242
243 /** Thread doing optimization for FTS index. */
244 IB_thread m_fts_optimize;
245
246 /** Thread for GTID persistence */
247 IB_thread m_gtid_persister;
248
249 #ifdef UNIV_DEBUG
250 /** Used in test scenario to delay threads' cleanup until the pre_dd_shutdown
251 is ended and final plugin's shutdown is started (when plugin is DELETED).
252 Note that you may only delay the shutdown for threads for which there is no
253 waiting procedure used in the pre_dd_shutdown. */
254 os_event_t m_shutdown_cleanup_dbg;
255 #endif /* UNIV_DEBUG */
256
257 /** When the master thread notices that shutdown has started (by noticing
258 srv_shutdown_state >= SRV_SHUTDOWN_PRE_DD_AND_SYSTEM_TRANSACTIONS), it exits
259 its main loop. Then the master thread proceeds with actions related to tasks:
260 - which it has been responsible for,
261 - and which might depend on DD objects.
262 After finishing them, the master thread sets this event.
263 @remarks We use this event to wait in srv_pre_dd_shutdown before we enter
264 next phase (SRV_SHUTDOWN_PURGE) in which master thread is not allowed to
265 use system transactions or touch DD objects. */
266 os_event_t m_master_ready_for_dd_shutdown;
267 };
268
269 /** Check if given thread is still active. */
270 bool srv_thread_is_active(const IB_thread &thread);
271
272 /** Check if given thread is cleaned-up and stopped. */
273 bool srv_thread_is_stopped(const IB_thread &thread);
274
275 /** Delay the thread after it discovered that the shutdown_state
276 is greater or equal to SRV_SHUTDOWN_CLEANUP, before it proceeds
277 with further clean up. This is used in the tests to see if such
278 a possible delay does not have impact on the clean shutdown.
279 @param[in] wait_for_signal wait until shutdown phase starts */
280 void srv_thread_delay_cleanup_if_needed(bool wait_for_signal);
281
282 struct Srv_cpu_usage {
283 int n_cpu;
284 double utime_abs;
285 double stime_abs;
286 double utime_pct;
287 double stime_pct;
288 };
289
290 /** Structure with state of srv background threads. */
291 extern Srv_threads srv_threads;
292
293 /** Structure with cpu usage information. */
294 extern Srv_cpu_usage srv_cpu_usage;
295
296 extern Log_DDL *log_ddl;
297
298 #ifdef INNODB_DD_TABLE
299 extern bool srv_is_upgrade_mode;
300 extern bool srv_downgrade_logs;
301 extern bool srv_upgrade_old_undo_found;
302 #endif /* INNODB_DD_TABLE */
303
304 extern bool srv_downgrade_partition_files;
305
306 extern const char *srv_main_thread_op_info;
307
308 /* The monitor thread waits on this event. */
309 extern os_event_t srv_monitor_event;
310
311 /* The error monitor thread waits on this event. */
312 extern os_event_t srv_error_event;
313
314 /** The buffer pool dump/load thread waits on this event. */
315 extern os_event_t srv_buf_dump_event;
316
317 /** The buffer pool resize thread waits on this event. */
318 extern os_event_t srv_buf_resize_event;
319 #endif /* !UNIV_HOTBACKUP */
320
321 /** The buffer pool dump/load file name */
322 #define SRV_BUF_DUMP_FILENAME_DEFAULT "ib_buffer_pool"
323 extern char *srv_buf_dump_filename;
324
325 /** Boolean config knobs that tell InnoDB to dump the buffer pool at shutdown
326 and/or load it during startup. */
327 extern bool srv_buffer_pool_dump_at_shutdown;
328 extern bool srv_buffer_pool_load_at_startup;
329
330 /* Whether to disable file system cache if it is defined */
331 extern bool srv_disable_sort_file_cache;
332
333 /** Enable or disable writing of NULLs while extending a tablespace.
334 If this is false, then the server will just allocate the space without
335 actually initializing it with NULLs. If the variable is true, the
336 server will allocate and initialize the space by writing NULLs in it. */
337 extern bool tbsp_extend_and_initialize;
338
339 /* If the last data file is auto-extended, we add this many pages to it
340 at a time */
341 #define SRV_AUTO_EXTEND_INCREMENT (srv_sys_space.get_autoextend_increment())
342
343 #ifndef UNIV_HOTBACKUP
344 /** Mutex protecting page_zip_stat_per_index */
345 extern ib_mutex_t page_zip_stat_per_index_mutex;
346 /* Mutex for locking srv_monitor_file. Not created if srv_read_only_mode */
347 extern ib_mutex_t srv_monitor_file_mutex;
348 /* Temporary file for innodb monitor output */
349 extern FILE *srv_monitor_file;
350 /* Mutex for locking srv_misc_tmpfile. Only created if !srv_read_only_mode.
351 This mutex has a very low rank; threads reserving it should not
352 acquire any further latches or sleep before releasing this one. */
353 extern ib_mutex_t srv_misc_tmpfile_mutex;
354 /* Temporary file for miscellaneous diagnostic output */
355 extern FILE *srv_misc_tmpfile;
356 #endif /* !UNIV_HOTBACKUP */
357
358 /* Server parameters which are read from the initfile */
359
360 extern char *srv_data_home;
361
362 /* Number of threads used for initializing rollback segments */
363 extern uint32_t srv_rseg_init_threads;
364
365 /** Number of pages per doublewrite thread/segment */
366 extern ulong srv_dblwr_pages;
367
368 /** Set if InnoDB must operate in read-only mode. We don't do any
369 recovery and open all tables in RO mode instead of RW mode. We don't
370 sync the max trx id to disk either. */
371 extern bool srv_read_only_mode;
372 /** Set if InnoDB operates in read-only mode or innodb-force-recovery
373 is greater than SRV_FORCE_NO_TRX_UNDO. */
374 extern bool high_level_read_only;
375 /** store to its own file each table created by an user; data
376 dictionary tables are in the system tablespace 0 */
377 extern bool srv_file_per_table;
378 /** Sleep delay for threads waiting to enter InnoDB. In micro-seconds. */
379 extern ulong srv_thread_sleep_delay;
380 /** Maximum sleep delay (in micro-seconds), value of 0 disables it.*/
381 extern ulong srv_adaptive_max_sleep_delay;
382
383 /** Sort buffer size in index creation */
384 extern ulong srv_sort_buf_size;
385
386 /** Maximum modification log file size for online index creation */
387 extern unsigned long long srv_online_max_size;
388
389 /** Number of threads to use for parallel reads. */
390 extern ulong srv_parallel_read_threads;
391
392 /* If this flag is true, then we will use the native aio of the
393 OS (provided we compiled Innobase with it in), otherwise we will
394 use simulated aio we build below with threads.
395 Currently we support native aio on windows and linux */
396 extern bool srv_use_native_aio;
397 extern bool srv_numa_interleave;
398
399 /* The innodb_directories variable value. This a list of directories
400 deliminated by ';', i.e the FIL_PATH_SEPARATOR. */
401 extern char *srv_innodb_directories;
402
403 /** Server undo tablespaces directory, can be absolute path. */
404 extern char *srv_undo_dir;
405
406 /** Number of undo tablespaces to use. */
407 extern ulong srv_undo_tablespaces;
408
409 /** The number of rollback segments per tablespace */
410 extern ulong srv_rollback_segments;
411
412 /** Maximum size of undo tablespace. */
413 extern unsigned long long srv_max_undo_tablespace_size;
414
415 /** Rate at which UNDO records should be purged. */
416 extern ulong srv_purge_rseg_truncate_frequency;
417
418 /** Enable or Disable Truncate of UNDO tablespace. */
419 extern bool srv_undo_log_truncate;
420
421 /** Enable or disable Encrypt of UNDO tablespace. */
422 extern bool srv_undo_log_encrypt;
423
424 /** Maximum number of recently truncated undo tablespace IDs for
425 the same undo number. */
426 extern const size_t CONCURRENT_UNDO_TRUNCATE_LIMIT;
427
428 extern char *srv_log_group_home_dir;
429
430 /** Enable or Disable Encrypt of REDO tablespace. */
431 extern bool srv_redo_log_encrypt;
432
433 /* Maximum number of redo files of a cloned DB. */
434 constexpr size_t SRV_N_LOG_FILES_CLONE_MAX = 1000;
435
436 /** Value of innodb_log_files_in_group. This is deprecated. */
437 extern ulong srv_log_n_files;
438
439 /** Value of innodb_log_file_size. Expressed in bytes. This is deprecated. */
440 extern ulonglong srv_log_file_size;
441
442 /** Value of innodb_redo_log_capacity. Expressed in bytes. Might be set
443 during startup automatically when started in "dedicated server mode". */
444 extern ulonglong srv_redo_log_capacity;
445
446 /** Assumed value of innodb_redo_log_capacity's - value which is used.
447 Expressed in bytes. Might be set during startup automatically when
448 started in "dedicated server mode". Might also be set during startup
449 when old sysvar (innodb_log_file_size or innodb_log_files_in_group)
450 are configured and the new sysvar (innodb_redo_log_capacity) is not. */
451 extern ulonglong srv_redo_log_capacity_used;
452
453 #ifdef UNIV_DEBUG_DEDICATED
454 extern ulong srv_debug_system_mem_size;
455 #endif /* UNIV_DEBUG_DEDICATED */
456
457 /** Space for log buffer, expressed in bytes. Note, that log buffer
458 will use only the largest power of two, which is not greater than
459 the assigned space. */
460 extern ulong srv_log_buffer_size;
461
462 /** When log writer follows links in the log recent written buffer,
463 it stops when it has reached at least that many bytes to write,
464 limiting how many bytes can be written in single call. */
465 extern ulong srv_log_write_max_size;
466
467 /** Size of block, used for writing ahead to avoid read-on-write. */
468 extern ulong srv_log_write_ahead_size;
469
470 /** Number of events used for notifications about redo write. */
471 extern ulong srv_log_write_events;
472
473 /** Number of events used for notifications about redo flush. */
474 extern ulong srv_log_flush_events;
475
476 /** Number of slots in a small buffer, which is used to allow concurrent
477 writes to log buffer. The slots are addressed by LSN values modulo number
478 of the slots. */
479 extern ulong srv_log_recent_written_size;
480
481 /** Number of slots in a small buffer, which is used to break requirement
482 for total order of dirty pages, when they are added to flush lists.
483 The slots are addressed by LSN values modulo number of the slots. */
484 extern ulong srv_log_recent_closed_size;
485
486 /** Whether to activate/pause the log writer threads. */
487 extern bool srv_log_writer_threads;
488
489 /** Minimum absolute value of cpu time for which spin-delay is used. */
490 extern uint srv_log_spin_cpu_abs_lwm;
491
492 /** Maximum percentage of cpu time for which spin-delay is used. */
493 extern uint srv_log_spin_cpu_pct_hwm;
494
495 /** Number of spin iterations, when spinning and waiting for log buffer
496 written up to given LSN, before we fallback to loop with sleeps.
497 This is not used when user thread has to wait for log flushed to disk. */
498 extern ulong srv_log_wait_for_write_spin_delay;
499
500 /** Timeout used when waiting for redo write. */
501 std::chrono::microseconds get_srv_log_wait_for_write_timeout();
502
503 /** Number of spin iterations, when spinning and waiting for log flushed. */
504 extern ulong srv_log_wait_for_flush_spin_delay;
505
506 /** Maximum value of average log flush time for which spin-delay is used.
507 When flushing takes longer, user threads no longer spin when waiting for
508 flushed redo. Expressed in microseconds. */
509 extern ulong srv_log_wait_for_flush_spin_hwm;
510
511 /** Timeout used when waiting for redo flush. */
512 std::chrono::microseconds get_srv_log_wait_for_flush_timeout();
513
514 /** Number of spin iterations, for which log writer thread is waiting
515 for new data to write or flush without sleeping. */
516 extern ulong srv_log_writer_spin_delay;
517
518 /** Initial timeout used to wait on writer_event. */
519 std::chrono::microseconds get_srv_log_writer_timeout();
520
521 /** Period every which a periodical checkpoint is written by the log
522 checkpointer thread (unless periodical checkpoints are disabled,
523 which is a case during initial phase of startup). */
524 std::chrono::milliseconds get_srv_log_checkpoint_every();
525
526 /** Number of spin iterations, for which log flusher thread is waiting
527 for new data to flush, without sleeping. */
528 extern ulong srv_log_flusher_spin_delay;
529
530 /** Initial timeout used to wait on flusher_event. */
531 std::chrono::microseconds get_srv_log_flusher_timeout();
532
533 /** Number of spin iterations, for which log write notifier thread is waiting
534 for advanced writeed_to_disk_lsn without sleeping. */
535 extern ulong srv_log_write_notifier_spin_delay;
536
537 /** Initial timeout used to wait on write_notifier_event. */
538 std::chrono::microseconds get_srv_log_write_notifier_timeout();
539
540 /** Number of spin iterations, for which log flush notifier thread is waiting
541 for advanced flushed_to_disk_lsn without sleeping. */
542 extern ulong srv_log_flush_notifier_spin_delay;
543
544 /** Initial timeout used to wait on flush_notifier_event. */
545 std::chrono::microseconds get_srv_log_flush_notifier_timeout();
546
547 /** Whether to generate and require checksums on the redo log pages. */
548 extern bool srv_log_checksums;
549
550 #ifdef UNIV_DEBUG
551
552 /** If true then disable checkpointing. */
553 extern bool srv_checkpoint_disabled;
554
555 /* Used to inject a failure to find a free rollback segment. */
556 extern bool srv_inject_too_many_concurrent_trxs;
557
558 #endif /* UNIV_DEBUG */
559
560 extern ulong srv_flush_log_at_trx_commit;
561 extern ulong srv_log_write_ahead_size;
562 std::chrono::seconds get_srv_flush_log_at_timeout();
563 extern bool srv_adaptive_flushing;
564 extern bool srv_flush_sync;
565
566 /* If this flag is true, then we will load the indexes' (and tables') metadata
567 even if they are marked as "corrupted". Mostly it is for DBA to process
568 corrupted index and table */
569 extern bool srv_load_corrupted;
570
571 /** Dedicated server setting */
572 extern bool srv_dedicated_server;
573 /** Requested size in bytes */
574 extern ulint srv_buf_pool_size;
575 /** Minimum pool size in bytes */
576 extern const ulint srv_buf_pool_min_size;
577 /** Default pool size in bytes */
578 extern const ulint srv_buf_pool_def_size;
579 /** Maximum pool size in bytes */
580 extern const longlong srv_buf_pool_max_size;
581 /** Requested buffer pool chunk size. Each buffer pool instance consists
582 of one or more chunks. */
583 extern ulonglong srv_buf_pool_chunk_unit;
584 /** Minimum buffer pool chunk size. */
585 extern const ulonglong srv_buf_pool_chunk_unit_min;
586 /** The buffer pool chunk size must be a multiple of this number. */
587 extern const ulonglong srv_buf_pool_chunk_unit_blk_sz;
588 /** Maximum buffer pool chunk size. */
589 extern const ulonglong srv_buf_pool_chunk_unit_max;
590
591 /** Requested number of buffer pool instances */
592 extern ulong srv_buf_pool_instances;
593 /** Default number of buffer pool instances */
594 extern const ulong srv_buf_pool_instances_default;
595 /** Number of locks to protect buf_pool->page_hash */
596 extern ulong srv_n_page_hash_locks;
597 /** Whether to validate InnoDB tablespace paths on startup */
598 extern bool srv_validate_tablespace_paths;
599 /** Use fdatasync() instead of fsync(). */
600 extern bool srv_use_fdatasync;
601 /** Scan depth for LRU flush batch i.e.: number of blocks scanned*/
602 extern ulong srv_LRU_scan_depth;
603 /** Whether or not to flush neighbors of a block */
604 extern ulong srv_flush_neighbors;
605 /** Previously requested size. Accesses protected by memory barriers. */
606 extern ulint srv_buf_pool_old_size;
607 /** Current size as scaling factor for the other components */
608 extern ulint srv_buf_pool_base_size;
609 /** Current size in bytes */
610 extern long long srv_buf_pool_curr_size;
611 /** Dump this % of each buffer pool during BP dump */
612 extern ulong srv_buf_pool_dump_pct;
613 /** Lock table size in bytes */
614 extern ulint srv_lock_table_size;
615
616 extern bool srv_random_read_ahead;
617 extern ulong srv_read_ahead_threshold;
618 extern ulong srv_n_read_io_threads;
619 extern ulong srv_n_write_io_threads;
620
621 extern uint srv_change_buffer_max_size;
622
623 /** Default value of srv_idle_flush_pct */
624 extern const ulong srv_idle_flush_pct_default;
625 /** How much flush to be done in case of server is idle */
626 extern ulong srv_idle_flush_pct;
627
628 /* Number of IO operations per second the server can do */
629 extern ulong srv_io_capacity;
630
631 /* We use this dummy default value at startup for max_io_capacity.
632 The real value is set based on the value of io_capacity. */
633 constexpr uint32_t SRV_MAX_IO_CAPACITY_DUMMY_DEFAULT = UINT32_MAX;
634 constexpr uint32_t SRV_MAX_IO_CAPACITY_LIMIT = UINT32_MAX;
635 extern ulong srv_max_io_capacity;
636 /* Returns the number of IO operations that is X percent of the
637 capacity. PCT_IO(5) -> returns the number of IO operations that
638 is 5% of the max where max is srv_io_capacity. */
639 static inline ulong PCT_IO(ulong p) {
640 return (ulong)(srv_io_capacity * ((double)(p) / 100.0));
641 }
642
643 /** Maximum number of purge threads, including the purge coordinator */
644 constexpr uint32_t MAX_PURGE_THREADS = 32;
645
646 /* The "innodb_stats_method" setting, decides how InnoDB is going
647 to treat NULL value when collecting statistics. It is not defined
648 as enum type because the configure option takes unsigned integer type. */
649 extern ulong srv_innodb_stats_method;
650
651 /** Returns current value of the "innodb_open_files" configuration variable. */
652 long innobase_get_open_files_limit();
653 /** Sets new value of the "innodb_open_files" configuration variable to present
654 to users.
655 @param[in] new_limit new limit to be set. */
656 void innobase_set_open_files_limit(long new_limit);
657
658 extern ulong srv_fatal_semaphore_wait_threshold;
659 extern uint srv_flush_log_at_timeout;
660 extern bool srv_btr_search_enabled;
661 extern ulong srv_replication_delay;
662
663 extern ulong srv_log_wait_for_write_timeout;
664 extern ulong srv_log_wait_for_flush_timeout;
665 extern ulong srv_log_writer_timeout;
666 extern ulong srv_log_checkpoint_every;
667 extern ulong srv_log_flusher_timeout;
668 extern ulong srv_log_write_notifier_timeout;
669 extern ulong srv_log_flush_notifier_timeout;
670
671 extern uint buf_LRU_old_threshold;
672
673 extern ulong srv_n_page_cleaners;
674
675 extern double srv_max_dirty_pages_pct;
676 extern double srv_max_dirty_pages_pct_lwm;
677
678 extern ulong srv_adaptive_flushing_lwm;
679 extern ulong srv_flushing_avg_loops;
680
681 extern ulong srv_force_recovery;
682 #ifdef UNIV_DEBUG
683 extern ulong srv_force_recovery_crash;
684 #endif /* UNIV_DEBUG */
685
686 /** The value of the configuration parameter innodb_fast_shutdown,
687 controlling the InnoDB shutdown.
688
689 If innodb_fast_shutdown=0, InnoDB shutdown will purge all undo log
690 records (except XA PREPARE transactions) and complete the merge of the
691 entire change buffer, and then shut down the redo log.
692
693 If innodb_fast_shutdown=1, InnoDB shutdown will only flush the buffer
694 pool to data files, cleanly shutting down the redo log.
695
696 If innodb_fast_shutdown=2, shutdown will effectively 'crash' InnoDB
697 (but lose no committed transactions). */
698 extern ulong srv_fast_shutdown;
699 extern bool srv_innodb_status;
700
701 extern unsigned long long srv_stats_transient_sample_pages;
702 extern bool srv_stats_persistent;
703 extern unsigned long long srv_stats_persistent_sample_pages;
704 extern bool srv_stats_auto_recalc;
705 extern bool srv_stats_include_delete_marked;
706
707 extern ulong srv_checksum_algorithm;
708
709 extern double srv_max_buf_pool_modified_pct;
710 extern ulong srv_max_purge_lag;
711 extern ulong srv_max_purge_lag_delay;
712
713 std::chrono::milliseconds get_srv_replication_delay();
714 /*-------------------------------------------*/
715
716 extern bool srv_print_innodb_monitor;
717 /** In contrast to srv_print_innodb_monitor which is controlled by the user,
718 this variable is controlled by InnoDB itself: if some module of InnoDB decides
719 it would be good to print the monitoring information it increments this value,
720 and decrements it when it no longer needs it. */
721 extern std::atomic_uint32_t srv_innodb_needs_monitoring;
722 extern bool srv_print_innodb_lock_monitor;
723
724 extern ulong srv_n_spin_wait_rounds;
725 extern ulong srv_n_free_tickets_to_enter;
726 extern ulong srv_spin_wait_delay;
727 extern bool srv_priority_boost;
728
729 extern ulint srv_truncated_status_writes;
730
731 #if defined UNIV_DEBUG || defined UNIV_IBUF_DEBUG
732 extern bool srv_ibuf_disable_background_merge;
733 #endif /* UNIV_DEBUG || UNIV_IBUF_DEBUG */
734
735 #ifdef UNIV_DEBUG
736 extern bool srv_buf_pool_debug;
737 extern bool srv_sync_debug;
738 extern bool srv_purge_view_update_only_debug;
739
740 /** Value of MySQL global used to disable master thread. */
741 extern bool srv_master_thread_disabled_debug;
742 #endif /* UNIV_DEBUG */
743
744 std::chrono::seconds get_srv_fatal_semaphore_wait_threshold();
745 extern std::atomic<int> srv_fatal_semaphore_wait_extend;
746
747 extern ulint srv_dml_needed_delay;
748
749 #ifdef UNIV_HOTBACKUP
750 // MAHI: changed from 130 to 1 assuming the apply-log is single threaded
751 constexpr uint32_t SRV_MAX_N_IO_THREADS = 1;
752 #else /* UNIV_HOTBACKUP */
753 constexpr uint32_t SRV_MAX_N_IO_THREADS = 130;
754 #endif /* UNIV_HOTBACKUP */
755
756 /* Array of English strings describing the current state of an
757 i/o handler thread */
758 extern const char *srv_io_thread_op_info[];
759 extern const char *srv_io_thread_function[];
760
761 /* the number of purge threads to use from the worker pool (currently 0 or 1) */
762 extern ulong srv_n_purge_threads;
763
764 /* the number of pages to purge in one batch */
765 extern ulong srv_purge_batch_size;
766
767 /* the number of sync wait arrays */
768 extern ulong srv_sync_array_size;
769
770 /* print all user-level transactions deadlocks to mysqld stderr */
771 extern bool srv_print_all_deadlocks;
772
773 /** Print all DDL logs to mysqld stderr */
774 extern bool srv_print_ddl_logs;
775
776 extern bool srv_cmp_per_index_enabled;
777
778 extern bool srv_redo_log;
779
780 /** Status variables to be passed to MySQL */
781 extern struct export_var_t export_vars;
782
783 #ifndef UNIV_HOTBACKUP
784 /** Global counters */
785 extern srv_stats_t srv_stats;
786
787 /* Keys to register InnoDB threads with performance schema */
788
789 #ifdef UNIV_PFS_THREAD
790 extern mysql_pfs_key_t log_archiver_thread_key;
791 extern mysql_pfs_key_t page_archiver_thread_key;
792 extern mysql_pfs_key_t buf_pool_create_thread_key;
793 extern mysql_pfs_key_t buf_dump_thread_key;
794 extern mysql_pfs_key_t buf_resize_thread_key;
795 extern mysql_pfs_key_t clone_ddl_thread_key;
796 extern mysql_pfs_key_t clone_gtid_thread_key;
797 extern mysql_pfs_key_t ddl_thread_key;
798 extern mysql_pfs_key_t dict_stats_thread_key;
799 extern mysql_pfs_key_t fts_optimize_thread_key;
800 extern mysql_pfs_key_t fts_parallel_merge_thread_key;
801 extern mysql_pfs_key_t fts_parallel_tokenization_thread_key;
802 extern mysql_pfs_key_t io_ibuf_thread_key;
803 extern mysql_pfs_key_t io_read_thread_key;
804 extern mysql_pfs_key_t io_write_thread_key;
805 extern mysql_pfs_key_t log_writer_thread_key;
806 extern mysql_pfs_key_t log_files_governor_thread_key;
807 extern mysql_pfs_key_t log_checkpointer_thread_key;
808 extern mysql_pfs_key_t log_flusher_thread_key;
809 extern mysql_pfs_key_t log_write_notifier_thread_key;
810 extern mysql_pfs_key_t log_flush_notifier_thread_key;
811 extern mysql_pfs_key_t page_flush_coordinator_thread_key;
812 extern mysql_pfs_key_t page_flush_thread_key;
813 extern mysql_pfs_key_t recv_writer_thread_key;
814 extern mysql_pfs_key_t srv_error_monitor_thread_key;
815 extern mysql_pfs_key_t srv_lock_timeout_thread_key;
816 extern mysql_pfs_key_t srv_master_thread_key;
817 extern mysql_pfs_key_t srv_monitor_thread_key;
818 extern mysql_pfs_key_t srv_purge_thread_key;
819 extern mysql_pfs_key_t srv_worker_thread_key;
820 extern mysql_pfs_key_t trx_recovery_rollback_thread_key;
821 extern mysql_pfs_key_t srv_ts_alter_encrypt_thread_key;
822 extern mysql_pfs_key_t parallel_read_thread_key;
823 extern mysql_pfs_key_t parallel_rseg_init_thread_key;
824 #endif /* UNIV_PFS_THREAD */
825 #endif /* !UNIV_HOTBACKUP */
826
827 #ifdef HAVE_PSI_STAGE_INTERFACE
828 /** Performance schema stage event for monitoring ALTER TABLE progress
829 everything after flush log_make_latest_checkpoint(). */
830 extern PSI_stage_info srv_stage_alter_table_end;
831
832 /** Performance schema stage event for monitoring ALTER TABLE progress
833 log_make_latest_checkpoint(). */
834 extern PSI_stage_info srv_stage_alter_table_flush;
835
836 /** Performance schema stage event for monitoring ALTER TABLE progress
837 row_merge_insert_index_tuples(). */
838 extern PSI_stage_info srv_stage_alter_table_insert;
839
840 /** Performance schema stage event for monitoring ALTER TABLE progress
841 row_log_apply(). */
842 extern PSI_stage_info srv_stage_alter_table_log_index;
843
844 /** Performance schema stage event for monitoring ALTER TABLE progress
845 row_log_table_apply(). */
846 extern PSI_stage_info srv_stage_alter_table_log_table;
847
848 /** Performance schema stage event for monitoring ALTER TABLE progress
849 row_merge_sort(). */
850 extern PSI_stage_info srv_stage_alter_table_merge_sort;
851
852 /** Performance schema stage event for monitoring ALTER TABLE progress
853 row_merge_read_clustered_index(). */
854 extern PSI_stage_info srv_stage_alter_table_read_pk_internal_sort;
855
856 /** Performance schema stage event for monitoring ALTER TABLESPACE
857 ENCRYPTION progress. */
858 extern PSI_stage_info srv_stage_alter_tablespace_encryption;
859
860 /** Performance schema stage event for monitoring buffer pool load progress. */
861 extern PSI_stage_info srv_stage_buffer_pool_load;
862 #endif /* HAVE_PSI_STAGE_INTERFACE */
863
864 /** Performance schema stage event for monitoring clone file copy progress. */
865 extern PSI_stage_info srv_stage_clone_file_copy;
866
867 /** Performance schema stage event for monitoring clone redo copy progress. */
868 extern PSI_stage_info srv_stage_clone_redo_copy;
869
870 /** Performance schema stage event for monitoring clone page copy progress. */
871 extern PSI_stage_info srv_stage_clone_page_copy;
872
873 #ifndef _WIN32
874 /** Alternatives for the file flush option in Unix.
875 @see innodb_flush_method_names */
876 enum srv_unix_flush_t {
877 SRV_UNIX_FSYNC = 0, /*!< fsync, the default */
878 SRV_UNIX_O_DSYNC, /*!< open log files in O_SYNC mode */
879 SRV_UNIX_LITTLESYNC, /*!< do not call os_file_flush()
880 when writing data files, but do flush
881 after writing to log files */
882 SRV_UNIX_NOSYNC, /*!< do not flush after writing */
883 SRV_UNIX_O_DIRECT, /*!< invoke os_file_set_nocache() on
884 data files. This implies using
885 non-buffered IO but still using fsync,
886 the reason for which is that some FS
887 do not flush meta-data when
888 unbuffered IO happens */
889 SRV_UNIX_O_DIRECT_NO_FSYNC
890 /*!< do not use fsync() when using
891 direct IO i.e.: it can be set to avoid
892 the fsync() call that we make when
893 using SRV_UNIX_O_DIRECT. However, in
894 this case user/DBA should be sure about
895 the integrity of the meta-data */
896 };
897 extern enum srv_unix_flush_t srv_unix_file_flush_method;
898
899 inline bool srv_is_direct_io() {
900 return (srv_unix_file_flush_method == SRV_UNIX_O_DIRECT ||
901 srv_unix_file_flush_method == SRV_UNIX_O_DIRECT_NO_FSYNC);
902 }
903
904 #else
905 /** Alternatives for file i/o in Windows. @see innodb_flush_method_names. */
906 enum srv_win_flush_t {
907 /** unbuffered I/O; this is the default */
908 SRV_WIN_IO_UNBUFFERED = 0,
909 /** buffered I/O */
910 SRV_WIN_IO_NORMAL,
911 };
912 extern enum srv_win_flush_t srv_win_file_flush_method;
913
914 inline bool srv_is_direct_io() {
915 return (srv_win_file_flush_method == SRV_WIN_IO_UNBUFFERED);
916 }
917
918 #endif /* _WIN32 */
919
920 /** Alternatives for srv_force_recovery. Non-zero values are intended
921 to help the user get a damaged database up so that he can dump intact
922 tables and rows with SELECT INTO OUTFILE. The database must not otherwise
923 be used with these options! A bigger number below means that all precautions
924 of lower numbers are included. */
925 enum {
926 SRV_FORCE_IGNORE_CORRUPT = 1, /*!< let the server run even if it
927 detects a corrupt page */
928 SRV_FORCE_NO_BACKGROUND = 2, /*!< prevent the main thread from
929 running: if a crash would occur
930 in purge, this prevents it */
931 SRV_FORCE_NO_TRX_UNDO = 3, /*!< do not run trx rollback after
932 recovery */
933 SRV_FORCE_NO_IBUF_MERGE = 4, /*!< prevent also ibuf operations:
934 if they would cause a crash, better
935 not do them */
936 SRV_FORCE_NO_UNDO_LOG_SCAN = 5, /*!< do not look at undo logs when
937 starting the database: InnoDB will
938 treat even incomplete transactions
939 as committed */
940 SRV_FORCE_NO_LOG_REDO = 6 /*!< do not do the log roll-forward
941 in connection with recovery */
942 };
943
944 /* Alternatives for srv_innodb_stats_method, which could be changed by
945 setting innodb_stats_method */
946 enum srv_stats_method_name_enum {
947 SRV_STATS_NULLS_EQUAL, /* All NULL values are treated as
948 equal. This is the default setting
949 for innodb_stats_method */
950 SRV_STATS_NULLS_UNEQUAL, /* All NULL values are treated as
951 NOT equal. */
952 SRV_STATS_NULLS_IGNORED /* NULL values are ignored */
953 };
954
955 typedef enum srv_stats_method_name_enum srv_stats_method_name_t;
956
957 #ifdef UNIV_DEBUG
958 /** Force all user tables to use page compression. */
959 extern ulong srv_debug_compress;
960 #endif /* UNIV_DEBUG */
961
962 /** Types of threads existing in the system. */
963 enum srv_thread_type {
964 SRV_NONE, /*!< None */
965 SRV_WORKER, /*!< threads serving parallelized
966 queries and queries released from
967 lock wait */
968 SRV_PURGE, /*!< Purge coordinator thread */
969 SRV_MASTER /*!< the master thread, (whose type
970 number must be biggest) */
971 };
972
973 /** Boots Innobase server. */
974 void srv_boot(void);
975 /** Frees the data structures created in srv_init(). */
976 void srv_free(void);
977
978 /** Sets the info describing an i/o thread current state.
979 @param[in] i The 'segment' of the i/o thread
980 @param[in] str Constant char string describing the state */
981 void srv_set_io_thread_op_info(ulint i, const char *str);
982
983 /** Resets the info describing an i/o thread current state. */
984 void srv_reset_io_thread_op_info();
985 /** Tells the purge thread that there has been activity in the database
986 and wakes up the purge thread if it is suspended (not sleeping). Note
987 that there is a small chance that the purge thread stays suspended
988 (we do not protect our operation with the srv_sys_t:mutex, for
989 performance reasons). */
990 void srv_wake_purge_thread_if_not_active(void);
991 /** Tells the Innobase server that there has been activity in the database
992 and wakes up the master thread if it is suspended (not sleeping). Used
993 in the MySQL interface. Note that there is a small chance that the master
994 thread stays suspended (we do not protect our operation with the kernel
995 mutex, for performance reasons). */
996 void srv_active_wake_master_thread_low(void);
997 static inline void srv_active_wake_master_thread() {
998 if (!srv_read_only_mode) {
999 srv_active_wake_master_thread_low();
1000 }
1001 }
1002 /** Wakes up the master thread if it is suspended or being suspended. */
1003 void srv_wake_master_thread(void);
1004 #ifndef UNIV_HOTBACKUP
1005 /** Outputs to a file the output of the InnoDB Monitor.
1006 @param[in] file output stream
1007 @param[in] nowait whether to wait for the exclusive global lock_sys latch
1008 @param[out] trx_start file position of the start of the list of active
1009 transactions
1010 @param[out] trx_end file position of the end of the list of active
1011 transactions
1012 @return false if not all information printed due to failure to obtain necessary
1013 mutex */
1014 bool srv_printf_innodb_monitor(FILE *file, bool nowait, ulint *trx_start,
1015 ulint *trx_end);
1016
1017 /** Function to pass InnoDB status variables to MySQL */
1018 void srv_export_innodb_status(void);
1019 /** Get current server activity count. We don't hold srv_sys::mutex while
1020 reading this value as it is only used in heuristics.
1021 @return activity count. */
1022 ulint srv_get_activity_count(void);
1023 /** Check if there has been any activity.
1024 @return false if no change in activity counter. */
1025 bool srv_check_activity(ulint old_activity_count); /*!< old activity count */
1026 /** Increment the server activity counter. */
1027 void srv_inc_activity_count(void);
1028
1029 /** Enqueues a task to server task queue and releases a worker thread, if there
1030 is a suspended one. */
1031 void srv_que_task_enqueue_low(que_thr_t *thr); /*!< in: query thread */
1032
1033 /** A thread which prints the info output by various InnoDB monitors. */
1034 void srv_monitor_thread();
1035
1036 /** A thread which prints warnings about semaphore waits which have lasted
1037 too long. These can be used to track bugs which cause hangs. */
1038 void srv_error_monitor_thread();
1039
1040 /** The master thread controlling the server. */
1041 void srv_master_thread();
1042
1043 /** Purge coordinator thread that schedules the purge tasks. */
1044 void srv_purge_coordinator_thread();
1045
1046 /** Worker thread that reads tasks from the work queue and executes them. */
1047 void srv_worker_thread();
1048
1049 /** Set encryption for UNDO tablespace with given space id.
1050 @param[in] space_id Undo tablespace id
1051 @param[in] mtr Mini-transaction
1052 @return false for success, true otherwise */
1053 bool set_undo_tablespace_encryption(space_id_t space_id, mtr_t *mtr);
1054
1055 /** Enable UNDO tablespaces encryption.
1056 @return false for success, true otherwise. */
1057 bool srv_enable_undo_encryption();
1058
1059 /** Enable REDO log encryption.
1060 @return false for success, true otherwise. */
1061 bool srv_enable_redo_encryption();
1062
1063 /** Get count of tasks in the queue.
1064 @return number of tasks in queue */
1065 ulint srv_get_task_queue_length(void);
1066
1067 /** Releases threads of the type given from suspension in the thread table.
1068 NOTE! The server mutex has to be reserved by the caller!
1069 @return number of threads released: this may be less than n if not
1070 enough threads were suspended at the moment */
1071 ulint srv_release_threads(enum srv_thread_type type, /*!< in: thread type */
1072 ulint n); /*!< in: number of threads to release */
1073
1074 /** Check whether the master thread is active.
1075 This is polled during the final phase of shutdown.
1076 The first phase of server shutdown must have already been executed
1077 (or the server must not have been fully started up).
1078 @see srv_pre_dd_shutdown()
1079 @retval true if any thread is active
1080 @retval false if no thread is active */
1081 bool srv_master_thread_is_active();
1082
1083 /** Wakeup the purge threads. */
1084 void srv_purge_wakeup(void);
1085
1086 /** Check if the purge threads are active, both coordinator and worker threads
1087 @return true if any thread is active, false if no thread is active */
1088 bool srv_purge_threads_active();
1089
1090 /** Create an undo tablespace with an explicit file name
1091 This is called during CREATE UNDO TABLESPACE.
1092 @param[in] space_name tablespace name
1093 @param[in] file_name file name
1094 @param[in] space_id Tablespace ID
1095 @return DB_SUCCESS or error code */
1096 dberr_t srv_undo_tablespace_create(const char *space_name,
1097 const char *file_name, space_id_t space_id);
1098
1099 /** Initialize undo::spaces and trx_sys_undo_spaces,
1100 called once during srv_start(). */
1101 void undo_spaces_init();
1102
1103 /** Free the resources occupied by undo::spaces and trx_sys_undo_spaces,
1104 called once during thread de-initialization. */
1105 void undo_spaces_deinit();
1106
1107 /** Set redo log variable for performance schema global status.
1108 @param[in] enable true => redo log enabled, false => redo log disabled */
1109 void set_srv_redo_log(bool enable);
1110
1111 #ifdef UNIV_DEBUG
1112 struct SYS_VAR;
1113
1114 /** Disables master thread. It's used by:
1115 SET GLOBAL innodb_master_thread_disabled_debug = 1 (0).
1116 @param[in] thd thread handle
1117 @param[in] var pointer to system variable
1118 @param[out] var_ptr where the formal string goes
1119 @param[in] save immediate result from check function */
1120 void srv_master_thread_disabled_debug_update(THD *thd, SYS_VAR *var,
1121 void *var_ptr, const void *save);
1122 #endif /* UNIV_DEBUG */
1123 #endif /* !UNIV_HOTBACKUP */
1124
1125 /** Status variables to be passed to MySQL */
1126 struct export_var_t {
1127 ulint innodb_data_pending_reads; /*!< Pending reads */
1128 ulint innodb_data_pending_writes; /*!< Pending writes */
1129 ulint innodb_data_pending_fsyncs; /*!< Pending fsyncs */
1130 ulint innodb_data_fsyncs; /*!< Number of fsyncs so far */
1131 ulint innodb_data_read; /*!< Data bytes read */
1132 ulint innodb_data_writes; /*!< I/O write requests */
1133 ulint innodb_data_written; /*!< Data bytes written */
1134 ulint innodb_data_reads; /*!< I/O read requests */
1135 char innodb_buffer_pool_dump_status[OS_FILE_MAX_PATH +
1136 128]; /*!< Buf pool dump status */
1137 char innodb_buffer_pool_load_status[OS_FILE_MAX_PATH +
1138 128]; /*!< Buf pool load status */
1139 char innodb_buffer_pool_resize_status[512]; /*!< Buf pool resize status */
1140 uint32_t
1141 innodb_buffer_pool_resize_status_code; /*!< Buf pool resize status code */
1142 uint32_t innodb_buffer_pool_resize_status_progress; /*!< Buf pool resize
1143 status progess */
1144 ulint innodb_buffer_pool_pages_total; /*!< Buffer pool size */
1145 ulint innodb_buffer_pool_pages_data; /*!< Data pages */
1146 ulint innodb_buffer_pool_bytes_data; /*!< File bytes used */
1147 ulint innodb_buffer_pool_pages_dirty; /*!< Dirty data pages */
1148 ulint innodb_buffer_pool_bytes_dirty; /*!< File bytes modified */
1149 ulint innodb_buffer_pool_pages_misc; /*!< Miscellaneous pages */
1150 ulint innodb_buffer_pool_pages_free; /*!< Free pages */
1151 #ifdef UNIV_DEBUG
1152 ulint innodb_buffer_pool_pages_latched; /*!< Latched pages */
1153 #endif /* UNIV_DEBUG */
1154 ulint innodb_buffer_pool_read_requests; /*!< buf_pool->stat.n_page_gets */
1155 ulint innodb_buffer_pool_reads; /*!< srv_buf_pool_reads */
1156 ulint innodb_buffer_pool_wait_free; /*!< srv_buf_pool_wait_free */
1157 ulint innodb_buffer_pool_pages_flushed; /*!< srv_buf_pool_flushed */
1158 ulint innodb_buffer_pool_write_requests; /*!< srv_buf_pool_write_requests */
1159 ulint innodb_buffer_pool_read_ahead_rnd; /*!< srv_read_ahead_rnd */
1160 ulint innodb_buffer_pool_read_ahead; /*!< srv_read_ahead */
1161 ulint innodb_buffer_pool_read_ahead_evicted; /*!< srv_read_ahead evicted*/
1162 ulint innodb_dblwr_pages_written; /*!< srv_dblwr_pages_written */
1163 ulint innodb_dblwr_writes; /*!< srv_dblwr_writes */
1164 char innodb_redo_log_resize_status[512]; /*!< Redo log resize status */
1165 bool innodb_redo_log_read_only; /*!< Is redo log read-only ? */
1166 ulonglong innodb_redo_log_uuid; /*!< Redo log UUID */
1167 ulonglong innodb_redo_log_checkpoint_lsn; /*!< Redo log checkpoint LSN */
1168 ulonglong innodb_redo_log_current_lsn; /*!< Redo log current LSN */
1169 ulonglong
1170 innodb_redo_log_flushed_to_disk_lsn; /*!< Redo log flushed to disk LSN */
1171 ulonglong innodb_redo_log_logical_size; /*!< Redo log logical size */
1172 ulonglong innodb_redo_log_physical_size; /*!< Redo log physical size */
1173 ulonglong innodb_redo_log_capacity_resized; /*!< Redo log capacity after
1174 the last finished redo resize */
1175 ulint innodb_log_waits; /*!< srv_log_waits */
1176 ulint innodb_log_write_requests; /*!< srv_log_write_requests */
1177 ulint innodb_log_writes; /*!< srv_log_writes */
1178 lsn_t innodb_os_log_written; /*!< srv_os_log_written */
1179 ulint innodb_os_log_fsyncs; /*!< log_total_flushes() */
1180 ulint innodb_os_log_pending_writes; /*!< srv_os_log_pending_writes */
1181 ulint innodb_os_log_pending_fsyncs; /*!< log_pending_flushes() */
1182 ulint innodb_page_size; /*!< UNIV_PAGE_SIZE */
1183 ulint innodb_pages_created; /*!< buf_pool->stat.n_pages_created */
1184 ulint innodb_pages_read; /*!< buf_pool->stat.n_pages_read */
1185 ulint innodb_pages_written; /*!< buf_pool->stat.n_pages_written */
1186 bool innodb_redo_log_enabled; /*!< srv_redo_log */
1187 ulint innodb_row_lock_waits; /*!< srv_n_lock_wait_count */
1188 ulint innodb_row_lock_current_waits; /*!< srv_n_lock_wait_current_count */
1189 int64_t innodb_row_lock_time; /*!< srv_n_lock_wait_time
1190 / 1000 */
1191 ulint innodb_row_lock_time_avg; /*!< srv_n_lock_wait_time
1192 / 1000
1193 / srv_n_lock_wait_count */
1194 ulint innodb_row_lock_time_max; /*!< srv_n_lock_max_wait_time
1195 / 1000 */
1196 ulint innodb_rows_read; /*!< srv_n_rows_read */
1197 ulint innodb_rows_inserted; /*!< srv_n_rows_inserted */
1198 ulint innodb_rows_updated; /*!< srv_n_rows_updated */
1199 ulint innodb_rows_deleted; /*!< srv_n_rows_deleted */
1200 ulint innodb_system_rows_read; /*!< srv_n_system_rows_read */
1201 ulint innodb_system_rows_inserted; /*!< srv_n_system_rows_inserted */
1202 ulint innodb_system_rows_updated; /*!< srv_n_system_rows_updated */
1203 ulint innodb_system_rows_deleted; /*!< srv_n_system_rows_deleted*/
1204 ulint innodb_sampled_pages_read;
1205 ulint innodb_sampled_pages_skipped;
1206 ulint innodb_num_open_files; /*!< fil_n_files_open */
1207 ulint innodb_truncated_status_writes; /*!< srv_truncated_status_writes */
1208 ulint innodb_undo_tablespaces_total; /*!< total number of undo tablespaces
1209 innoDB is tracking. */
1210 ulint innodb_undo_tablespaces_implicit; /*!< number of undo tablespaces
1211 innoDB created implicitly. */
1212 ulint innodb_undo_tablespaces_explicit; /*!< number of undo tablespaces
1213 the dba created explicitly. */
1214 ulint innodb_undo_tablespaces_active; /*!< number of active undo
1215 tablespaces */
1216 #ifdef UNIV_DEBUG
1217 ulint innodb_purge_trx_id_age; /*!< rw_max_trx_no - purged trx_no */
1218 ulint innodb_purge_view_trx_id_age; /*!< rw_max_trx_no
1219 - purged view's min trx_no */
1220 ulint innodb_ahi_drop_lookups; /*!< number of adaptive hash
1221 index lookups when freeing
1222 file pages */
1223 #endif /* UNIV_DEBUG */
1224 };
1225
1226 #ifndef UNIV_HOTBACKUP
1227 /** Thread slot in the thread table. */
1228 struct srv_slot_t {
1229 /** Thread type: user, utility etc. */
1230 srv_thread_type type;
1231
1232 /** true if this slot is in use. */
1233 bool in_use;
1234
1235 /** true if the thread is waiting for the event of this slot. */
1236 bool suspended;
1237
1238 /** Time when the thread was suspended. Initialized by
1239 lock_wait_table_reserve_slot() for lock wait. */
1240 std::chrono::steady_clock::time_point suspend_time;
1241
1242 /** Stores the current value of lock_wait_table_reservations, when
1243 lock_wait_table_reserve_slot is called.
1244 This can be used as a version number to avoid ABA problems.
1245 The difference lock_wait_table_reservations - reservation_no tells us how many
1246 other threads got suspended while our thr was sleeping.
1247 This can be used to determine if the wait was unfairly long, and it is time to
1248 boost trx->lock.schedule_weight.
1249 Protected by lock->wait_mutex. */
1250 uint64_t reservation_no;
1251
1252 /** Wait time that if exceeded the thread will be timed out.
1253 Initialized by lock_wait_table_reserve_slot() for lock wait. */
1254 std::chrono::steady_clock::duration wait_timeout;
1255
1256 /** Event used in suspending the thread when it has nothing to do. */
1257 os_event_t event;
1258
1259 /** Suspended query thread (only used for user threads). */
1260 que_thr_t *thr;
1261 };
1262 #endif /* !UNIV_HOTBACKUP */
1263
1264 #endif