Commit e0e80575 authored by Marko Mäkelä's avatar Marko Mäkelä

Merge 10.2 into 10.3

parents fde29f3a 56976e60
...@@ -527,7 +527,7 @@ struct log_t{ ...@@ -527,7 +527,7 @@ struct log_t{
to the first half before freeing/resizing to the first half before freeing/resizing
must be undertaken. */ must be undertaken. */
bool first_in_use; /*!< true if buf points to the first bool first_in_use; /*!< true if buf points to the first
half of the aligned(buf_ptr), false half of the buffer, false
if the second half */ if the second half */
ulong max_buf_free; /*!< recommended maximum value of ulong max_buf_free; /*!< recommended maximum value of
buf_free for the buffer in use, after buf_free for the buffer in use, after
...@@ -611,8 +611,6 @@ struct log_t{ ...@@ -611,8 +611,6 @@ struct log_t{
later; this is advanced when a flush later; this is advanced when a flush
operation is completed to all the log operation is completed to all the log
groups */ groups */
volatile bool is_extending; /*!< this is set to true during extend
the log buffer size */
lsn_t write_lsn; /*!< last written lsn */ lsn_t write_lsn; /*!< last written lsn */
lsn_t current_flush_lsn;/*!< end lsn for the current running lsn_t current_flush_lsn;/*!< end lsn for the current running
write + flush operation */ write + flush operation */
......
...@@ -161,87 +161,42 @@ log_buf_pool_get_oldest_modification(void) ...@@ -161,87 +161,42 @@ log_buf_pool_get_oldest_modification(void)
@param[in] len requested minimum size in bytes */ @param[in] len requested minimum size in bytes */
void log_buffer_extend(ulong len) void log_buffer_extend(ulong len)
{ {
byte tmp_buf[OS_FILE_LOG_BLOCK_SIZE]; const ulong new_buf_size = ut_calc_align(len, srv_page_size);
byte* new_buf = static_cast<byte*>(
ut_malloc_dontdump(new_buf_size * 2));
TRASH_ALLOC(new_buf, new_buf_size * 2);
log_mutex_enter_all(); log_mutex_enter();
while (log_sys.is_extending) {
/* Another thread is trying to extend already.
Needs to wait for. */
log_mutex_exit_all();
log_buffer_flush_to_disk();
log_mutex_enter_all();
if (srv_log_buffer_size > len) {
/* Already extended enough by the others */
log_mutex_exit_all();
return;
}
}
if (len >= srv_log_buffer_size / 2) {
DBUG_EXECUTE_IF("ib_log_buffer_is_short_crash",
DBUG_SUICIDE(););
/* log_buffer is too small. try to extend instead of crash. */
ib::warn() << "The redo log transaction size " << len <<
" exceeds innodb_log_buffer_size="
<< srv_log_buffer_size << " / 2). Trying to extend it.";
}
log_sys.is_extending = true;
while ((log_sys.buf_free ^ log_sys.buf_next_to_write)
& (OS_FILE_LOG_BLOCK_SIZE - 1)) {
/* Buffer might have >1 blocks to write still. */
log_mutex_exit_all();
log_buffer_flush_to_disk();
log_mutex_enter_all();
}
ulong move_start = ut_2pow_round(log_sys.buf_free,
ulong(OS_FILE_LOG_BLOCK_SIZE));
ulong move_end = log_sys.buf_free;
/* store the last log block in buffer */
ut_memcpy(tmp_buf, log_sys.buf + move_start,
move_end - move_start);
log_sys.buf_free -= move_start;
log_sys.buf_next_to_write -= move_start;
/* free previous after getting the right address */ if (len <= srv_log_buffer_size) {
if (!log_sys.first_in_use) { /* Already extended enough by the others */
log_sys.buf -= srv_log_buffer_size; log_mutex_exit();
ut_free_dodump(new_buf, new_buf_size * 2);
return;
} }
ut_free_dodump(log_sys.buf, srv_log_buffer_size * 2);
/* reallocate log buffer */
srv_log_buffer_size = len;
log_sys.buf = static_cast<byte*>( ib::warn() << "The redo log transaction size " << len <<
ut_malloc_dontdump(srv_log_buffer_size * 2)); " exceeds innodb_log_buffer_size="
TRASH_ALLOC(log_sys.buf, srv_log_buffer_size * 2); << srv_log_buffer_size << " / 2). Trying to extend it.";
const byte* old_buf_begin = log_sys.buf;
const ulong old_buf_size = srv_log_buffer_size;
byte* old_buf = log_sys.first_in_use
? log_sys.buf : log_sys.buf - old_buf_size;
srv_log_buffer_size = new_buf_size;
log_sys.buf = new_buf;
log_sys.first_in_use = true; log_sys.first_in_use = true;
memcpy(log_sys.buf, old_buf_begin, log_sys.buf_free);
log_sys.max_buf_free = srv_log_buffer_size / LOG_BUF_FLUSH_RATIO log_sys.max_buf_free = new_buf_size / LOG_BUF_FLUSH_RATIO
- LOG_BUF_FLUSH_MARGIN; - LOG_BUF_FLUSH_MARGIN;
/* restore the last log block */ log_mutex_exit();
ut_memcpy(log_sys.buf, tmp_buf, move_end - move_start);
ut_ad(log_sys.is_extending);
log_sys.is_extending = false;
log_mutex_exit_all(); ut_free_dodump(old_buf, old_buf_size);
ib::info() << "innodb_log_buffer_size was extended to " ib::info() << "innodb_log_buffer_size was extended to "
<< srv_log_buffer_size << "."; << new_buf_size << ".";
} }
/** Calculate actual length in redo buffer and file including /** Calculate actual length in redo buffer and file including
...@@ -350,20 +305,6 @@ log_reserve_and_open( ...@@ -350,20 +305,6 @@ log_reserve_and_open(
loop: loop:
ut_ad(log_mutex_own()); ut_ad(log_mutex_own());
if (log_sys.is_extending) {
log_mutex_exit();
/* Log buffer size is extending. Writing up to the next block
should wait for the extending finished. */
os_thread_sleep(100000);
ut_ad(++count < 50);
log_mutex_enter();
goto loop;
}
/* Calculate an upper limit for the space the string may take in the /* Calculate an upper limit for the space the string may take in the
log buffer */ log buffer */
...@@ -619,7 +560,6 @@ void log_t::create() ...@@ -619,7 +560,6 @@ void log_t::create()
last_printout_time= time(NULL); last_printout_time= time(NULL);
buf_next_to_write= 0; buf_next_to_write= 0;
is_extending= false;
write_lsn= lsn; write_lsn= lsn;
flushed_to_disk_lsn= 0; flushed_to_disk_lsn= 0;
n_pending_flushes= 0; n_pending_flushes= 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