trx0trx.c:

  Fix bug: group commit still did not work when we had MySQL binlogging on
parent 16bf8d7a
...@@ -778,29 +778,53 @@ trx_commit_off_kernel( ...@@ -778,29 +778,53 @@ trx_commit_off_kernel(
efficient here: call os_thread_yield here to allow also other efficient here: call os_thread_yield here to allow also other
trxs to come to commit! */ trxs to come to commit! */
/* We now flush the log, as the transaction made changes to
the database, making the transaction committed on disk. It is
enough that any one of the log groups gets written to disk. */
/*-------------------------------------*/ /*-------------------------------------*/
/* Most MySQL users run with srv_flush_.. set to 0: */ /* Depending on the my.cnf options, we may now write the log
buffer to the log files, making the transaction durable if
if (srv_flush_log_at_trx_commit != 0) { the OS does not crash. We may also flush the log files to
if (srv_unix_file_flush_method != SRV_UNIX_NOSYNC disk, making the transaction durable also at an OS crash or a
&& srv_flush_log_at_trx_commit != 2 power outage.
&& !trx->flush_log_later) {
The idea in InnoDB's group commit is that a group of
/* Write the log to the log files AND flush transactions gather behind a trx doing a physical disk write
them to disk */ to log files, and when that physical write has been completed,
one of those transactions does a write which commits the whole
log_write_up_to(lsn, LOG_WAIT_ONE_GROUP, TRUE); group. Note that this group commit will only bring benefit if
} else { there are > 2 users in the database. Then at least 2 users can
/* Write the log but do not flush it to disk */ gather behind one doing the physical log write to disk.
log_write_up_to(lsn, LOG_WAIT_ONE_GROUP, FALSE); If we are calling trx_commit() under MySQL's binlog mutex, we
} will delay possible log write and flush to a separate function
} trx_commit_complete_for_mysql(), which is only called when the
thread has released the binlog mutex. This is to make the
group commit algorithm to work. Otherwise, the MySQL binlog
mutex would serialize all commits and prevent a group of
transactions from gathering. */
if (trx->flush_log_later) {
/* Do nothing yet */
} else if (srv_flush_log_at_trx_commit == 0) {
/* Do nothing */
} else if (srv_flush_log_at_trx_commit == 1) {
if (srv_unix_file_flush_method == SRV_UNIX_NOSYNC) {
/* Write the log but do not flush it to disk */
log_write_up_to(lsn, LOG_WAIT_ONE_GROUP, FALSE);
} else {
/* Write the log to the log files AND flush
them to disk */
log_write_up_to(lsn, LOG_WAIT_ONE_GROUP, TRUE);
}
} else if (srv_flush_log_at_trx_commit == 2) {
/* Write the log but do not flush it to disk */
log_write_up_to(lsn, LOG_WAIT_ONE_GROUP, FALSE);
} else {
ut_a(0);
}
trx->commit_lsn = lsn; trx->commit_lsn = lsn;
...@@ -1497,21 +1521,33 @@ trx_commit_complete_for_mysql( ...@@ -1497,21 +1521,33 @@ trx_commit_complete_for_mysql(
/* out: 0 or error number */ /* out: 0 or error number */
trx_t* trx) /* in: trx handle */ trx_t* trx) /* in: trx handle */
{ {
ut_a(trx); dulint lsn = trx->commit_lsn;
if (srv_flush_log_at_trx_commit == 1 ut_a(trx);
&& srv_unix_file_flush_method != SRV_UNIX_NOSYNC) {
trx->op_info = (char *) "flushing log";
/* Flush the log files to disk */ if (srv_flush_log_at_trx_commit == 0) {
/* Do nothing */
} else if (srv_flush_log_at_trx_commit == 1) {
if (srv_unix_file_flush_method == SRV_UNIX_NOSYNC) {
/* Write the log but do not flush it to disk */
log_write_up_to(trx->commit_lsn, LOG_WAIT_ONE_GROUP, TRUE); log_write_up_to(lsn, LOG_WAIT_ONE_GROUP, FALSE);
} else {
/* Write the log to the log files AND flush them to
disk */
trx->op_info = (char *) ""; log_write_up_to(lsn, LOG_WAIT_ONE_GROUP, TRUE);
} }
} else if (srv_flush_log_at_trx_commit == 2) {
return(0); /* Write the log but do not flush it to disk */
log_write_up_to(lsn, LOG_WAIT_ONE_GROUP, FALSE);
} else {
ut_a(0);
}
return(0);
} }
/************************************************************************** /**************************************************************************
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment