Skip to content

Commit e0e8057

Browse files
committed
Merge 10.2 into 10.3
2 parents fde29f3 + 56976e6 commit e0e8057

File tree

2 files changed

+25
-87
lines changed

2 files changed

+25
-87
lines changed

storage/innobase/include/log0log.h

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -527,7 +527,7 @@ struct log_t{
527527
to the first half before freeing/resizing
528528
must be undertaken. */
529529
boolfirst_in_use;/*!< true if buf points to the first
530-
half of the aligned(buf_ptr), false
530+
half of the buffer, false
531531
if the second half */
532532
ulong max_buf_free;/*!< recommended maximum value of
533533
buf_free for the buffer in use, after
@@ -611,8 +611,6 @@ struct log_t{
611611
later; this is advanced when a flush
612612
operation is completed to all the log
613613
groups */
614-
volatile boolis_extending;/*!< this is set to true during extend
615-
the log buffer size */
616614
lsn_twrite_lsn;/*!< last written lsn */
617615
lsn_tcurrent_flush_lsn;/*!< end lsn for the current running
618616
write + flush operation */

storage/innobase/log/log0log.cc

Lines changed: 24 additions & 84 deletions
Original file line numberDiff line numberDiff line change
@@ -161,87 +161,42 @@ log_buf_pool_get_oldest_modification(void)
161161
@param[in] len requested minimum size in bytes */
162162
void log_buffer_extend(ulong len)
163163
{
164-
byte tmp_buf[OS_FILE_LOG_BLOCK_SIZE];
164+
const ulong new_buf_size = ut_calc_align(len, srv_page_size);
165+
byte* new_buf = static_cast<byte*>(
166+
ut_malloc_dontdump(new_buf_size * 2));
167+
TRASH_ALLOC(new_buf, new_buf_size * 2);
165168

166-
log_mutex_enter_all();
167-
168-
while (log_sys.is_extending) {
169-
/* Another thread is trying to extend already.
170-
Needs to wait for. */
171-
log_mutex_exit_all();
172-
173-
log_buffer_flush_to_disk();
174-
175-
log_mutex_enter_all();
176-
177-
if (srv_log_buffer_size > len) {
178-
/* Already extended enough by the others */
179-
log_mutex_exit_all();
180-
return;
181-
}
182-
}
183-
184-
if (len >= srv_log_buffer_size / 2) {
185-
DBUG_EXECUTE_IF("ib_log_buffer_is_short_crash",
186-
DBUG_SUICIDE(););
187-
188-
/* log_buffer is too small. try to extend instead of crash. */
189-
ib::warn() << "The redo log transaction size " << len <<
190-
" exceeds innodb_log_buffer_size="
191-
<< srv_log_buffer_size << " / 2). Trying to extend it.";
192-
}
193-
194-
log_sys.is_extending = true;
195-
196-
while ((log_sys.buf_free ^ log_sys.buf_next_to_write)
197-
& (OS_FILE_LOG_BLOCK_SIZE - 1)) {
198-
/* Buffer might have >1 blocks to write still. */
199-
log_mutex_exit_all();
200-
201-
log_buffer_flush_to_disk();
202-
203-
log_mutex_enter_all();
204-
}
205-
206-
ulong move_start = ut_2pow_round(log_sys.buf_free,
207-
ulong(OS_FILE_LOG_BLOCK_SIZE));
208-
ulong move_end = log_sys.buf_free;
209-
210-
/* store the last log block in buffer */
211-
ut_memcpy(tmp_buf, log_sys.buf + move_start,
212-
move_end - move_start);
213-
214-
log_sys.buf_free -= move_start;
215-
log_sys.buf_next_to_write -= move_start;
169+
log_mutex_enter();
216170

217-
/* free previous after getting the right address */
218-
if (!log_sys.first_in_use) {
219-
log_sys.buf -= srv_log_buffer_size;
171+
if (len <= srv_log_buffer_size) {
172+
/* Already extended enough by the others */
173+
log_mutex_exit();
174+
ut_free_dodump(new_buf, new_buf_size * 2);
175+
return;
220176
}
221-
ut_free_dodump(log_sys.buf, srv_log_buffer_size * 2);
222-
223-
/* reallocate log buffer */
224-
srv_log_buffer_size = len;
225177

226-
log_sys.buf = static_cast<byte*>(
227-
ut_malloc_dontdump(srv_log_buffer_size * 2));
228-
TRASH_ALLOC(log_sys.buf, srv_log_buffer_size * 2);
178+
ib::warn() << "The redo log transaction size " << len <<
179+
" exceeds innodb_log_buffer_size="
180+
<< srv_log_buffer_size << " / 2). Trying to extend it.";
229181

182+
const byte* old_buf_begin = log_sys.buf;
183+
const ulong old_buf_size = srv_log_buffer_size;
184+
byte* old_buf = log_sys.first_in_use
185+
? log_sys.buf : log_sys.buf - old_buf_size;
186+
srv_log_buffer_size = new_buf_size;
187+
log_sys.buf = new_buf;
230188
log_sys.first_in_use = true;
189+
memcpy(log_sys.buf, old_buf_begin, log_sys.buf_free);
231190

232-
log_sys.max_buf_free = srv_log_buffer_size / LOG_BUF_FLUSH_RATIO
191+
log_sys.max_buf_free = new_buf_size / LOG_BUF_FLUSH_RATIO
233192
- LOG_BUF_FLUSH_MARGIN;
234193

235-
/* restore the last log block */
236-
ut_memcpy(log_sys.buf, tmp_buf, move_end - move_start);
237-
238-
ut_ad(log_sys.is_extending);
239-
log_sys.is_extending = false;
194+
log_mutex_exit();
240195

241-
log_mutex_exit_all();
196+
ut_free_dodump(old_buf, old_buf_size);
242197

243198
ib::info() << "innodb_log_buffer_size was extended to "
244-
<< srv_log_buffer_size << ".";
199+
<< new_buf_size << ".";
245200
}
246201

247202
/** Calculate actual length in redo buffer and file including
@@ -350,20 +305,6 @@ log_reserve_and_open(
350305
loop:
351306
ut_ad(log_mutex_own());
352307

353-
if (log_sys.is_extending) {
354-
log_mutex_exit();
355-
356-
/* Log buffer size is extending. Writing up to the next block
357-
should wait for the extending finished. */
358-
359-
os_thread_sleep(100000);
360-
361-
ut_ad(++count < 50);
362-
363-
log_mutex_enter();
364-
goto loop;
365-
}
366-
367308
/* Calculate an upper limit for the space the string may take in the
368309
log buffer */
369310

@@ -619,7 +560,6 @@ void log_t::create()
619560
last_printout_time= time(NULL);
620561

621562
buf_next_to_write= 0;
622-
is_extending= false;
623563
write_lsn= lsn;
624564
flushed_to_disk_lsn= 0;
625565
n_pending_flushes= 0;

0 commit comments

Comments
 (0)