53#include <drizzled/errmsg_print.h>
83UNIV_INTERN ulint log_fsp_current_free_limit = 0;
86UNIV_INTERN
log_t* log_sys = NULL;
89UNIV_INTERN mysql_pfs_key_t checkpoint_lock_key;
90# ifdef UNIV_LOG_ARCHIVE
91UNIV_INTERN mysql_pfs_key_t archive_lock_key;
96UNIV_INTERN mysql_pfs_key_t log_sys_mutex_key;
97UNIV_INTERN mysql_pfs_key_t log_flush_order_mutex_key;
106UNIV_INTERN ibool log_has_printed_chkp_warning = FALSE;
107UNIV_INTERN time_t log_last_warning_time;
109#ifdef UNIV_LOG_ARCHIVE
112UNIV_INTERN
byte log_archive_io;
116#define LOG_BUF_WRITE_MARGIN (4 * OS_FILE_LOG_BLOCK_SIZE)
119#define LOG_BUF_FLUSH_RATIO 2
120#define LOG_BUF_FLUSH_MARGIN (LOG_BUF_WRITE_MARGIN + 4 * UNIV_PAGE_SIZE)
125#define LOG_CHECKPOINT_FREE_PER_THREAD (4 * UNIV_PAGE_SIZE)
126#define LOG_CHECKPOINT_EXTRA_FREE (8 * UNIV_PAGE_SIZE)
131#define LOG_POOL_CHECKPOINT_RATIO_ASYNC 32
134#define LOG_POOL_PREFLUSH_RATIO_SYNC 16
138#define LOG_POOL_PREFLUSH_RATIO_ASYNC 8
141#define LOG_ARCHIVE_EXTRA_MARGIN (4 * UNIV_PAGE_SIZE)
144#define LOG_ARCHIVE_RATIO_ASYNC 16
147#define LOG_UNLOCK_NONE_FLUSHED_LOCK 1
148#define LOG_UNLOCK_FLUSH_LOCK 2
151#define LOG_ARCHIVE_READ 1
152#define LOG_ARCHIVE_WRITE 2
158log_io_complete_checkpoint(
void);
160#ifdef UNIV_LOG_ARCHIVE
165log_io_complete_archive(
void);
181 mutex_enter(&(log_sys->mutex));
183 log_fsp_current_free_limit = limit;
185 mutex_exit(&(log_sys->mutex));
202log_buf_pool_get_oldest_modification(
void)
207 ut_ad(mutex_own(&(log_sys->mutex)));
229 log_t* log = log_sys;
230 ulint len_upper_limit;
231#ifdef UNIV_LOG_ARCHIVE
232 ulint archived_lsn_age;
239 ut_a(len < log->buf_size / 2);
241 mutex_enter(&(log->
mutex));
242 ut_ad(!recv_no_log_write);
247 len_upper_limit = LOG_BUF_WRITE_MARGIN + (5 * len) / 4;
251 mutex_exit(&(log->
mutex));
265#ifdef UNIV_LOG_ARCHIVE
266 if (log->archiving_state != LOG_ARCH_OFF) {
268 archived_lsn_age = log->
lsn - log->archived_lsn;
269 if (archived_lsn_age + len_upper_limit
270 > log->max_archived_lsn_age) {
274 mutex_exit(&(log->
mutex));
276 ut_ad(len_upper_limit <= log->max_archived_lsn_age);
304 log_t* log = log_sys;
311 ut_ad(!recv_no_log_write);
326 - LOG_BLOCK_TRL_SIZE;
341 log_block_set_checkpoint_no(log_block,
342 log_sys->next_checkpoint_no);
343 len += LOG_BLOCK_HDR_SIZE + LOG_BLOCK_TRL_SIZE;
361 srv_log_write_requests++;
368log_max_modified_age_async()
371 if (srv_checkpoint_age_target) {
372 return(
ut_min(log_sys->max_modified_age_async,
373 srv_checkpoint_age_target
374 - srv_checkpoint_age_target / 8));
376 return(log_sys->max_modified_age_async);
384log_max_checkpoint_age_async()
387 if (srv_checkpoint_age_target) {
388 return(
ut_min(log_sys->max_checkpoint_age_async,
389 srv_checkpoint_age_target));
391 return(log_sys->max_checkpoint_age_async);
406 ulint first_rec_group;
407 ib_uint64_t oldest_lsn;
409 log_t* log = log_sys;
410 ib_uint64_t checkpoint_age;
413 ut_ad(!recv_no_log_write);
421 if (first_rec_group == 0) {
444 if (!log_has_printed_chkp_warning
445 || difftime(time(NULL), log_last_warning_time) > 15) {
447 log_has_printed_chkp_warning = TRUE;
448 log_last_warning_time = time(NULL);
452 " InnoDB: ERROR: the age of the last"
453 " checkpoint is %lu,\n"
454 "InnoDB: which exceeds the log group"
456 "InnoDB: If you are using big"
457 " BLOB or TEXT rows, you must set the\n"
458 "InnoDB: combined size of log files"
459 " at least 10 times bigger than the\n"
460 "InnoDB: largest such row.\n",
461 (ulong) checkpoint_age,
466 if (checkpoint_age <= log_max_modified_age_async()) {
474 || lsn - oldest_lsn > log_max_modified_age_async()
475 || checkpoint_age > log_max_checkpoint_age_async()) {
489#ifdef UNIV_LOG_ARCHIVE
495log_pad_current_log_block(
void)
506 - LOG_BLOCK_TRL_SIZE;
508 for (i = 0; i < pad_length; i++) {
512 const ib_uint64_t lsn = log_sys->lsn;
531 ut_ad(mutex_own(&(log_sys->mutex)));
542log_group_calc_size_offset(
548 ut_ad(mutex_own(&(log_sys->mutex)));
550 return(offset - LOG_FILE_HDR_SIZE * (1 + offset / group->
file_size));
559log_group_calc_real_offset(
565 ut_ad(mutex_own(&(log_sys->mutex)));
567 return(offset + LOG_FILE_HDR_SIZE
568 * (1 + offset / (group->
file_size - LOG_FILE_HDR_SIZE)));
576log_group_calc_lsn_offset(
583 ib_int64_t gr_lsn_size_offset;
584 ib_int64_t difference;
585 ib_int64_t group_size;
588 ut_ad(mutex_own(&(log_sys->mutex)));
595 gr_lsn_size_offset = (ib_int64_t)
596 log_group_calc_size_offset(group->
lsn_offset, group);
602 difference = (ib_int64_t) (lsn - gr_lsn);
604 difference = (ib_int64_t) (gr_lsn - lsn);
606 difference = difference % group_size;
608 difference = group_size - difference;
611 offset = (gr_lsn_size_offset + difference) % group_size;
614 ut_a((
sizeof(ulint) != 4) || (offset < (((ib_int64_t) 1) << 32)));
621 return(log_group_calc_real_offset((ulint)offset, group));
626UNIV_INTERN ibool log_debug_writes = FALSE;
636 ib_int64_t* log_file_offset,
638 ib_uint64_t first_header_lsn,
644 ib_int64_t log_file_size)
647 ib_int64_t capacity = log_file_size - LOG_FILE_HDR_SIZE;
649 ib_int64_t add_this_many;
651 if (lsn < first_header_lsn) {
652 add_this_many = 1 + (first_header_lsn - lsn)
653 / (capacity * (ib_int64_t)n_log_files);
655 * capacity * (ib_int64_t)n_log_files;
658 ut_a(lsn >= first_header_lsn);
660 file_no = ((ulint)((lsn - first_header_lsn) / capacity))
662 *log_file_offset = (lsn - first_header_lsn) % capacity;
664 *log_file_offset = *log_file_offset + LOG_FILE_HDR_SIZE;
669#ifndef UNIV_HOTBACKUP
682 group->
lsn_offset = log_group_calc_lsn_offset(lsn, group);
693log_calc_max_ages(
void)
699 ibool success = TRUE;
700 ulint smallest_capacity;
701 ulint archive_margin;
702 ulint smallest_archive_margin;
704 mutex_enter(&(log_sys->mutex));
710 smallest_capacity = ULINT_MAX;
711 smallest_archive_margin = ULINT_MAX;
721 - LOG_ARCHIVE_EXTRA_MARGIN;
723 if (archive_margin < smallest_archive_margin) {
725 smallest_archive_margin = archive_margin;
732 smallest_capacity = smallest_capacity - smallest_capacity / 10;
739 free = LOG_CHECKPOINT_FREE_PER_THREAD * (10 + srv_thread_concurrency)
740 + LOG_CHECKPOINT_EXTRA_FREE;
741 if (free >= smallest_capacity / 2) {
746 margin = smallest_capacity - free;
749 margin =
ut_min(margin, log_sys->adm_checkpoint_interval);
751 margin = margin - margin / 10;
753 log_sys->log_group_capacity = smallest_capacity;
755 log_sys->max_modified_age_async = margin
756 - margin / LOG_POOL_PREFLUSH_RATIO_ASYNC;
757 log_sys->max_modified_age_sync = margin
758 - margin / LOG_POOL_PREFLUSH_RATIO_SYNC;
760 log_sys->max_checkpoint_age_async = margin - margin
761 / LOG_POOL_CHECKPOINT_RATIO_ASYNC;
762 log_sys->max_checkpoint_age = margin;
764#ifdef UNIV_LOG_ARCHIVE
765 log_sys->max_archived_lsn_age = smallest_archive_margin;
767 log_sys->max_archived_lsn_age_async = smallest_archive_margin
768 - smallest_archive_margin / LOG_ARCHIVE_RATIO_ASYNC;
771 mutex_exit(&(log_sys->mutex));
775 "InnoDB: Error: ib_logfiles are too small"
776 " for innodb_thread_concurrency %lu.\n"
777 "InnoDB: The combined size of ib_logfiles"
778 " should be bigger than\n"
779 "InnoDB: 200 kB * innodb_thread_concurrency.\n"
780 "InnoDB: To get mysqld to start up, set"
781 " innodb_thread_concurrency in my.cnf\n"
782 "InnoDB: to a lower value, for example, to 8."
783 " After an ERROR-FREE shutdown\n"
784 "InnoDB: of mysqld you can adjust the size of"
785 " ib_logfiles, as explained in\n"
786 "InnoDB: " REFMAN
"adding-and-removing.html\n"
787 "InnoDB: Cannot continue operation."
788 " Calling exit(1).\n",
789 (ulong)srv_thread_concurrency);
804 log_sys =
static_cast<log_t *
>(mem_alloc(
sizeof(
log_t)));
806 mutex_create(log_sys_mutex_key, &log_sys->mutex, SYNC_LOG);
808 mutex_create(log_flush_order_mutex_key,
809 &log_sys->log_flush_order_mutex,
810 SYNC_LOG_FLUSH_ORDER);
812 mutex_enter(&(log_sys->mutex));
817 log_sys->lsn = LOG_START_LSN;
820 ut_a(LOG_BUFFER_SIZE >= 4 * UNIV_PAGE_SIZE);
825 log_sys->buf_size = LOG_BUFFER_SIZE;
827 memset(log_sys->buf,
'\0', LOG_BUFFER_SIZE);
829 log_sys->max_buf_free = log_sys->buf_size / LOG_BUF_FLUSH_RATIO
830 - LOG_BUF_FLUSH_MARGIN;
831 log_sys->check_flush_or_checkpoint = TRUE;
834 log_sys->n_log_ios = 0;
836 log_sys->n_log_ios_old = log_sys->n_log_ios;
837 log_sys->last_printout_time = time(NULL);
840 log_sys->buf_next_to_write = 0;
842 log_sys->write_lsn = 0;
843 log_sys->current_flush_lsn = 0;
844 log_sys->flushed_to_disk_lsn = 0;
846 log_sys->written_to_some_lsn = log_sys->lsn;
847 log_sys->written_to_all_lsn = log_sys->lsn;
849 log_sys->n_pending_writes = 0;
860 log_sys->adm_checkpoint_interval = ULINT_MAX;
862 log_sys->next_checkpoint_no = 0;
863 log_sys->last_checkpoint_lsn = log_sys->lsn;
864 log_sys->n_pending_checkpoint_writes = 0;
867 SYNC_NO_ORDER_CHECK);
870 log_sys->checkpoint_buf =
static_cast<unsigned char *
>(
ut_align(log_sys->checkpoint_buf_ptr,
875#ifdef UNIV_LOG_ARCHIVE
877 log_sys->archiving_state = LOG_ARCH_OFF;
878 log_sys->archived_lsn = log_sys->lsn;
879 log_sys->next_archived_lsn = 0;
881 log_sys->n_pending_archive_ios = 0;
884 SYNC_NO_ORDER_CHECK);
886 log_sys->archive_buf = NULL;
892 log_sys->archive_buf_size = 0;
904 log_sys->buf_free = LOG_BLOCK_HDR_SIZE;
905 log_sys->lsn = LOG_START_LSN + LOG_BLOCK_HDR_SIZE;
907 mutex_exit(&(log_sys->mutex));
913 recv_sys->parse_start_lsn = log_sys->lsn;
914 recv_sys->scanned_lsn = log_sys->lsn;
915 recv_sys->scanned_checkpoint_no = 0;
916 recv_sys->recovered_lsn = log_sys->lsn;
917 recv_sys->limit_lsn = IB_ULONGLONG_MAX;
950 group->
state = LOG_GROUP_OK;
951 group->
lsn = LOG_START_LSN;
955 group->
file_header_bufs_ptr =
static_cast<unsigned char **
>(mem_alloc(
sizeof(
byte*) * n_files));
956 group->
file_header_bufs =
static_cast<unsigned char **
>(mem_alloc(
sizeof(
byte*) * n_files));
957#ifdef UNIV_LOG_ARCHIVE
958 group->archive_file_header_bufs_ptr = mem_alloc(
959 sizeof(
byte*) * n_files);
960 group->archive_file_header_bufs = mem_alloc(
sizeof(
byte*) * n_files);
963 for (i = 0; i < n_files; i++) {
974#ifdef UNIV_LOG_ARCHIVE
975 group->archive_file_header_bufs_ptr[i] = mem_alloc(
978 group->archive_file_header_bufs[i] =
ut_align(
979 group->archive_file_header_bufs_ptr[i],
982 memset(*(group->archive_file_header_bufs + i),
'\0',
987#ifdef UNIV_LOG_ARCHIVE
988 group->archive_space_id = archive_space_id;
990 group->archived_file_no = 0;
991 group->archived_offset = 0;
1002 ut_a(log_calc_max_ages());
1009log_flush_do_unlocks(
1014 ut_ad(mutex_own(&(log_sys->mutex)));
1027 if (code & LOG_UNLOCK_NONE_FLUSHED_LOCK) {
1031 if (code & LOG_UNLOCK_FLUSH_LOCK) {
1042log_group_check_flush_completion(
1046 ut_ad(mutex_own(&(log_sys->mutex)));
1050 if (log_debug_writes) {
1052 "Log flushed first to group %lu\n",
1056 log_sys->written_to_some_lsn = log_sys->write_lsn;
1057 log_sys->one_flushed = TRUE;
1059 return(LOG_UNLOCK_NONE_FLUSHED_LOCK);
1065 fprintf(stderr,
"Log flushed to group %lu\n",
1077log_sys_check_flush_completion(
void)
1083 ut_ad(mutex_own(&(log_sys->mutex)));
1085 if (log_sys->n_pending_writes == 0) {
1087 log_sys->written_to_all_lsn = log_sys->write_lsn;
1088 log_sys->buf_next_to_write = log_sys->write_end_offset;
1090 if (log_sys->write_end_offset > log_sys->max_buf_free / 2) {
1095 log_sys->write_end_offset,
1100 ut_memmove(log_sys->buf, log_sys->buf + move_start,
1101 move_end - move_start);
1102 log_sys->buf_free -= move_start;
1104 log_sys->buf_next_to_write -= move_start;
1107 return(LOG_UNLOCK_FLUSH_LOCK);
1123#ifdef UNIV_LOG_ARCHIVE
1124 if ((
byte*)group == &log_archive_io) {
1127 log_io_complete_archive();
1133 if ((ulint)group & 0x1UL) {
1145 if (log_debug_writes) {
1147 "Checkpoint info written to group %lu\n",
1151 log_io_complete_checkpoint();
1162 && srv_flush_log_at_trx_commit != 2) {
1167 mutex_enter(&(log_sys->mutex));
1168 ut_ad(!recv_no_log_write);
1171 ut_a(log_sys->n_pending_writes > 0);
1174 log_sys->n_pending_writes--;
1176 unlock = log_group_check_flush_completion(group);
1177 unlock = unlock | log_sys_check_flush_completion();
1179 log_flush_do_unlocks(unlock);
1181 mutex_exit(&(log_sys->mutex));
1188log_group_file_header_flush(
1193 ib_uint64_t start_lsn)
1199 ut_ad(mutex_own(&(log_sys->mutex)));
1200 ut_ad(!recv_no_log_write);
1201 ut_a(nth_file < group->n_files);
1209 memcpy(buf + LOG_FILE_WAS_CREATED_BY_HOT_BACKUP,
" ", 4);
1212 srv_log_block_size);
1214 dest_offset = nth_file * group->
file_size;
1217 if (log_debug_writes) {
1219 "Writing log file header to group %lu file %lu\n",
1220 (ulong) group->
id, (ulong) nth_file);
1224 log_sys->n_log_ios++;
1226 srv_os_log_pending_writes++;
1228 fil_io(OS_FILE_WRITE | OS_FILE_LOG, TRUE, group->
space_id, 0,
1229 dest_offset / UNIV_PAGE_SIZE,
1230 dest_offset % UNIV_PAGE_SIZE,
1234 srv_os_log_pending_writes--;
1244log_block_store_checksum(
1261 ib_uint64_t start_lsn,
1264 ulint new_data_offset)
1274 ut_ad(mutex_own(&(log_sys->mutex)));
1275 ut_ad(!recv_no_log_write);
1279 if (new_data_offset == 0) {
1280 write_header = TRUE;
1282 write_header = FALSE;
1290 next_offset = log_group_calc_lsn_offset(start_lsn, group);
1292 if ((next_offset % group->
file_size == LOG_FILE_HDR_SIZE)
1296 log_group_file_header_flush(group,
1312 if (log_debug_writes) {
1315 "Writing log file segment to group %lu"
1316 " offset %lu len %lu\n"
1317 "start lsn %" PRIu64
"\n"
1318 "First block n:o %lu last block n:o %lu\n",
1319 (ulong) group->
id, (ulong) next_offset,
1344 log_sys->n_log_ios++;
1346 srv_os_log_pending_writes++;
1348 fil_io(OS_FILE_WRITE | OS_FILE_LOG, TRUE, group->
space_id, 0,
1349 next_offset / UNIV_PAGE_SIZE,
1350 next_offset % UNIV_PAGE_SIZE, write_len, buf, group);
1352 srv_os_log_pending_writes--;
1354 srv_os_log_written+= write_len;
1358 if (write_len < len) {
1359 start_lsn += write_len;
1363 write_header = TRUE;
1383 ibool flush_to_disk)
1393 ulint loop_count = 0;
1408 ut_ad(loop_count < 5);
1411 if (loop_count > 2) {
1412 fprintf(stderr,
"Log loop count %lu\n", loop_count);
1417 mutex_enter(&(log_sys->mutex));
1418 ut_ad(!recv_no_log_write);
1421 && log_sys->flushed_to_disk_lsn >= lsn) {
1423 mutex_exit(&(log_sys->mutex));
1429 && (log_sys->written_to_all_lsn >= lsn
1430 || (log_sys->written_to_some_lsn >= lsn
1431 && wait != LOG_WAIT_ALL_GROUPS))) {
1433 mutex_exit(&(log_sys->mutex));
1438 if (log_sys->n_pending_writes > 0) {
1442 && log_sys->current_flush_lsn >= lsn) {
1450 && log_sys->write_lsn >= lsn) {
1457 mutex_exit(&(log_sys->mutex));
1462 os_event_wait(log_sys->no_flush_event);
1468 && log_sys->buf_free == log_sys->buf_next_to_write) {
1471 mutex_exit(&(log_sys->mutex));
1477 if (log_debug_writes) {
1479 "Writing log from %" PRIu64
" up to lsn %" PRIu64
"\n",
1480 log_sys->written_to_all_lsn,
1484 log_sys->n_pending_writes++;
1493 start_offset = log_sys->buf_next_to_write;
1494 end_offset = log_sys->buf_free;
1499 ut_ad(area_end - area_start > 0);
1501 log_sys->write_lsn = log_sys->lsn;
1503 if (flush_to_disk) {
1504 log_sys->current_flush_lsn = log_sys->lsn;
1507 log_sys->one_flushed = FALSE;
1509 log_block_set_flush_bit(log_sys->buf + area_start, TRUE);
1510 log_block_set_checkpoint_no(
1512 log_sys->next_checkpoint_no);
1523 log_sys->write_end_offset = log_sys->buf_free;
1531 group, log_sys->buf + area_start,
1532 area_end - area_start,
1535 start_offset - area_start);
1542 mutex_exit(&(log_sys->mutex));
1549 log_sys->flushed_to_disk_lsn = log_sys->write_lsn;
1551 }
else if (flush_to_disk) {
1556 log_sys->flushed_to_disk_lsn = log_sys->write_lsn;
1559 mutex_enter(&(log_sys->mutex));
1564 ut_a(log_sys->n_pending_writes == 1);
1567 log_sys->n_pending_writes--;
1569 unlock = log_group_check_flush_completion(group);
1570 unlock = unlock | log_sys_check_flush_completion();
1572 log_flush_do_unlocks(unlock);
1574 mutex_exit(&(log_sys->mutex));
1579 mutex_exit(&(log_sys->mutex));
1582 case LOG_WAIT_ONE_GROUP:
1583 os_event_wait(log_sys->one_flushed_event);
1585 case LOG_WAIT_ALL_GROUPS:
1586 os_event_wait(log_sys->no_flush_event);
1606 mutex_enter(&(log_sys->mutex));
1610 mutex_exit(&(log_sys->mutex));
1628 mutex_enter(&(log_sys->mutex));
1632 mutex_exit(&(log_sys->mutex));
1643log_flush_margin(
void)
1646 log_t* log = log_sys;
1647 ib_uint64_t lsn = 0;
1649 mutex_enter(&(log->
mutex));
1661 mutex_exit(&(log->
mutex));
1678 ib_uint64_t new_oldest,
1699 n_pages = buf_flush_list(ULINT_MAX, new_oldest);
1705 if (n_pages == ULINT_UNDEFINED) {
1717log_complete_checkpoint(
void)
1720 ut_ad(mutex_own(&(log_sys->mutex)));
1721 ut_ad(log_sys->n_pending_checkpoint_writes == 0);
1723 log_sys->next_checkpoint_no++;
1725 log_sys->last_checkpoint_lsn = log_sys->next_checkpoint_lsn;
1727 rw_lock_x_unlock_gen(&(log_sys->checkpoint_lock), LOG_CHECKPOINT);
1734log_io_complete_checkpoint(
void)
1737 mutex_enter(&(log_sys->mutex));
1739 ut_ad(log_sys->n_pending_checkpoint_writes > 0);
1741 log_sys->n_pending_checkpoint_writes--;
1743 if (log_sys->n_pending_checkpoint_writes == 0) {
1744 log_complete_checkpoint();
1747 mutex_exit(&(log_sys->mutex));
1754log_checkpoint_set_nth_group_info(
1764 + 8 * n + LOG_CHECKPOINT_ARCHIVED_FILE_NO, file_no);
1766 + 8 * n + LOG_CHECKPOINT_ARCHIVED_OFFSET, offset);
1783 + 8 * n + LOG_CHECKPOINT_ARCHIVED_FILE_NO);
1785 + 8 * n + LOG_CHECKPOINT_ARCHIVED_OFFSET);
1792log_group_checkpoint(
1797#ifdef UNIV_LOG_ARCHIVE
1798 ib_uint64_t archived_lsn;
1799 ib_uint64_t next_archived_lsn;
1806 ut_ad(mutex_own(&(log_sys->mutex)));
1811 mach_write_to_8(buf + LOG_CHECKPOINT_NO, log_sys->next_checkpoint_no);
1812 mach_write_to_8(buf + LOG_CHECKPOINT_LSN, log_sys->next_checkpoint_lsn);
1815 log_group_calc_lsn_offset(
1816 log_sys->next_checkpoint_lsn, group));
1818 mach_write_to_4(buf + LOG_CHECKPOINT_LOG_BUF_SIZE, log_sys->buf_size);
1820#ifdef UNIV_LOG_ARCHIVE
1821 if (log_sys->archiving_state == LOG_ARCH_OFF) {
1822 archived_lsn = IB_ULONGLONG_MAX;
1824 archived_lsn = log_sys->archived_lsn;
1826 if (archived_lsn != log_sys->next_archived_lsn) {
1827 next_archived_lsn = log_sys->next_archived_lsn;
1835 (ib_uint64_t)log_group_calc_lsn_offset(
1836 log_sys->next_checkpoint_lsn, group));
1841 log_checkpoint_set_nth_group_info(buf, i, 0, 0);
1847 log_checkpoint_set_nth_group_info(buf, group2->
id,
1848#ifdef UNIV_LOG_ARCHIVE
1849 group2->archived_file_no,
1850 group2->archived_offset
1863 LOG_CHECKPOINT_CHECKSUM_2 - LOG_CHECKPOINT_LSN);
1870 log_fsp_current_free_limit);
1873 LOG_CHECKPOINT_FSP_MAGIC_N_VAL);
1878 if ((log_sys->next_checkpoint_no & 1) == 0) {
1879 write_offset = LOG_CHECKPOINT_1;
1881 write_offset = LOG_CHECKPOINT_2;
1885 if (log_sys->n_pending_checkpoint_writes == 0) {
1887 rw_lock_x_lock_gen(&(log_sys->checkpoint_lock),
1891 log_sys->n_pending_checkpoint_writes++;
1893 log_sys->n_log_ios++;
1899 fil_io(OS_FILE_WRITE | OS_FILE_LOG, FALSE, group->
space_id, 0,
1900 write_offset / UNIV_PAGE_SIZE,
1901 write_offset % UNIV_PAGE_SIZE,
1903 buf, ((
byte*)group + 1));
1905 ut_ad(((ulint)group & 0x1UL) == 0);
1910#ifdef UNIV_HOTBACKUP
1916log_reset_first_header_and_checkpoint(
1931 lsn = start + LOG_BLOCK_HDR_SIZE;
1934 strcpy((
char*) hdr_buf + LOG_FILE_WAS_CREATED_BY_HOT_BACKUP,
1937 + (LOG_FILE_WAS_CREATED_BY_HOT_BACKUP
1938 + (
sizeof "ibbackup ") - 1));
1939 buf = hdr_buf + LOG_CHECKPOINT_1;
1945 LOG_FILE_HDR_SIZE + LOG_BLOCK_HDR_SIZE);
1955 LOG_CHECKPOINT_CHECKSUM_2 - LOG_CHECKPOINT_LSN);
1964#ifndef UNIV_HOTBACKUP
1974 ut_ad(mutex_own(&(log_sys->mutex)));
1976 log_sys->n_log_ios++;
1979 field / UNIV_PAGE_SIZE, field % UNIV_PAGE_SIZE,
1992 ut_ad(mutex_own(&(log_sys->mutex)));
1997 log_group_checkpoint(group);
2022 ib_uint64_t oldest_lsn;
2032 mutex_enter(&(log_sys->mutex));
2034 ut_ad(!recv_no_log_write);
2035 oldest_lsn = log_buf_pool_get_oldest_modification();
2037 mutex_exit(&(log_sys->mutex));
2049 mutex_enter(&(log_sys->mutex));
2052 && log_sys->last_checkpoint_lsn >= oldest_lsn) {
2054 mutex_exit(&(log_sys->mutex));
2059 ut_ad(log_sys->flushed_to_disk_lsn >= oldest_lsn);
2061 if (log_sys->n_pending_checkpoint_writes > 0) {
2064 mutex_exit(&(log_sys->mutex));
2069 rw_lock_s_unlock(&(log_sys->checkpoint_lock));
2075 log_sys->next_checkpoint_lsn = oldest_lsn;
2078 if (log_debug_writes) {
2079 fprintf(stderr,
"Making checkpoint no %lu at lsn %" PRIu64
"\n",
2080 (ulong) log_sys->next_checkpoint_no,
2087 mutex_exit(&(log_sys->mutex));
2092 rw_lock_s_unlock(&(log_sys->checkpoint_lock));
2129log_checkpoint_margin(
void)
2132 log_t* log = log_sys;
2134 ib_uint64_t checkpoint_age;
2135 ib_uint64_t advance;
2136 ib_uint64_t oldest_lsn;
2138 ibool checkpoint_sync;
2139 ibool do_checkpoint;
2143 checkpoint_sync = FALSE;
2144 do_checkpoint = FALSE;
2146 mutex_enter(&(log->
mutex));
2147 ut_ad(!recv_no_log_write);
2150 mutex_exit(&(log->
mutex));
2155 oldest_lsn = log_buf_pool_get_oldest_modification();
2157 age = log->
lsn - oldest_lsn;
2165 }
else if (age > log_max_modified_age_async()) {
2168 advance = age - log_max_modified_age_async();
2178 checkpoint_sync = TRUE;
2180 do_checkpoint = TRUE;
2182 }
else if (checkpoint_age > log_max_checkpoint_age_async()) {
2185 do_checkpoint = TRUE;
2192 mutex_exit(&(log->
mutex));
2195 ib_uint64_t new_oldest = oldest_lsn + advance;
2205 if (sync && !success) {
2206 mutex_enter(&(log->
mutex));
2210 mutex_exit(&(log->
mutex));
2215 if (do_checkpoint) {
2218 if (checkpoint_sync) {
2234 ib_uint64_t start_lsn,
2235 ib_uint64_t end_lsn)
2238 ulint source_offset;
2241 ut_ad(mutex_own(&(log_sys->mutex)));
2243 sync = (type == LOG_RECOVER);
2245 source_offset = log_group_calc_lsn_offset(start_lsn, group);
2247 len = (ulint) (end_lsn - start_lsn);
2256#ifdef UNIV_LOG_ARCHIVE
2257 if (type == LOG_ARCHIVE) {
2259 log_sys->n_pending_archive_ios++;
2263 log_sys->n_log_ios++;
2266 source_offset / UNIV_PAGE_SIZE, source_offset % UNIV_PAGE_SIZE,
2272 if (start_lsn != end_lsn) {
2278#ifdef UNIV_LOG_ARCHIVE
2291 sprintf(buf,
"%sib_arch_log_%010lu", srv_arch_dir, (ulong) file_no);
2298log_group_archive_file_header_write(
2304 ib_uint64_t start_lsn)
2310 ut_ad(mutex_own(&(log_sys->mutex)));
2312 ut_a(nth_file < group->n_files);
2314 buf = *(group->archive_file_header_bufs + nth_file);
2322 dest_offset = nth_file * group->
file_size;
2324 log_sys->n_log_ios++;
2326 fil_io(OS_FILE_WRITE | OS_FILE_LOG, TRUE, group->archive_space_id,
2327 dest_offset / UNIV_PAGE_SIZE,
2328 dest_offset % UNIV_PAGE_SIZE,
2330 buf, &log_archive_io);
2337log_group_archive_completed_header_write(
2342 ib_uint64_t end_lsn)
2347 ut_ad(mutex_own(&(log_sys->mutex)));
2348 ut_a(nth_file < group->n_files);
2350 buf = *(group->archive_file_header_bufs + nth_file);
2355 dest_offset = nth_file * group->
file_size + LOG_FILE_ARCH_COMPLETED;
2357 log_sys->n_log_ios++;
2359 fil_io(OS_FILE_WRITE | OS_FILE_LOG, TRUE, group->archive_space_id,
2360 dest_offset / UNIV_PAGE_SIZE,
2361 dest_offset % UNIV_PAGE_SIZE,
2363 buf + LOG_FILE_ARCH_COMPLETED,
2376 ib_uint64_t start_lsn;
2377 ib_uint64_t end_lsn;
2386 ut_ad(mutex_own(&(log_sys->mutex)));
2388 start_lsn = log_sys->archived_lsn;
2392 end_lsn = log_sys->next_archived_lsn;
2396 buf = log_sys->archive_buf;
2400 next_offset = group->archived_offset;
2402 if ((next_offset % group->
file_size == 0)
2403 || (fil_space_get_size(group->archive_space_id) == 0)) {
2408 if (next_offset % group->
file_size == 0) {
2409 open_mode = OS_FILE_CREATE;
2415 group->archived_file_no + n_files);
2417 file_handle = os_file_create(innodb_file_log_key,
2422 if (!ret && (open_mode == OS_FILE_CREATE)) {
2423 file_handle = os_file_create(
2430 "InnoDB: Cannot create or open"
2431 " archive log file %s.\n"
2432 "InnoDB: Cannot continue operation.\n"
2433 "InnoDB: Check that the log archive"
2434 " directory exists,\n"
2435 "InnoDB: you have access rights to it, and\n"
2436 "InnoDB: there is space available.\n", name);
2441 if (log_debug_writes) {
2442 fprintf(stderr,
"Created archive file %s\n", name);
2446 ret = os_file_close(file_handle);
2452 fil_node_create(name, group->
file_size / UNIV_PAGE_SIZE,
2453 group->archive_space_id, FALSE);
2455 if (next_offset % group->
file_size == 0) {
2456 log_group_archive_file_header_write(
2458 group->archived_file_no + n_files,
2461 next_offset += LOG_FILE_HDR_SIZE;
2465 len = end_lsn - start_lsn;
2473 if (log_debug_writes) {
2475 "Archiving starting at lsn %" PRIu64
", len %lu"
2478 (ulong) len, (ulong) group->
id);
2482 log_sys->n_pending_archive_ios++;
2484 log_sys->n_log_ios++;
2486 fil_io(OS_FILE_WRITE | OS_FILE_LOG, FALSE, group->archive_space_id,
2487 next_offset / UNIV_PAGE_SIZE, next_offset % UNIV_PAGE_SIZE,
2495 if (next_offset % group->
file_size == 0) {
2499 if (end_lsn != start_lsn) {
2504 group->next_archived_file_no = group->archived_file_no + n_files;
2505 group->next_archived_offset = next_offset % group->
file_size;
2515log_archive_groups(
void)
2520 ut_ad(mutex_own(&(log_sys->mutex)));
2524 log_group_archive(group);
2532log_archive_write_complete_groups(
void)
2539 ib_uint64_t start_lsn;
2540 ib_uint64_t end_lsn;
2543 ut_ad(mutex_own(&(log_sys->mutex)));
2547 group->archived_file_no = group->next_archived_file_no;
2548 group->archived_offset = group->next_archived_offset;
2553 n_files = (UNIV_PAGE_SIZE
2554 * fil_space_get_size(group->archive_space_id))
2558 end_offset = group->archived_offset;
2560 if (end_offset % group->
file_size == 0) {
2562 trunc_files = n_files;
2564 trunc_files = n_files - 1;
2568 if (log_debug_writes && trunc_files) {
2570 "Complete file(s) archived to group %lu\n",
2576 start_lsn = log_sys->next_archived_lsn
2577 - (end_offset - LOG_FILE_HDR_SIZE + trunc_files
2578 * (group->
file_size - LOG_FILE_HDR_SIZE));
2579 end_lsn = start_lsn;
2581 for (i = 0; i < trunc_files; i++) {
2583 end_lsn += group->
file_size - LOG_FILE_HDR_SIZE;
2588 log_group_archive_completed_header_write(group, i, end_lsn);
2591 fil_space_truncate_start(group->archive_space_id,
2595 if (log_debug_writes) {
2596 fputs(
"Archiving writes completed\n", stderr);
2605log_archive_check_completion_low(
void)
2608 ut_ad(mutex_own(&(log_sys->mutex)));
2610 if (log_sys->n_pending_archive_ios == 0
2611 && log_sys->archiving_phase == LOG_ARCHIVE_READ) {
2614 if (log_debug_writes) {
2615 fputs(
"Archiving read completed\n", stderr);
2621 log_sys->archiving_phase = LOG_ARCHIVE_WRITE;
2623 log_archive_groups();
2626 if (log_sys->n_pending_archive_ios == 0
2627 && log_sys->archiving_phase == LOG_ARCHIVE_WRITE) {
2629 log_archive_write_complete_groups();
2631 log_sys->archived_lsn = log_sys->next_archived_lsn;
2633 rw_lock_x_unlock_gen(&(log_sys->archive_lock), LOG_ARCHIVE);
2641log_io_complete_archive(
void)
2646 mutex_enter(&(log_sys->mutex));
2650 mutex_exit(&(log_sys->mutex));
2652 fil_flush(group->archive_space_id);
2654 mutex_enter(&(log_sys->mutex));
2656 ut_ad(log_sys->n_pending_archive_ios > 0);
2658 log_sys->n_pending_archive_ios--;
2660 log_archive_check_completion_low();
2662 mutex_exit(&(log_sys->mutex));
2676 ibool calc_new_limit;
2677 ib_uint64_t start_lsn;
2678 ib_uint64_t limit_lsn;
2680 calc_new_limit = TRUE;
2682 mutex_enter(&(log_sys->mutex));
2684 switch (log_sys->archiving_state) {
2687 mutex_exit(&(log_sys->mutex));
2692 case LOG_ARCH_STOPPED:
2693 case LOG_ARCH_STOPPING2:
2694 mutex_exit(&(log_sys->mutex));
2696 os_event_wait(log_sys->archiving_on);
2701 start_lsn = log_sys->archived_lsn;
2703 if (calc_new_limit) {
2705 limit_lsn = start_lsn + log_sys->archive_buf_size;
2707 *n_bytes = log_sys->archive_buf_size;
2709 if (limit_lsn >= log_sys->lsn) {
2716 if (log_sys->archived_lsn >= limit_lsn) {
2721 if (log_sys->written_to_all_lsn < limit_lsn) {
2723 mutex_exit(&(log_sys->mutex));
2727 calc_new_limit = FALSE;
2732 if (log_sys->n_pending_archive_ios > 0) {
2735 mutex_exit(&(log_sys->mutex));
2739 rw_lock_s_unlock(&(log_sys->archive_lock));
2742 *n_bytes = log_sys->archive_buf_size;
2747 rw_lock_x_lock_gen(&(log_sys->archive_lock), LOG_ARCHIVE);
2749 log_sys->archiving_phase = LOG_ARCHIVE_READ;
2751 log_sys->next_archived_lsn = limit_lsn;
2754 if (log_debug_writes) {
2756 "Archiving from lsn %" PRIu64
" to lsn %" PRIu64
"\n",
2757 log_sys->archived_lsn, limit_lsn);
2765 start_lsn, limit_lsn);
2767 mutex_exit(&(log_sys->mutex));
2771 rw_lock_s_unlock(&(log_sys->archive_lock));
2774 *n_bytes = log_sys->archive_buf_size;
2784log_archive_all(
void)
2787 ib_uint64_t present_lsn;
2790 mutex_enter(&(log_sys->mutex));
2792 if (log_sys->archiving_state == LOG_ARCH_OFF) {
2793 mutex_exit(&(log_sys->mutex));
2798 present_lsn = log_sys->lsn;
2800 mutex_exit(&(log_sys->mutex));
2802 log_pad_current_log_block();
2805 mutex_enter(&(log_sys->mutex));
2807 if (present_lsn <= log_sys->archived_lsn) {
2809 mutex_exit(&(log_sys->mutex));
2814 mutex_exit(&(log_sys->mutex));
2825log_archive_close_groups(
2827 ibool increment_file_count)
2833 ut_ad(mutex_own(&(log_sys->mutex)));
2835 if (log_sys->archiving_state == LOG_ARCH_OFF) {
2842 trunc_len = UNIV_PAGE_SIZE
2843 * fil_space_get_size(group->archive_space_id);
2844 if (trunc_len > 0) {
2850 log_group_archive_completed_header_write(
2851 group, 0, log_sys->archived_lsn);
2853 fil_space_truncate_start(group->archive_space_id,
2855 if (increment_file_count) {
2856 group->archived_offset = 0;
2857 group->archived_file_no += 2;
2861 if (log_debug_writes) {
2863 "Incrementing arch file no to %lu"
2864 " in log group %lu\n",
2865 (ulong) group->archived_file_no + 2,
2885 mutex_enter(&(log_sys->mutex));
2887 if (log_sys->archiving_state != LOG_ARCH_ON) {
2889 mutex_exit(&(log_sys->mutex));
2894 log_sys->archiving_state = LOG_ARCH_STOPPING;
2896 mutex_exit(&(log_sys->mutex));
2900 mutex_enter(&(log_sys->mutex));
2902 log_sys->archiving_state = LOG_ARCH_STOPPING2;
2905 mutex_exit(&(log_sys->mutex));
2910 rw_lock_s_unlock(&(log_sys->archive_lock));
2912 mutex_enter(&(log_sys->mutex));
2917 log_archive_close_groups(TRUE);
2919 mutex_exit(&(log_sys->mutex));
2930 mutex_enter(&(log_sys->mutex));
2932 log_sys->archiving_state = LOG_ARCH_STOPPED;
2934 mutex_exit(&(log_sys->mutex));
2947 mutex_enter(&(log_sys->mutex));
2949 if (log_sys->archiving_state != LOG_ARCH_STOPPED) {
2951 mutex_exit(&(log_sys->mutex));
2956 log_sys->archiving_state = LOG_ARCH_ON;
2960 mutex_exit(&(log_sys->mutex));
2974 mutex_enter(&(log_sys->mutex));
2976 if (log_sys->archiving_state == LOG_ARCH_STOPPED
2977 || log_sys->archiving_state == LOG_ARCH_OFF) {
2979 log_sys->archiving_state = LOG_ARCH_OFF;
2983 mutex_exit(&(log_sys->mutex));
2988 mutex_exit(&(log_sys->mutex));
3005 mutex_enter(&(log_sys->mutex));
3007 if (log_sys->archiving_state == LOG_ARCH_OFF) {
3009 log_sys->archiving_state = LOG_ARCH_ON;
3011 log_sys->archived_lsn
3014 mutex_exit(&(log_sys->mutex));
3019 mutex_exit(&(log_sys->mutex));
3030log_archive_margin(
void)
3033 log_t* log = log_sys;
3038 mutex_enter(&(log->
mutex));
3040 if (log->archiving_state == LOG_ARCH_OFF) {
3041 mutex_exit(&(log->
mutex));
3046 age = log->
lsn - log->archived_lsn;
3048 if (age > log->max_archived_lsn_age) {
3054 }
else if (age > log->max_archived_lsn_age_async) {
3062 mutex_exit(&(log->
mutex));
3067 mutex_exit(&(log->
mutex));
3092 log_checkpoint_margin();
3094#ifdef UNIV_LOG_ARCHIVE
3095 log_archive_margin();
3098 mutex_enter(&(log_sys->mutex));
3099 ut_ad(!recv_no_log_write);
3101 if (log_sys->check_flush_or_checkpoint) {
3103 mutex_exit(&(log_sys->mutex));
3108 mutex_exit(&(log_sys->mutex));
3124 if (srv_print_verbose_log) {
3126 fprintf(stderr,
" InnoDB: Starting shutdown...\n");
3135 mutex_enter(&kernel_mutex);
3141 if (srv_fast_shutdown < 2
3142 && (srv_error_monitor_active
3143 || srv_lock_timeout_active
3144 || srv_monitor_active)) {
3146 mutex_exit(&kernel_mutex);
3159 if (! srv_apply_log_only) {
3163 mutex_exit(&kernel_mutex);
3169 if (srv_fast_shutdown == 2) {
3180 mutex_exit(&kernel_mutex);
3185 mutex_exit(&kernel_mutex);
3193 mutex_enter(&(log_sys->mutex));
3195 if (log_sys->n_pending_checkpoint_writes
3196#ifdef UNIV_LOG_ARCHIVE
3197 || log_sys->n_pending_archive_ios
3199 || log_sys->n_pending_writes) {
3201 mutex_exit(&(log_sys->mutex));
3206 mutex_exit(&(log_sys->mutex));
3213#ifdef UNIV_LOG_ARCHIVE
3219 mutex_enter(&(log_sys->mutex));
3223 if (lsn != log_sys->last_checkpoint_lsn
3224#ifdef UNIV_LOG_ARCHIVE
3225 || (srv_log_archive_on
3226 && lsn != log_sys->archived_lsn + LOG_BLOCK_HDR_SIZE)
3230 mutex_exit(&(log_sys->mutex));
3237#ifdef UNIV_LOG_ARCHIVE
3245 log_archive_close_groups(TRUE);
3248 mutex_exit(&(log_sys->mutex));
3253 "InnoDB: Warning: some background thread woke up"
3254 " during shutdown\n");
3260 fil_flush_file_spaces(
FIL_LOG);
3278 ut_a(lsn == log_sys->lsn);
3281 drizzled::errmsg_printf(drizzled::error::ERROR,
3282 "InnoDB: Error: log sequence number at shutdown %" PRIu64
" is lower than at startup %" PRIu64
"!",
3288 fil_write_flushed_lsn_to_data_files(lsn, arch_log_no);
3298 ut_a(lsn == log_sys->lsn);
3301#ifdef UNIV_LOG_DEBUG
3313 ib_uint64_t buf_start_lsn)
3315 ib_uint64_t contiguous_lsn;
3316 ib_uint64_t scanned_lsn;
3322 ut_ad(mutex_own(&(log_sys->mutex)));
3335 ut_memcpy(scan_buf, start, end - start);
3339 * UNIV_PAGE_SIZE, FALSE, scan_buf, end - start,
3342 &contiguous_lsn, &scanned_lsn);
3344 ut_a(scanned_lsn == buf_start_lsn + len);
3362 if (0 == mutex_enter_nowait(&(log_sys->mutex))) {
3363 *lsn = log_sys->lsn;
3365 mutex_exit(&(log_sys->mutex));
3381 double time_elapsed;
3382 time_t current_time;
3384 mutex_enter(&(log_sys->mutex));
3387 "Log sequence number %" PRIu64
"\n"
3388 "Log flushed up to %" PRIu64
"\n"
3389 "Last checkpoint at %" PRIu64
"\n",
3391 log_sys->flushed_to_disk_lsn,
3392 log_sys->last_checkpoint_lsn);
3395 "Max checkpoint age %lu\n"
3396 "Checkpoint age target %lu\n"
3397 "Modified age %" PRIu64
"\n"
3398 "Checkpoint age %" PRIu64
"\n",
3399 log_sys->max_checkpoint_age,
3400 log_max_checkpoint_age_async(),
3401 log_sys->lsn - log_buf_pool_get_oldest_modification(),
3402 log_sys->lsn - log_sys->last_checkpoint_lsn);
3404 current_time = time(NULL);
3406 time_elapsed = 0.001 + difftime(current_time,
3407 log_sys->last_printout_time);
3409 "%lu pending log writes, %lu pending chkp writes\n"
3410 "%lu log i/o's done, %.2f log i/o's/second\n",
3411 (ulong) log_sys->n_pending_writes,
3412 (ulong) log_sys->n_pending_checkpoint_writes,
3413 (ulong) log_sys->n_log_ios,
3414 ((log_sys->n_log_ios - log_sys->n_log_ios_old)
3417 log_sys->n_log_ios_old = log_sys->n_log_ios;
3418 log_sys->last_printout_time = current_time;
3420 mutex_exit(&(log_sys->mutex));
3430 log_sys->n_log_ios_old = log_sys->n_log_ios;
3431 log_sys->last_printout_time = time(NULL);
3444 for (i = 0; i < group->
n_files; i++) {
3446#ifdef UNIV_LOG_ARCHIVE
3447 mem_free(group->archive_file_header_bufs_ptr[i]);
3454#ifdef UNIV_LOG_ARCHIVE
3455 mem_free(group->archive_file_header_bufs_ptr);
3456 mem_free(group->archive_file_header_bufs);
3481 log_group_close(prev_group);
3485 log_sys->buf_ptr = NULL;
3486 log_sys->buf = NULL;
3487 mem_free(log_sys->checkpoint_buf_ptr);
3488 log_sys->checkpoint_buf_ptr = NULL;
3489 log_sys->checkpoint_buf = NULL;
3494 rw_lock_free(&log_sys->checkpoint_lock);
3496 mutex_free(&log_sys->mutex);
3498#ifdef UNIV_LOG_ARCHIVE
3499 rw_lock_free(&log_sys->archive_lock);
3503#ifdef UNIV_LOG_DEBUG
3504 recv_sys_debug_free();
3517 if (log_sys != NULL) {
UNIV_INTERN ibool buf_pool_check_no_pending_io(void)
UNIV_INLINE ulint buf_pool_get_curr_size(void)
UNIV_INTERN ib_uint64_t buf_pool_get_oldest_modification(void)
UNIV_INTERN ibool buf_all_freed(void)
UNIV_INLINE ulint buf_pool_get_n_pages(void)
UNIV_INTERN void fil_close_all_files(void)
UNIV_INTERN void log_group_set_fields(log_group_t *group, ib_uint64_t lsn)
UNIV_INTERN void log_refresh_stats(void)
UNIV_INTERN void log_group_read_checkpoint_info(log_group_t *group, ulint field)
UNIV_INTERN void log_make_checkpoint_at(ib_uint64_t lsn, ibool write_always)
UNIV_INLINE ulint log_block_get_data_len(const byte *log_block)
UNIV_INTERN ulint log_group_get_capacity(const log_group_t *group)
UNIV_INTERN void log_write_low(byte *str, ulint str_len)
UNIV_INTERN void log_check_margins(void)
UNIV_INTERN ulint log_archive_start(void)
UNIV_INTERN ibool log_archive_do(ibool sync, ulint *n_bytes)
UNIV_INTERN ibool log_preflush_pool_modified_pages(ib_uint64_t new_oldest, ibool sync)
UNIV_INTERN void logs_empty_and_mark_files_at_shutdown(void)
UNIV_INLINE void log_release(void)
UNIV_INTERN void log_write_up_to(ib_uint64_t lsn, ulint wait, ibool flush_to_disk)
UNIV_INLINE ulint log_block_get_hdr_no(const byte *log_block)
UNIV_INLINE ulint log_block_convert_lsn_to_no(ib_uint64_t lsn)
UNIV_INLINE ulint log_block_calc_checksum(const byte *block)
UNIV_INLINE void log_block_set_checksum(byte *log_block, ulint checksum)
UNIV_INTERN void log_checkpoint_get_nth_group_info(const byte *buf, ulint n, ulint *file_no, ulint *offset)
UNIV_INTERN ulint log_archive_archivelog(void)
UNIV_INTERN void log_print(FILE *file)
UNIV_INLINE void log_block_init(byte *log_block, ib_uint64_t lsn)
UNIV_INLINE void log_block_set_data_len(byte *log_block, ulint len)
UNIV_INTERN void log_buffer_flush_to_disk(void)
UNIV_INTERN ulint log_archive_stop(void)
UNIV_INTERN void log_group_write_buf(log_group_t *group, byte *buf, ulint len, ib_uint64_t start_lsn, ulint new_data_offset)
UNIV_INTERN void log_fsp_current_free_limit_set_and_checkpoint(ulint limit)
UNIV_INLINE ulint log_block_get_first_rec_group(const byte *log_block)
UNIV_INTERN void log_buffer_sync_in_background(ibool flush)
UNIV_INTERN ibool log_peek_lsn(ib_uint64_t *lsn)
UNIV_INTERN void log_io_complete(log_group_t *group)
UNIV_INTERN ulint log_calc_where_lsn_is(ib_int64_t *log_file_offset, ib_uint64_t first_header_lsn, ib_uint64_t lsn, ulint n_log_files, ib_int64_t log_file_size)
UNIV_INTERN ib_uint64_t log_close(void)
UNIV_INTERN void log_group_read_log_seg(ulint type, byte *buf, log_group_t *group, ib_uint64_t start_lsn, ib_uint64_t end_lsn)
UNIV_INTERN void log_group_init(ulint id, ulint n_files, ulint file_size, ulint space_id, ulint archive_space_id)
UNIV_INTERN ulint log_archive_noarchivelog(void)
UNIV_INTERN ib_uint64_t log_reserve_and_open(ulint len)
struct log_group_struct log_group_t
UNIV_INTERN void log_archived_file_name_gen(char *buf, ulint id, ulint file_no)
UNIV_INLINE void log_block_set_first_rec_group(byte *log_block, ulint offset)
UNIV_INTERN ibool log_checkpoint(ibool sync, ibool write_always)
UNIV_INTERN void log_init(void)
UNIV_INTERN void log_groups_write_checkpoint_info(void)
UNIV_INTERN void recv_sys_mem_free(void)
UNIV_INTERN void recv_sys_close(void)
UNIV_INTERN void recv_apply_hashed_log_recs(ibool allow_ibuf)
UNIV_INTERN void recv_sys_create(void)
UNIV_INTERN ibool recv_scan_log_recs(ulint available_memory, ibool store_to_hash, const byte *buf, ulint len, ib_uint64_t start_lsn, ib_uint64_t *contiguous_lsn, ib_uint64_t *group_scanned_lsn)
ibool recv_no_ibuf_operations
ulint recv_n_pool_free_frames
UNIV_INTERN void recv_sys_init(ulint available_memory)
UNIV_INLINE ibool recv_recovery_is_on(void)
UNIV_INLINE void mach_write_to_8(byte *b, ib_uint64_t n)
UNIV_INLINE void mach_write_to_4(byte *b, ulint n)
UNIV_INLINE ulint mach_read_from_4(const byte *b) __attribute__((nonnull
#define MLOG_DUMMY_RECORD
#define OS_FILE_LOG_BLOCK_SIZE
UNIV_INTERN ib_int64_t os_event_reset(os_event_t event)
UNIV_INTERN os_event_t os_event_create(const char *name)
UNIV_INTERN void os_event_set(os_event_t event)
UNIV_INTERN void os_event_free(os_event_t event)
UNIV_INTERN void os_thread_sleep(ulint tm)
ulint srv_buf_pool_instances
UNIV_INTERN ibool srv_is_any_background_thread_active(void)
ib_uint64_t srv_shutdown_lsn
@ SRV_SHUTDOWN_LAST_PHASE
ib_uint64_t srv_start_lsn
byte * checkpoint_buf_ptr
byte ** file_header_bufs_ptr
ib_uint64_t last_checkpoint_lsn
ibool check_flush_or_checkpoint
ulint max_modified_age_sync
#define rw_lock_s_lock(M)
#define rw_lock_create(K, L, level)
ulint trx_n_mysql_transactions
UNIV_INLINE void * ut_align(const void *ptr, ulint align_no)
UNIV_INLINE void * ut_align_down(const void *ptr, ulint align_no) __attribute__((const))
UNIV_INLINE ib_uint64_t ut_uint64_align_down(ib_uint64_t n, ulint align_no)
#define UT_LIST_GET_LEN(BASE)
#define UT_LIST_REMOVE(NAME, BASE, N)
#define UT_LIST_GET_FIRST(BASE)
#define UT_LIST_ADD_LAST(NAME, BASE, N)
#define UT_LIST_GET_NEXT(NAME, N)
#define UT_LIST_INIT(BASE)
UNIV_INLINE void * ut_memcpy(void *dest, const void *sour, ulint n)
UNIV_INLINE void * ut_memmove(void *dest, const void *sour, ulint n)
UNIV_INLINE ulint ut_fold_binary(const byte *str, ulint len) __attribute__((pure))
UNIV_INLINE ulint ut_min(ulint n1, ulint n2)
UNIV_INTERN void ut_print_timestamp(FILE *file)
UNIV_INTERN void ut_sprintf_timestamp(char *buf)
#define ut_calc_align_down(n, m)
#define ut_calc_align(n, m)