[Commits] 633946fb63f: Merge branch '10.1' into 10.2

Oleksandr Byelkin sanja at mariadb.com
Mon May 6 19:07:53 EEST 2019


revision-id: 633946fb63f6957b49554ce6f6d33862951d810e (mariadb-10.2.23-117-g633946fb63f)
parent(s): 54d0a55adf6fbfc92c5473bbcad2b459f14ef038 0573744a83ad89958c4e48a9299cd9274db1b355
author: Oleksandr Byelkin
committer: Oleksandr Byelkin
timestamp: 2019-05-06 18:07:40 +0200
message:

Merge branch '10.1' into 10.2


 .../innodb/r/innodb_skip_innodb_is_tables.result   |  6 ++---
 sql/sql_base.cc                                    |  9 +++----
 storage/innobase/log/log0log.cc                    |  6 -----
 storage/innobase/srv/srv0mon.cc                    | 28 +++++++++++++++++++---
 storage/xtradb/log/log0log.cc                      | 21 ----------------
 storage/xtradb/srv/srv0mon.cc                      | 28 +++++++++++++++++++---
 support-files/rpm/server-postin.sh                 |  3 +++
 7 files changed, 61 insertions(+), 40 deletions(-)

diff --cc mysql-test/suite/innodb/r/innodb_skip_innodb_is_tables.result
index 5bac43badb3,65e063979c4..6ce63a5744b
--- a/mysql-test/suite/innodb/r/innodb_skip_innodb_is_tables.result
+++ b/mysql-test/suite/innodb/r/innodb_skip_innodb_is_tables.result
@@@ -204,9 -193,9 +204,9 @@@ log_lsn_checkpoint_age	recovery	0	NULL	
  log_lsn_buf_pool_oldest	recovery	0	NULL	NULL	NULL	0	NULL	NULL	NULL	NULL	NULL	NULL	NULL	disabled	value	The oldest modified block LSN in the buffer pool
  log_max_modified_age_async	recovery	0	NULL	NULL	NULL	0	NULL	NULL	NULL	NULL	NULL	NULL	NULL	disabled	value	Maximum LSN difference; when exceeded, start asynchronous preflush
  log_max_modified_age_sync	recovery	0	NULL	NULL	NULL	0	NULL	NULL	NULL	NULL	NULL	NULL	NULL	disabled	value	Maximum LSN difference; when exceeded, start synchronous preflush
- log_pending_log_flushes	recovery	0	NULL	NULL	NULL	0	NULL	NULL	NULL	NULL	NULL	NULL	NULL	disabled	counter	Pending log flushes
- log_pending_checkpoint_writes	recovery	0	NULL	NULL	NULL	0	NULL	NULL	NULL	NULL	NULL	NULL	NULL	disabled	counter	Pending checkpoints
- log_num_log_io	recovery	0	NULL	NULL	NULL	0	NULL	NULL	NULL	NULL	NULL	NULL	NULL	disabled	counter	Number of log I/Os
 -log_pending_log_writes	recovery	0	NULL	NULL	NULL	0	NULL	NULL	NULL	NULL	NULL	NULL	NULL	disabled	value	Pending log writes
++log_pending_log_flushes	recovery	0	NULL	NULL	NULL	0	NULL	NULL	NULL	NULL	NULL	NULL	NULL	disabled	value	Pending log flushes
+ log_pending_checkpoint_writes	recovery	0	NULL	NULL	NULL	0	NULL	NULL	NULL	NULL	NULL	NULL	NULL	disabled	value	Pending checkpoints
+ log_num_log_io	recovery	0	NULL	NULL	NULL	0	NULL	NULL	NULL	NULL	NULL	NULL	NULL	disabled	value	Number of log I/Os
  log_waits	recovery	0	NULL	NULL	NULL	0	NULL	NULL	NULL	NULL	NULL	NULL	NULL	disabled	status_counter	Number of log waits due to small log buffer (innodb_log_waits)
  log_write_requests	recovery	0	NULL	NULL	NULL	0	NULL	NULL	NULL	NULL	NULL	NULL	NULL	disabled	status_counter	Number of log write requests (innodb_log_write_requests)
  log_writes	recovery	0	NULL	NULL	NULL	0	NULL	NULL	NULL	NULL	NULL	NULL	NULL	disabled	status_counter	Number of log writes (innodb_log_writes)
diff --cc storage/innobase/log/log0log.cc
index da301a3b4f1,234fabcd860..316e337ec4e
--- a/storage/innobase/log/log0log.cc
+++ b/storage/innobase/log/log0log.cc
@@@ -800,105 -977,284 +800,103 @@@ log_init(ulint n_files
  	group->state = LOG_GROUP_OK;
  	group->lsn = LOG_START_LSN;
  	group->lsn_offset = LOG_FILE_HDR_SIZE;
 -	group->n_pending_writes = 0;
 -
 -	group->file_header_bufs_ptr = static_cast<byte**>(
 -		mem_zalloc(sizeof(byte*) * n_files));
  
 -	group->file_header_bufs = static_cast<byte**>(
 -		mem_zalloc(sizeof(byte**) * n_files));
 +	group->checkpoint_buf_ptr = static_cast<byte*>(
 +		ut_zalloc_nokey(2 * OS_FILE_LOG_BLOCK_SIZE));
  
 -#ifdef UNIV_LOG_ARCHIVE
 -	group->archive_file_header_bufs_ptr = static_cast<byte*>(
 -		mem_zalloc( sizeof(byte*) * n_files));
 +	group->checkpoint_buf = static_cast<byte*>(
 +		ut_align(group->checkpoint_buf_ptr,OS_FILE_LOG_BLOCK_SIZE));
 +}
  
 -	group->archive_file_header_bufs = static_cast<byte*>(
 -		mem_zalloc(sizeof(byte*) * n_files));
 -#endif /* UNIV_LOG_ARCHIVE */
 +/******************************************************//**
 +Completes an i/o to a log file. */
 +void
 +log_io_complete(
 +/*============*/
 +	log_group_t*	group)	/*!< in: log group or a dummy pointer */
 +{
 +	if ((ulint) group & 0x1UL) {
 +		/* It was a checkpoint write */
 +		group = (log_group_t*)((ulint) group - 1);
  
 -	for (i = 0; i < n_files; i++) {
 -		group->file_header_bufs_ptr[i] = static_cast<byte*>(
 -			mem_zalloc(LOG_FILE_HDR_SIZE + OS_FILE_LOG_BLOCK_SIZE));
 +		switch (srv_file_flush_method) {
 +		case SRV_O_DSYNC:
 +		case SRV_NOSYNC:
 +			break;
 +		case SRV_FSYNC:
 +		case SRV_LITTLESYNC:
 +		case SRV_O_DIRECT:
 +		case SRV_O_DIRECT_NO_FSYNC:
 +		case SRV_ALL_O_DIRECT_FSYNC:
 +			fil_flush(SRV_LOG_SPACE_FIRST_ID);
 +		}
  
 -		group->file_header_bufs[i] = static_cast<byte*>(
 -			ut_align(group->file_header_bufs_ptr[i],
 -				 OS_FILE_LOG_BLOCK_SIZE));
  
 -#ifdef UNIV_LOG_ARCHIVE
 -		group->archive_file_header_bufs_ptr[i] = static_cast<byte*>(
 -			mem_zalloc(LOG_FILE_HDR_SIZE + OS_FILE_LOG_BLOCK_SIZE));
 +		DBUG_PRINT("ib_log", ("checkpoint info written"));
 +		log_io_complete_checkpoint();
  
 -		group->archive_file_header_bufs[i] = static_cast<byte*>(
 -			ut_align(group->archive_file_header_bufs_ptr[i],
 -				 OS_FILE_LOG_BLOCK_SIZE));
 -#endif /* UNIV_LOG_ARCHIVE */
 +		return;
  	}
  
 -#ifdef UNIV_LOG_ARCHIVE
 -	group->archive_space_id = archive_space_id;
 -
 -	group->archived_file_no = 0;
 -	group->archived_offset = 0;
 -#endif /* UNIV_LOG_ARCHIVE */
 -
 -	group->checkpoint_buf_ptr = static_cast<byte*>(
 -		mem_zalloc(2 * OS_FILE_LOG_BLOCK_SIZE));
 -
 -	group->checkpoint_buf = static_cast<byte*>(
 -		ut_align(group->checkpoint_buf_ptr,OS_FILE_LOG_BLOCK_SIZE));
 -
 -	UT_LIST_ADD_LAST(log_groups, log_sys->log_groups, group);
 -
 -	ut_a(log_calc_max_ages());
 +	ut_error;	/*!< We currently use synchronous writing of the
 +			logs and cannot end up here! */
  }
  
 -/******************************************************************//**
 -Does the unlockings needed in flush i/o completion. */
 -UNIV_INLINE
 +/******************************************************//**
 +Writes a log file header to a log file space. */
 +static
  void
 -log_flush_do_unlocks(
 -/*=================*/
 -	ulint	code)	/*!< in: any ORed combination of LOG_UNLOCK_FLUSH_LOCK
 -			and LOG_UNLOCK_NONE_FLUSHED_LOCK */
 +log_group_file_header_flush(
 +/*========================*/
 +	log_group_t*	group,		/*!< in: log group */
 +	ulint		nth_file,	/*!< in: header to the nth file in the
 +					log file space */
 +	lsn_t		start_lsn)	/*!< in: log file data starts at this
 +					lsn */
  {
 -	ut_ad(mutex_own(&(log_sys->mutex)));
 +	lsn_t	dest_offset;
  
 -	/* NOTE that we must own the log mutex when doing the setting of the
 -	events: this is because transactions will wait for these events to
 -	be set, and at that moment the log flush they were waiting for must
 -	have ended. If the log mutex were not reserved here, the i/o-thread
 -	calling this function might be preempted for a while, and when it
 -	resumed execution, it might be that a new flush had been started, and
 -	this function would erroneously signal the NEW flush as completed.
 -	Thus, the changes in the state of these events are performed
 -	atomically in conjunction with the changes in the state of
 -	log_sys->n_pending_writes etc. */
 +	ut_ad(log_write_mutex_own());
 +	ut_ad(!recv_no_log_write);
 +	ut_a(nth_file < group->n_files);
 +	ut_ad((group->format & ~LOG_HEADER_FORMAT_ENCRYPTED)
 +	      == (srv_safe_truncate
 +		  ? LOG_HEADER_FORMAT_10_3
 +		  : LOG_HEADER_FORMAT_10_2));
 +
 +	// man 2 open suggests this buffer to be aligned by 512 for O_DIRECT
 +	MY_ALIGNED(OS_FILE_LOG_BLOCK_SIZE)
 +	byte buf[OS_FILE_LOG_BLOCK_SIZE] = {0};
 +
 +	mach_write_to_4(buf + LOG_HEADER_FORMAT, group->format);
 +	mach_write_to_4(buf + LOG_HEADER_SUBFORMAT, srv_safe_truncate);
 +	mach_write_to_8(buf + LOG_HEADER_START_LSN, start_lsn);
 +	strcpy(reinterpret_cast<char*>(buf) + LOG_HEADER_CREATOR,
 +	       LOG_HEADER_CREATOR_CURRENT);
 +	ut_ad(LOG_HEADER_CREATOR_END - LOG_HEADER_CREATOR
 +	      >= sizeof LOG_HEADER_CREATOR_CURRENT);
 +	log_block_set_checksum(buf, log_block_calc_checksum_crc32(buf));
  
 -	if (code & LOG_UNLOCK_NONE_FLUSHED_LOCK) {
 -		os_event_set(log_sys->one_flushed_event);
 -	}
 +	dest_offset = nth_file * group->file_size;
  
 -	if (code & LOG_UNLOCK_FLUSH_LOCK) {
 -		os_event_set(log_sys->no_flush_event);
 -	}
 -}
 +	DBUG_PRINT("ib_log", ("write " LSN_PF
 +			      " file " ULINTPF " header",
 +			      start_lsn, nth_file));
  
 -/******************************************************************//**
 -Checks if a flush is completed for a log group and does the completion
 -routine if yes.
 - at return	LOG_UNLOCK_NONE_FLUSHED_LOCK or 0 */
 -UNIV_INLINE
 -ulint
 -log_group_check_flush_completion(
 -/*=============================*/
 -	log_group_t*	group)	/*!< in: log group */
 -{
 -	ut_ad(mutex_own(&(log_sys->mutex)));
 +	log_sys->n_log_ios++;
  
- 	MONITOR_INC(MONITOR_LOG_IO);
- 
 -	if (!log_sys->one_flushed && group->n_pending_writes == 0) {
 -#ifdef UNIV_DEBUG
 -		if (log_debug_writes) {
 -			fprintf(stderr,
 -				"Log flushed first to group %lu\n",
 -				(ulong) group->id);
 -		}
 -#endif /* UNIV_DEBUG */
 -		log_sys->written_to_some_lsn = log_sys->write_lsn;
 -		log_sys->one_flushed = TRUE;
 +	srv_stats.os_log_pending_writes.inc();
  
 -		return(LOG_UNLOCK_NONE_FLUSHED_LOCK);
 -	}
 +	const ulint	page_no
 +		= (ulint) (dest_offset / univ_page_size.physical());
  
 -#ifdef UNIV_DEBUG
 -	if (log_debug_writes && (group->n_pending_writes == 0)) {
 +	fil_io(IORequestLogWrite, true,
 +	       page_id_t(SRV_LOG_SPACE_FIRST_ID, page_no),
 +	       univ_page_size,
 +	       (ulint) (dest_offset % univ_page_size.physical()),
 +	       OS_FILE_LOG_BLOCK_SIZE, buf, group);
  
 -		fprintf(stderr, "Log flushed to group %lu\n",
 -			(ulong) group->id);
 -	}
 -#endif /* UNIV_DEBUG */
 -	return(0);
 -}
 -
 -/******************************************************//**
 -Checks if a flush is completed and does the completion routine if yes.
 - at return	LOG_UNLOCK_FLUSH_LOCK or 0 */
 -static
 -ulint
 -log_sys_check_flush_completion(void)
 -/*================================*/
 -{
 -	ulint	move_start;
 -	ulint	move_end;
 -
 -	ut_ad(mutex_own(&(log_sys->mutex)));
 -
 -	if (log_sys->n_pending_writes == 0) {
 -
 -		log_sys->written_to_all_lsn = log_sys->write_lsn;
 -		log_sys->buf_next_to_write = log_sys->write_end_offset;
 -
 -		if (log_sys->write_end_offset > log_sys->max_buf_free / 2) {
 -			/* Move the log buffer content to the start of the
 -			buffer */
 -
 -			move_start = ut_calc_align_down(
 -				log_sys->write_end_offset,
 -				OS_FILE_LOG_BLOCK_SIZE);
 -			move_end = ut_calc_align(log_sys->buf_free,
 -						 OS_FILE_LOG_BLOCK_SIZE);
 -
 -			ut_memmove(log_sys->buf, log_sys->buf + move_start,
 -				   move_end - move_start);
 -			log_sys->buf_free -= move_start;
 -
 -			log_sys->buf_next_to_write -= move_start;
 -		}
 -
 -		return(LOG_UNLOCK_FLUSH_LOCK);
 -	}
 -
 -	return(0);
 -}
 -
 -/******************************************************//**
 -Completes an i/o to a log file. */
 -UNIV_INTERN
 -void
 -log_io_complete(
 -/*============*/
 -	log_group_t*	group)	/*!< in: log group or a dummy pointer */
 -{
 -	ulint	unlock;
 -
 -#ifdef UNIV_LOG_ARCHIVE
 -	if ((byte*) group == &log_archive_io) {
 -		/* It was an archive write */
 -
 -		log_io_complete_archive();
 -
 -		return;
 -	}
 -#endif /* UNIV_LOG_ARCHIVE */
 -
 -	if ((ulint) group & 0x1UL) {
 -		/* It was a checkpoint write */
 -		group = (log_group_t*)((ulint) group - 1);
 -
 -		if (srv_unix_file_flush_method != SRV_UNIX_O_DSYNC
 -		    && srv_unix_file_flush_method != SRV_UNIX_NOSYNC) {
 -
 -			fil_flush(group->space_id);
 -		}
 -
 -#ifdef UNIV_DEBUG
 -		if (log_debug_writes) {
 -			fprintf(stderr,
 -				"Checkpoint info written to group %lu\n",
 -				group->id);
 -		}
 -#endif /* UNIV_DEBUG */
 -		log_io_complete_checkpoint();
 -
 -		return;
 -	}
 -
 -	ut_error;	/*!< We currently use synchronous writing of the
 -			logs and cannot end up here! */
 -
 -	if (srv_unix_file_flush_method != SRV_UNIX_O_DSYNC
 -	    && srv_unix_file_flush_method != SRV_UNIX_NOSYNC
 -	    && srv_flush_log_at_trx_commit != 2) {
 -
 -		fil_flush(group->space_id);
 -	}
 -
 -	mutex_enter(&(log_sys->mutex));
 -	ut_ad(!recv_no_log_write);
 -
 -	ut_a(group->n_pending_writes > 0);
 -	ut_a(log_sys->n_pending_writes > 0);
 -
 -	group->n_pending_writes--;
 -	log_sys->n_pending_writes--;
 -
 -	unlock = log_group_check_flush_completion(group);
 -	unlock = unlock | log_sys_check_flush_completion();
 -
 -	log_flush_do_unlocks(unlock);
 -
 -	mutex_exit(&(log_sys->mutex));
 -}
 -
 -/******************************************************//**
 -Writes a log file header to a log file space. */
 -static
 -void
 -log_group_file_header_flush(
 -/*========================*/
 -	log_group_t*	group,		/*!< in: log group */
 -	ulint		nth_file,	/*!< in: header to the nth file in the
 -					log file space */
 -	lsn_t		start_lsn)	/*!< in: log file data starts at this
 -					lsn */
 -{
 -	byte*	buf;
 -	lsn_t	dest_offset;
 -
 -	ut_ad(mutex_own(&(log_sys->mutex)));
 -	ut_ad(!recv_no_log_write);
 -	ut_a(nth_file < group->n_files);
 -
 -	buf = *(group->file_header_bufs + nth_file);
 -
 -	mach_write_to_4(buf + LOG_GROUP_ID, group->id);
 -	mach_write_to_8(buf + LOG_FILE_START_LSN, start_lsn);
 -
 -	/* Wipe over possible label of mysqlbackup --restore */
 -	memcpy(buf + LOG_FILE_WAS_CREATED_BY_HOT_BACKUP, "    ", 4);
 -
 -	dest_offset = nth_file * group->file_size;
 -
 -#ifdef UNIV_DEBUG
 -	if (log_debug_writes) {
 -		fprintf(stderr,
 -			"Writing log file header to group %lu file %lu\n",
 -			(ulong) group->id, (ulong) nth_file);
 -	}
 -#endif /* UNIV_DEBUG */
 -	if (log_do_write) {
 -		log_sys->n_log_ios++;
 -
 -		srv_stats.os_log_pending_writes.inc();
 -
 -		fil_io(OS_FILE_WRITE | OS_FILE_LOG, true, group->space_id, 0,
 -		       (ulint) (dest_offset / UNIV_PAGE_SIZE),
 -		       (ulint) (dest_offset % UNIV_PAGE_SIZE),
 -		       OS_FILE_LOG_BLOCK_SIZE,
 -		       buf, group, 0);
 -
 -		srv_stats.os_log_pending_writes.dec();
 -	}
 +	srv_stats.os_log_pending_writes.dec();
  }
  
  /******************************************************//**
@@@ -1004,27 -1367,26 +1002,25 @@@ loop
  		log_block_store_checksum(buf + i * OS_FILE_LOG_BLOCK_SIZE);
  	}
  
 -	if (log_do_write) {
 -		log_sys->n_log_ios++;
 +	log_sys->n_log_ios++;
  
- 	MONITOR_INC(MONITOR_LOG_IO);
- 
 -		srv_stats.os_log_pending_writes.inc();
 +	srv_stats.os_log_pending_writes.inc();
  
 -		ut_a(next_offset / UNIV_PAGE_SIZE <= ULINT_MAX);
 +	ut_a(next_offset / UNIV_PAGE_SIZE <= ULINT_MAX);
  
 -		log_encrypt_before_write(log_sys->next_checkpoint_no,
 -					 buf, start_lsn, write_len);
 +	const ulint	page_no
 +		= (ulint) (next_offset / univ_page_size.physical());
  
 -		fil_io(OS_FILE_WRITE | OS_FILE_LOG, true, group->space_id, 0,
 -		       (ulint) (next_offset / UNIV_PAGE_SIZE),
 -		       (ulint) (next_offset % UNIV_PAGE_SIZE), write_len, buf,
 -			group, 0);
 +	fil_io(IORequestLogWrite, true,
 +	       page_id_t(SRV_LOG_SPACE_FIRST_ID, page_no),
 +	       univ_page_size,
 +	       (ulint) (next_offset % UNIV_PAGE_SIZE), write_len, buf,
 +	       group);
  
 -		srv_stats.os_log_pending_writes.dec();
 +	srv_stats.os_log_pending_writes.dec();
  
 -		srv_stats.os_log_written.add(write_len);
 -		srv_stats.log_writes.inc();
 -	}
 +	srv_stats.os_log_written.add(write_len);
 +	srv_stats.log_writes.inc();
  
  	if (write_len < len) {
  		start_lsn += write_len;
@@@ -1037,81 -1399,29 +1033,80 @@@
  	}
  }
  
 -/******************************************************//**
 -This function is called, e.g., when a transaction wants to commit. It checks
 -that the log has been written to the log file up to the last log entry written
 -by the transaction. If there is a flush running, it waits and checks if the
 -flush flushed enough. If not, starts a new flush. */
 -UNIV_INTERN
 +/** Flush the recently written changes to the log file.
 +and invoke log_mutex_enter(). */
 +static
 +void
 +log_write_flush_to_disk_low()
 +{
 +	/* FIXME: This is not holding log_sys->mutex while
 +	calling os_event_set()! */
 +	ut_a(log_sys->n_pending_flushes == 1); /* No other threads here */
 +
 +	bool	do_flush = srv_file_flush_method != SRV_O_DSYNC;
 +
 +	if (do_flush) {
 +		fil_flush(SRV_LOG_SPACE_FIRST_ID);
 +	}
 +
- 	MONITOR_DEC(MONITOR_PENDING_LOG_FLUSH);
 +
 +	log_mutex_enter();
 +	if (do_flush) {
 +		log_sys->flushed_to_disk_lsn = log_sys->current_flush_lsn;
 +	}
 +
 +	log_sys->n_pending_flushes--;
 +
 +	os_event_set(log_sys->flush_event);
 +}
 +
 +/** Switch the log buffer in use, and copy the content of last block
 +from old log buffer to the head of the to be used one. Thus, buf_free and
 +buf_next_to_write would be changed accordingly */
 +static inline
 +void
 +log_buffer_switch()
 +{
 +	ut_ad(log_mutex_own());
 +	ut_ad(log_write_mutex_own());
 +
 +	const byte*	old_buf = log_sys->buf;
 +	ulint		area_end = ut_calc_align(
 +		log_sys->buf_free, ulint(OS_FILE_LOG_BLOCK_SIZE));
 +
 +	if (log_sys->first_in_use) {
 +		log_sys->first_in_use = false;
 +		ut_ad(log_sys->buf == ut_align(log_sys->buf_ptr,
 +					       OS_FILE_LOG_BLOCK_SIZE));
 +		log_sys->buf += log_sys->buf_size;
 +	} else {
 +		log_sys->first_in_use = true;
 +		log_sys->buf -= log_sys->buf_size;
 +		ut_ad(log_sys->buf == ut_align(log_sys->buf_ptr,
 +					       OS_FILE_LOG_BLOCK_SIZE));
 +	}
 +
 +	/* Copy the last block to new buf */
 +	ut_memcpy(log_sys->buf,
 +		  old_buf + area_end - OS_FILE_LOG_BLOCK_SIZE,
 +		  OS_FILE_LOG_BLOCK_SIZE);
 +
 +	log_sys->buf_free %= OS_FILE_LOG_BLOCK_SIZE;
 +	log_sys->buf_next_to_write = log_sys->buf_free;
 +}
 +
 +/** Ensure that the log has been written to the log file up to a given
 +log entry (such as that of a transaction commit). Start a new write, or
 +wait and check if an already running write is covering the request.
 + at param[in]	lsn		log sequence number that should be
 +included in the redo log file write
 + at param[in]	flush_to_disk	whether the written log should also
 +be flushed to the file system */
  void
  log_write_up_to(
 -/*============*/
 -	lsn_t	lsn,	/*!< in: log sequence number up to which
 -			the log should be written,
 -			LSN_MAX if not specified */
 -	ulint	wait,	/*!< in: LOG_NO_WAIT, LOG_WAIT_ONE_GROUP,
 -			or LOG_WAIT_ALL_GROUPS */
 -	ibool	flush_to_disk)
 -			/*!< in: TRUE if we want the written log
 -			also to be flushed to disk */
 +	lsn_t	lsn,
 +	bool	flush_to_disk)
  {
 -	log_group_t*	group;
 -	ulint		start_offset;
 -	ulint		end_offset;
 -	ulint		area_start;
 -	ulint		area_end;
  #ifdef UNIV_DEBUG
  	ulint		loop_count	= 0;
  #endif /* UNIV_DEBUG */
@@@ -1184,30 -1500,22 +1179,29 @@@ loop
  		return;
  	}
  
 -#ifdef UNIV_DEBUG
 -	if (log_debug_writes) {
 -		fprintf(stderr,
 -			"Writing log from " LSN_PF " up to lsn " LSN_PF "\n",
 -			log_sys->written_to_all_lsn,
 -			log_sys->lsn);
 -	}
 -#endif /* UNIV_DEBUG */
 -	log_sys->n_pending_writes++;
 +	ulint		start_offset;
 +	ulint		end_offset;
 +	ulint		area_start;
 +	ulint		area_end;
 +	ulong		write_ahead_size = srv_log_write_ahead_size;
 +	ulint		pad_size;
  
 -	group = UT_LIST_GET_FIRST(log_sys->log_groups);
 -	group->n_pending_writes++;	/*!< We assume here that we have only
 -					one log group! */
 +	DBUG_PRINT("ib_log", ("write " LSN_PF " to " LSN_PF,
 +			      log_sys->write_lsn,
 +			      log_sys->lsn));
 +	if (flush_to_disk) {
 +		log_sys->n_pending_flushes++;
 +		log_sys->current_flush_lsn = log_sys->lsn;
- 		MONITOR_INC(MONITOR_PENDING_LOG_FLUSH);
 +		os_event_reset(log_sys->flush_event);
  
 -	os_event_reset(log_sys->no_flush_event);
 -	os_event_reset(log_sys->one_flushed_event);
 +		if (log_sys->buf_free == log_sys->buf_next_to_write) {
 +			/* Nothing to write, flush only */
 +			log_mutex_exit_all();
 +			log_write_flush_to_disk_low();
 +			log_mutex_exit();
 +			return;
 +		}
 +	}
  
  	start_offset = log_sys->buf_next_to_write;
  	end_offset = log_sys->buf_free;
diff --cc storage/innobase/srv/srv0mon.cc
index de1c0d27efe,8f5f774df89..ff965989ce4
--- a/storage/innobase/srv/srv0mon.cc
+++ b/storage/innobase/srv/srv0mon.cc
@@@ -921,12 -872,14 +921,14 @@@ static monitor_info_t	innodb_counter_in
  	 MONITOR_EXISTING | MONITOR_DISPLAY_CURRENT),
  	 MONITOR_DEFAULT_START, MONITOR_OVLD_MAX_AGE_SYNC},
  
 -	{"log_pending_log_writes", "recovery", "Pending log writes",
 +	{"log_pending_log_flushes", "recovery", "Pending log flushes",
- 	 MONITOR_NONE,
+ 	 static_cast<monitor_type_t>(
+ 	 MONITOR_EXISTING | MONITOR_DISPLAY_CURRENT),
 -	 MONITOR_DEFAULT_START, MONITOR_PENDING_LOG_WRITE},
 +	 MONITOR_DEFAULT_START, MONITOR_PENDING_LOG_FLUSH},
  
  	{"log_pending_checkpoint_writes", "recovery", "Pending checkpoints",
- 	 MONITOR_NONE,
+ 	 static_cast<monitor_type_t>(
+ 	 MONITOR_EXISTING | MONITOR_DISPLAY_CURRENT),
  	 MONITOR_DEFAULT_START, MONITOR_PENDING_CHECKPOINT_WRITE},
  
  	{"log_num_log_io", "recovery", "Number of log I/Os",
@@@ -2007,6 -1973,25 +2010,25 @@@ srv_mon_process_existing_counter
  		value = (mon_type_t) log_sys->lsn;
  		break;
  
 -	case MONITOR_PENDING_LOG_WRITE:
++	case MONITOR_PENDING_LOG_FLUSH:
+ 		mutex_enter(&log_sys->mutex);
 -		value = static_cast<mon_type_t>(log_sys->n_pending_writes);
++		value = static_cast<mon_type_t>(log_sys->n_pending_flushes);
+ 		mutex_exit(&log_sys->mutex);
+ 		break;
+ 
+ 	case MONITOR_PENDING_CHECKPOINT_WRITE:
+ 		mutex_enter(&log_sys->mutex);
+ 		value = static_cast<mon_type_t>(
+ 		    log_sys->n_pending_checkpoint_writes);
+ 		mutex_exit(&log_sys->mutex);
+ 		break;
+ 
+ 	case MONITOR_LOG_IO:
+ 		mutex_enter(&log_sys->mutex);
+ 		value = static_cast<mon_type_t>(log_sys->n_log_ios);
+ 		mutex_exit(&log_sys->mutex);
+ 		break;
+ 
  	case MONITOR_OVLD_BUF_OLDEST_LSN:
  		value = (mon_type_t) buf_pool_get_oldest_modification();
  		break;


More information about the commits mailing list