Skip to content

Commit

Permalink
Revert "MDEV-8696: Adding indexes on empty table is slow with large i…
Browse files Browse the repository at this point in the history
…nnodb_sort_buffer_size."

This reverts commit 13884cf.

Fixed in 5.6 (merged in the next commit)
  • Loading branch information
vuvova committed Feb 16, 2016
1 parent 271fed4 commit d520d35
Show file tree
Hide file tree
Showing 19 changed files with 42 additions and 297 deletions.
30 changes: 0 additions & 30 deletions mysql-test/suite/innodb/r/innodb-alter-filewrite.result

This file was deleted.

9 changes: 0 additions & 9 deletions mysql-test/suite/innodb/r/innodb_monitor.result
Expand Up @@ -123,9 +123,6 @@ os_log_bytes_written disabled
os_log_fsyncs disabled
os_log_pending_fsyncs disabled
os_log_pending_writes disabled
os_merge_blocks_written disabled
os_merge_blocks_read disabled
os_merge_blocks_merged disabled
trx_rw_commits disabled
trx_ro_commits disabled
trx_nl_ro_commits disabled
Expand Down Expand Up @@ -257,9 +254,6 @@ lock_row_lock_time disabled
lock_row_lock_time_max disabled
lock_row_lock_waits disabled
lock_row_lock_time_avg disabled
os_merge_blocks_written disabled
os_merge_blocks_read disabled
os_merge_blocks_merged disabled
innodb_rwlock_s_spin_waits disabled
innodb_rwlock_x_spin_waits disabled
innodb_rwlock_s_spin_rounds disabled
Expand Down Expand Up @@ -298,9 +292,6 @@ os_log_bytes_written disabled
os_log_fsyncs disabled
os_log_pending_fsyncs enabled
os_log_pending_writes enabled
os_merge_blocks_written disabled
os_merge_blocks_read disabled
os_merge_blocks_merged disabled
set global innodb_monitor_enable="";
ERROR 42000: Variable 'innodb_monitor_enable' can't be set to the value of ''
set global innodb_monitor_enable="_";
Expand Down
32 changes: 0 additions & 32 deletions mysql-test/suite/innodb/t/innodb-alter-filewrite.test

This file was deleted.

Expand Up @@ -123,9 +123,6 @@ os_log_bytes_written disabled
os_log_fsyncs disabled
os_log_pending_fsyncs disabled
os_log_pending_writes disabled
os_merge_blocks_written disabled
os_merge_blocks_read disabled
os_merge_blocks_merged disabled
trx_rw_commits disabled
trx_ro_commits disabled
trx_nl_ro_commits disabled
Expand Down Expand Up @@ -257,9 +254,6 @@ lock_row_lock_time disabled
lock_row_lock_time_max disabled
lock_row_lock_waits disabled
lock_row_lock_time_avg disabled
os_merge_blocks_written disabled
os_merge_blocks_read disabled
os_merge_blocks_merged disabled
innodb_rwlock_s_spin_waits disabled
innodb_rwlock_x_spin_waits disabled
innodb_rwlock_s_spin_rounds disabled
Expand Down Expand Up @@ -298,9 +292,6 @@ os_log_bytes_written disabled
os_log_fsyncs disabled
os_log_pending_fsyncs enabled
os_log_pending_writes enabled
os_merge_blocks_written disabled
os_merge_blocks_read disabled
os_merge_blocks_merged disabled
set global innodb_monitor_enable="";
ERROR 42000: Variable 'innodb_monitor_enable' can't be set to the value of ''
set global innodb_monitor_enable="_";
Expand Down
Expand Up @@ -123,9 +123,6 @@ os_log_bytes_written disabled
os_log_fsyncs disabled
os_log_pending_fsyncs disabled
os_log_pending_writes disabled
os_merge_blocks_written disabled
os_merge_blocks_read disabled
os_merge_blocks_merged disabled
trx_rw_commits disabled
trx_ro_commits disabled
trx_nl_ro_commits disabled
Expand Down Expand Up @@ -257,9 +254,6 @@ lock_row_lock_time disabled
lock_row_lock_time_max disabled
lock_row_lock_waits disabled
lock_row_lock_time_avg disabled
os_merge_blocks_written disabled
os_merge_blocks_read disabled
os_merge_blocks_merged disabled
innodb_rwlock_s_spin_waits disabled
innodb_rwlock_x_spin_waits disabled
innodb_rwlock_s_spin_rounds disabled
Expand Down Expand Up @@ -298,9 +292,6 @@ os_log_bytes_written disabled
os_log_fsyncs disabled
os_log_pending_fsyncs enabled
os_log_pending_writes enabled
os_merge_blocks_written disabled
os_merge_blocks_read disabled
os_merge_blocks_merged disabled
set global innodb_monitor_enable="";
ERROR 42000: Variable 'innodb_monitor_enable' can't be set to the value of ''
set global innodb_monitor_enable="_";
Expand Down
Expand Up @@ -123,9 +123,6 @@ os_log_bytes_written disabled
os_log_fsyncs disabled
os_log_pending_fsyncs disabled
os_log_pending_writes disabled
os_merge_blocks_written disabled
os_merge_blocks_read disabled
os_merge_blocks_merged disabled
trx_rw_commits disabled
trx_ro_commits disabled
trx_nl_ro_commits disabled
Expand Down Expand Up @@ -257,9 +254,6 @@ lock_row_lock_time disabled
lock_row_lock_time_max disabled
lock_row_lock_waits disabled
lock_row_lock_time_avg disabled
os_merge_blocks_written disabled
os_merge_blocks_read disabled
os_merge_blocks_merged disabled
innodb_rwlock_s_spin_waits disabled
innodb_rwlock_x_spin_waits disabled
innodb_rwlock_s_spin_rounds disabled
Expand Down Expand Up @@ -298,9 +292,6 @@ os_log_bytes_written disabled
os_log_fsyncs disabled
os_log_pending_fsyncs enabled
os_log_pending_writes enabled
os_merge_blocks_written disabled
os_merge_blocks_read disabled
os_merge_blocks_merged disabled
set global innodb_monitor_enable="";
ERROR 42000: Variable 'innodb_monitor_enable' can't be set to the value of ''
set global innodb_monitor_enable="_";
Expand Down
9 changes: 0 additions & 9 deletions mysql-test/suite/sys_vars/r/innodb_monitor_reset_basic.result
Expand Up @@ -123,9 +123,6 @@ os_log_bytes_written disabled
os_log_fsyncs disabled
os_log_pending_fsyncs disabled
os_log_pending_writes disabled
os_merge_blocks_written disabled
os_merge_blocks_read disabled
os_merge_blocks_merged disabled
trx_rw_commits disabled
trx_ro_commits disabled
trx_nl_ro_commits disabled
Expand Down Expand Up @@ -257,9 +254,6 @@ lock_row_lock_time disabled
lock_row_lock_time_max disabled
lock_row_lock_waits disabled
lock_row_lock_time_avg disabled
os_merge_blocks_written disabled
os_merge_blocks_read disabled
os_merge_blocks_merged disabled
innodb_rwlock_s_spin_waits disabled
innodb_rwlock_x_spin_waits disabled
innodb_rwlock_s_spin_rounds disabled
Expand Down Expand Up @@ -298,9 +292,6 @@ os_log_bytes_written disabled
os_log_fsyncs disabled
os_log_pending_fsyncs enabled
os_log_pending_writes enabled
os_merge_blocks_written disabled
os_merge_blocks_read disabled
os_merge_blocks_merged disabled
set global innodb_monitor_enable="";
ERROR 42000: Variable 'innodb_monitor_enable' can't be set to the value of ''
set global innodb_monitor_enable="_";
Expand Down
8 changes: 1 addition & 7 deletions storage/innobase/handler/ha_innodb.cc
Expand Up @@ -4,7 +4,7 @@ Copyright (c) 2000, 2015, Oracle and/or its affiliates. All Rights Reserved.
Copyright (c) 2008, 2009 Google Inc.
Copyright (c) 2009, Percona Inc.
Copyright (c) 2012, Facebook Inc.
Copyright (c) 2013, 2015, MariaDB Corporation.
Copyright (c) 2013, 2014 SkySQL Ab. All Rights Reserved.

Portions of this file contain modifications contributed and copyrighted by
Google, Inc. Those modifications are gratefully acknowledged and are described
Expand Down Expand Up @@ -647,12 +647,6 @@ static SHOW_VAR innodb_status_variables[]= {
(char*) &export_vars.innodb_os_log_pending_writes, SHOW_LONG},
{"os_log_written",
(char*) &export_vars.innodb_os_log_written, SHOW_LONGLONG},
{"os_merge_buffers_written",
(char*) &export_vars.innodb_merge_buffers_written, SHOW_LONGLONG},
{"os_merge_buffers_read",
(char*) &export_vars.innodb_merge_buffers_read, SHOW_LONGLONG},
{"os_merge_buffers_merged",
(char*) &export_vars.innodb_merge_buffers_merged, SHOW_LONGLONG},
{"page_size",
(char*) &export_vars.innodb_page_size, SHOW_LONG},
{"pages_created",
Expand Down
4 changes: 0 additions & 4 deletions storage/innobase/include/srv0mon.h
Expand Up @@ -2,7 +2,6 @@
Copyright (c) 2010, 2013, Oracle and/or its affiliates. All Rights Reserved.
Copyright (c) 2012, Facebook Inc.
Copyright (c) 2014, 2015, MariaDB Corporation.
This program is free software; you can redistribute it and/or modify it
under the terms of the GNU General Public License as published by the
Expand Down Expand Up @@ -256,9 +255,6 @@ enum monitor_id_t {
MONITOR_OVLD_OS_LOG_FSYNC,
MONITOR_OVLD_OS_LOG_PENDING_FSYNC,
MONITOR_OVLD_OS_LOG_PENDING_WRITES,
MONITOR_MERGE_BLOCKS_WRITTEN,
MONITOR_MERGE_BLOCKS_READ,
MONITOR_MERGE_BLOCKS_MERGED,

/* Transaction related counters */
MONITOR_MODULE_TRX,
Expand Down
14 changes: 1 addition & 13 deletions storage/innobase/include/srv0srv.h
Expand Up @@ -3,7 +3,7 @@
Copyright (c) 1995, 2015, Oracle and/or its affiliates. All rights reserved.
Copyright (c) 2008, 2009, Google Inc.
Copyright (c) 2009, Percona Inc.
Copyright (c) 2013, 2015, MariaDB Corporation.
Copyright (c) 2013, 2014, SkySQL Ab. All Rights Reserved.
Portions of this file contain modifications contributed and copyrighted by
Google, Inc. Those modifications are gratefully acknowledged and are described
Expand Down Expand Up @@ -138,15 +138,6 @@ struct srv_stats_t {

/** Number of system rows inserted */
ulint_ctr_64_t n_system_rows_inserted;

/** Number of merge buffers written */
ulint_ctr_64_t merge_buffers_written;

/** Number of merge buffers read */
ulint_ctr_64_t merge_buffers_read;

/** Number of merge buffers merged */
ulint_ctr_64_t merge_buffers_merged;
};

extern const char* srv_main_thread_op_info;
Expand Down Expand Up @@ -886,9 +877,6 @@ struct export_var_t{
ulint innodb_purge_view_trx_id_age; /*!< rw_max_trx_id
- purged view's min trx_id */
#endif /* UNIV_DEBUG */
ib_int64_t innodb_merge_buffers_written;
ib_int64_t innodb_merge_buffers_read;
ib_int64_t innodb_merge_buffers_merged;
};

/** Thread slot in the thread table. */
Expand Down
51 changes: 18 additions & 33 deletions storage/innobase/row/row0merge.cc
@@ -1,7 +1,6 @@
/*****************************************************************************
Copyright (c) 2005, 2015, Oracle and/or its affiliates. All Rights Reserved.
Copyright (c) 2014, 2015, MariaDB Corporation.
This program is free software; you can redistribute it and/or modify it under
the terms of the GNU General Public License as published by the Free Software
Expand Down Expand Up @@ -872,8 +871,6 @@ row_merge_read(

success = os_file_read_no_error_handling(OS_FILE_FROM_FD(fd), buf,
ofs, srv_sort_buf_size);
srv_stats.merge_buffers_read.inc();

#ifdef POSIX_FADV_DONTNEED
/* Each block is read exactly once. Free up the file cache. */
posix_fadvise(fd, ofs, srv_sort_buf_size, POSIX_FADV_DONTNEED);
Expand Down Expand Up @@ -908,7 +905,6 @@ row_merge_write(
DBUG_EXECUTE_IF("row_merge_write_failure", return(FALSE););

ret = os_file_write("(merge)", OS_FILE_FROM_FD(fd), buf, ofs, buf_len);
srv_stats.merge_buffers_written.inc();

#ifdef UNIV_DEBUG
if (row_merge_print_block_write) {
Expand Down Expand Up @@ -1740,7 +1736,7 @@ row_merge_read_clustered_index(
/* We have enough data tuples to form a block.
Sort them and write to disk. */

if (UNIV_LIKELY(buf->n_tuples)) {
if (buf->n_tuples) {
if (dict_index_is_unique(buf->index)) {
row_merge_dup_t dup = {
buf->index, table, col_map, 0};
Expand Down Expand Up @@ -1781,17 +1777,13 @@ row_merge_read_clustered_index(
dict_index_get_lock(buf->index));
}

/* Do not write empty buffers to temporary file */
if (buf->n_tuples) {

row_merge_buf_write(buf, file, block);
row_merge_buf_write(buf, file, block);

if (!row_merge_write(file->fd, file->offset++,
block)) {
err = DB_TEMP_FILE_WRITE_FAILURE;
trx->error_key_num = i;
break;
}
if (!row_merge_write(file->fd, file->offset++,
block)) {
err = DB_TEMP_FILE_WRITE_FAILURE;
trx->error_key_num = i;
break;
}

UNIV_MEM_INVALID(&block[0], srv_sort_buf_size);
Expand Down Expand Up @@ -2076,9 +2068,6 @@ row_merge_blocks(
mem_heap_free(heap);
b2 = row_merge_write_eof(&block[2 * srv_sort_buf_size],
b2, of->fd, &of->offset);

srv_stats.merge_buffers_merged.inc();

return(b2 ? DB_SUCCESS : DB_CORRUPTION);
}

Expand Down Expand Up @@ -3763,21 +3752,17 @@ row_merge_build_indexes(
DEBUG_FTS_SORT_PRINT("FTS_SORT: Complete Insert\n");
#endif
} else {
/* Sorting and inserting is required only if
there really is records */
if (UNIV_LIKELY(merge_files[i].n_rec)) {
row_merge_dup_t dup = {
sort_idx, table, col_map, 0};

error = row_merge_sort(
trx, &dup, &merge_files[i],
block, &tmpfd);

if (error == DB_SUCCESS) {
error = row_merge_insert_index_tuples(
trx->id, sort_idx, old_table,
merge_files[i].fd, block);
}
row_merge_dup_t dup = {
sort_idx, table, col_map, 0};

error = row_merge_sort(
trx, &dup, &merge_files[i],
block, &tmpfd);

if (error == DB_SUCCESS) {
error = row_merge_insert_index_tuples(
trx->id, sort_idx, old_table,
merge_files[i].fd, block);
}
}

Expand Down

0 comments on commit d520d35

Please sign in to comment.