Commit bc9f6021 authored by unknown's avatar unknown

MWL#116: After-review fixes.

parent a2d921be
...@@ -554,6 +554,8 @@ typedef int (*qsort2_cmp)(const void *, const void *, const void *); ...@@ -554,6 +554,8 @@ typedef int (*qsort2_cmp)(const void *, const void *, const void *);
#define my_b_tell(info) ((info)->pos_in_file + \ #define my_b_tell(info) ((info)->pos_in_file + \
(size_t) (*(info)->current_pos - (info)->request_pos)) (size_t) (*(info)->current_pos - (info)->request_pos))
#define my_b_write_tell(info) ((info)->pos_in_file + \
((info)->write_pos - (info)->write_buffer))
#define my_b_get_buffer_start(info) (info)->request_pos #define my_b_get_buffer_start(info) (info)->request_pos
#define my_b_get_bytes_in_buffer(info) (char*) (info)->read_end - \ #define my_b_get_bytes_in_buffer(info) (char*) (info)->read_end - \
......
CREATE TABLE t1 (a INT PRIMARY KEY) ENGINE=InnoDB;
SET binlog_format= mixed;
RESET MASTER;
XA START 'xatest';
INSERT INTO t1 VALUES (1);
XA END 'xatest';
XA PREPARE 'xatest';
XA COMMIT 'xatest';
XA START 'xatest';
INSERT INTO t1 VALUES (2);
XA END 'xatest';
XA COMMIT 'xatest' ONE PHASE;
BEGIN;
INSERT INTO t1 VALUES (3);
COMMIT;
SELECT * FROM t1 ORDER BY a;
a
1
2
3
SHOW BINLOG EVENTS LIMIT 1,9;
Log_name Pos Event_type Server_id End_log_pos Info
master-bin.000001 # Query 1 # BEGIN
master-bin.000001 # Query 1 # use `test`; INSERT INTO t1 VALUES (1)
master-bin.000001 # Query 1 # COMMIT
master-bin.000001 # Query 1 # BEGIN
master-bin.000001 # Query 1 # use `test`; INSERT INTO t1 VALUES (2)
master-bin.000001 # Query 1 # COMMIT
master-bin.000001 # Query 1 # BEGIN
master-bin.000001 # Query 1 # use `test`; INSERT INTO t1 VALUES (3)
master-bin.000001 # Xid 1 # COMMIT /* xid=XX */
DROP TABLE t1;
...@@ -21,7 +21,8 @@ SELECT * FROM t1; ...@@ -21,7 +21,8 @@ SELECT * FROM t1;
# Actually the output from this currently shows a bug. # Actually the output from this currently shows a bug.
# The injected IO error leaves partially written transactions in the binlog in # The injected IO error leaves partially written transactions in the binlog in
# the form of stray "BEGIN" events. # the form of stray "BEGIN" events.
# These should disappear from the output if binlog error handling is improved. # These should disappear from the output if binlog error handling is improved
# (see MySQL Bug#37148 and WL#1790).
--replace_regex /\/\* xid=.* \*\//\/* XID *\// /Server ver: .*, Binlog ver: .*/Server ver: #, Binlog ver: #/ /table_id: [0-9]+/table_id: #/ --replace_regex /\/\* xid=.* \*\//\/* XID *\// /Server ver: .*, Binlog ver: .*/Server ver: #, Binlog ver: #/ /table_id: [0-9]+/table_id: #/
--replace_column 1 BINLOG 2 POS 5 ENDPOS --replace_column 1 BINLOG 2 POS 5 ENDPOS
SHOW BINLOG EVENTS; SHOW BINLOG EVENTS;
......
...@@ -16,6 +16,7 @@ select * from t2; ...@@ -16,6 +16,7 @@ select * from t2;
b b
2 2
SET sql_log_bin = 0; SET sql_log_bin = 0;
BEGIN;
INSERT INTO t1 VALUES (3); INSERT INTO t1 VALUES (3);
INSERT INTO t2 VALUES (4); INSERT INTO t2 VALUES (4);
COMMIT; COMMIT;
......
...@@ -20,6 +20,7 @@ select * from t2; ...@@ -20,6 +20,7 @@ select * from t2;
# Test 2-phase commit when we disable binlogging. # Test 2-phase commit when we disable binlogging.
SET sql_log_bin = 0; SET sql_log_bin = 0;
BEGIN;
INSERT INTO t1 VALUES (3); INSERT INTO t1 VALUES (3);
INSERT INTO t2 VALUES (4); INSERT INTO t2 VALUES (4);
COMMIT; COMMIT;
......
...@@ -8,6 +8,10 @@ ...@@ -8,6 +8,10 @@
# Don't test this under valgrind, memory leaks will occur as we crash # Don't test this under valgrind, memory leaks will occur as we crash
--source include/not_valgrind.inc --source include/not_valgrind.inc
# The test case currently uses grep and tail, which may be unavailable on
# some windows systems. But see MWL#191 for how to remove the need for grep.
--source include/not_windows.inc
# XtraDB stores the binlog position corresponding to the last commit, and # XtraDB stores the binlog position corresponding to the last commit, and
# prints it during crash recovery. # prints it during crash recovery.
# Test that we get the correct position when we group commit several # Test that we get the correct position when we group commit several
......
--source include/have_innodb.inc
--source include/have_log_bin.inc
CREATE TABLE t1 (a INT PRIMARY KEY) ENGINE=InnoDB;
# Fix binlog format (otherwise SHOW BINLOG EVENTS will fluctuate).
SET binlog_format= mixed;
RESET MASTER;
XA START 'xatest';
INSERT INTO t1 VALUES (1);
XA END 'xatest';
XA PREPARE 'xatest';
XA COMMIT 'xatest';
XA START 'xatest';
INSERT INTO t1 VALUES (2);
XA END 'xatest';
XA COMMIT 'xatest' ONE PHASE;
BEGIN;
INSERT INTO t1 VALUES (3);
COMMIT;
SELECT * FROM t1 ORDER BY a;
--replace_column 2 # 5 #
--replace_regex /xid=[0-9]+/xid=XX/
SHOW BINLOG EVENTS LIMIT 1,9;
DROP TABLE t1;
...@@ -1186,17 +1186,16 @@ int ha_commit_trans(THD *thd, bool all) ...@@ -1186,17 +1186,16 @@ int ha_commit_trans(THD *thd, bool all)
Sic: we know that prepare() is not NULL since otherwise Sic: we know that prepare() is not NULL since otherwise
trans->no_2pc would have been set. trans->no_2pc would have been set.
*/ */
if ((err= ht->prepare(ht, thd, all))) err= ht->prepare(ht, thd, all);
my_error(ER_ERROR_DURING_COMMIT, MYF(0), err);
status_var_increment(thd->status_var.ha_prepare_count); status_var_increment(thd->status_var.ha_prepare_count);
if (err)
my_error(ER_ERROR_DURING_COMMIT, MYF(0), err);
if (err) if (err)
goto err; goto err;
if (ht->prepare_ordered) need_prepare_ordered|= (ht->prepare_ordered != NULL);
need_prepare_ordered= TRUE; need_commit_ordered|= (ht->commit_ordered != NULL);
if (ht->commit_ordered)
need_commit_ordered= TRUE;
} }
DBUG_EXECUTE_IF("crash_commit_after_prepare", DBUG_ABORT();); DBUG_EXECUTE_IF("crash_commit_after_prepare", DBUG_ABORT(););
...@@ -1225,8 +1224,7 @@ int ha_commit_trans(THD *thd, bool all) ...@@ -1225,8 +1224,7 @@ int ha_commit_trans(THD *thd, bool all)
/* Come here if error and we need to rollback. */ /* Come here if error and we need to rollback. */
err: err:
if (!error) error= 1; /* Transaction was rolled back */
error= 1;
ha_rollback_trans(thd, all); ha_rollback_trans(thd, all);
end: end:
...@@ -1877,8 +1875,11 @@ int ha_start_consistent_snapshot(THD *thd) ...@@ -1877,8 +1875,11 @@ int ha_start_consistent_snapshot(THD *thd)
bool warn= true; bool warn= true;
/* /*
Holding the LOCK_commit_ordered mutex ensures that for any transaction Holding the LOCK_commit_ordered mutex ensures that we get the same
we either see it committed in all engines, or in none. snapshot for all engines (including the binary log). This allows us
among other things to do backups with
START TRANSACTION WITH CONSISTENT SNAPSHOT and
have a consistent binlog position.
*/ */
pthread_mutex_lock(&LOCK_commit_ordered); pthread_mutex_lock(&LOCK_commit_ordered);
plugin_foreach(thd, snapshot_handlerton, MYSQL_STORAGE_ENGINE_PLUGIN, &warn); plugin_foreach(thd, snapshot_handlerton, MYSQL_STORAGE_ENGINE_PLUGIN, &warn);
......
...@@ -670,7 +670,7 @@ struct handlerton ...@@ -670,7 +670,7 @@ struct handlerton
Not that like prepare(), commit_ordered() is only called when 2-phase Not that like prepare(), commit_ordered() is only called when 2-phase
commit takes place. Ie. when no binary log and only a single engine commit takes place. Ie. when no binary log and only a single engine
participates in a transaction, one commit() is called, no participates in a transaction, one commit() is called, no
commit_orderd(). So engines must be prepared for this. commit_ordered(). So engines must be prepared for this.
The calls to commit_ordered() in multiple parallel transactions is The calls to commit_ordered() in multiple parallel transactions is
guaranteed to happen in the same order in every participating guaranteed to happen in the same order in every participating
...@@ -683,7 +683,7 @@ struct handlerton ...@@ -683,7 +683,7 @@ struct handlerton
transaction visible to other transactions, thereby making the order of transaction visible to other transactions, thereby making the order of
transaction commits be defined by the order of commit_ordered() calls. transaction commits be defined by the order of commit_ordered() calls.
The intension is that commit_ordered() should do the minimal amount of The intention is that commit_ordered() should do the minimal amount of
work that needs to happen in consistent commit order among handlers. To work that needs to happen in consistent commit order among handlers. To
preserve ordering, calls need to be serialised on a global mutex, so preserve ordering, calls need to be serialised on a global mutex, so
doing any time-consuming or blocking operations in commit_ordered() will doing any time-consuming or blocking operations in commit_ordered() will
...@@ -727,7 +727,7 @@ struct handlerton ...@@ -727,7 +727,7 @@ struct handlerton
order transactions will be eventually committed. order transactions will be eventually committed.
Like commit_ordered(), prepare_ordered() calls are serialised to maintain Like commit_ordered(), prepare_ordered() calls are serialised to maintain
ordering, so the intension is that they should execute fast, with only ordering, so the intention is that they should execute fast, with only
the minimal amount of work needed to define commit order. Handlers can the minimal amount of work needed to define commit order. Handlers can
rely on this serialisation, and do not need to do any extra locking to rely on this serialisation, and do not need to do any extra locking to
avoid two prepare_ordered() calls running in parallel. avoid two prepare_ordered() calls running in parallel.
...@@ -747,8 +747,7 @@ struct handlerton ...@@ -747,8 +747,7 @@ struct handlerton
require blocking all other commits for an indefinite time). require blocking all other commits for an indefinite time).
When 2-phase commit is not used (eg. only one engine (and no binlog) in When 2-phase commit is not used (eg. only one engine (and no binlog) in
transaction), prepare() is not called and in such cases prepare_ordered() transaction), neither prepare() nor prepare_ordered() is called.
also is not called.
*/ */
void (*prepare_ordered)(handlerton *hton, THD *thd, bool all); void (*prepare_ordered)(handlerton *hton, THD *thd, bool all);
int (*recover)(handlerton *hton, XID *xid_list, uint len); int (*recover)(handlerton *hton, XID *xid_list, uint len);
......
This diff is collapsed.
...@@ -4023,8 +4023,8 @@ THD::signal_wakeup_ready() ...@@ -4023,8 +4023,8 @@ THD::signal_wakeup_ready()
{ {
pthread_mutex_lock(&LOCK_wakeup_ready); pthread_mutex_lock(&LOCK_wakeup_ready);
wakeup_ready= true; wakeup_ready= true;
pthread_cond_signal(&COND_wakeup_ready);
pthread_mutex_unlock(&LOCK_wakeup_ready); pthread_mutex_unlock(&LOCK_wakeup_ready);
pthread_cond_signal(&COND_wakeup_ready);
} }
......
...@@ -11643,6 +11643,12 @@ static MYSQL_SYSVAR_ENUM(adaptive_checkpoint, srv_adaptive_checkpoint, ...@@ -11643,6 +11643,12 @@ static MYSQL_SYSVAR_ENUM(adaptive_checkpoint, srv_adaptive_checkpoint,
"Enable/Disable flushing along modified age. (none, reflex, [estimate])", "Enable/Disable flushing along modified age. (none, reflex, [estimate])",
NULL, innodb_adaptive_checkpoint_update, 2, &adaptive_checkpoint_typelib); NULL, innodb_adaptive_checkpoint_update, 2, &adaptive_checkpoint_typelib);
static MYSQL_SYSVAR_ULONG(enable_unsafe_group_commit, srv_deprecated_enable_unsafe_group_commit,
PLUGIN_VAR_RQCMDARG,
"Enable/Disable unsafe group commit when support_xa=OFF and use with binlog or other XA storage engine. "
"(Deprecated, and does nothing, group commit is always enabled in a safe way)",
NULL, NULL, 0, 0, 1, 0);
static MYSQL_SYSVAR_ULONG(expand_import, srv_expand_import, static MYSQL_SYSVAR_ULONG(expand_import, srv_expand_import,
PLUGIN_VAR_RQCMDARG, PLUGIN_VAR_RQCMDARG,
"Enable/Disable converting automatically *.ibd files when import tablespace.", "Enable/Disable converting automatically *.ibd files when import tablespace.",
...@@ -11748,6 +11754,7 @@ static struct st_mysql_sys_var* innobase_system_variables[]= { ...@@ -11748,6 +11754,7 @@ static struct st_mysql_sys_var* innobase_system_variables[]= {
MYSQL_SYSVAR(read_ahead), MYSQL_SYSVAR(read_ahead),
MYSQL_SYSVAR(adaptive_checkpoint), MYSQL_SYSVAR(adaptive_checkpoint),
MYSQL_SYSVAR(flush_log_at_trx_commit_session), MYSQL_SYSVAR(flush_log_at_trx_commit_session),
MYSQL_SYSVAR(enable_unsafe_group_commit),
MYSQL_SYSVAR(expand_import), MYSQL_SYSVAR(expand_import),
MYSQL_SYSVAR(extra_rsegments), MYSQL_SYSVAR(extra_rsegments),
MYSQL_SYSVAR(dict_size_limit), MYSQL_SYSVAR(dict_size_limit),
......
...@@ -230,7 +230,7 @@ extern ulong srv_ibuf_active_contract; ...@@ -230,7 +230,7 @@ extern ulong srv_ibuf_active_contract;
extern ulong srv_ibuf_accel_rate; extern ulong srv_ibuf_accel_rate;
extern ulint srv_checkpoint_age_target; extern ulint srv_checkpoint_age_target;
extern ulong srv_flush_neighbor_pages; extern ulong srv_flush_neighbor_pages;
extern ulong srv_enable_unsafe_group_commit; extern ulong srv_deprecated_enable_unsafe_group_commit;
extern ulong srv_read_ahead; extern ulong srv_read_ahead;
extern ulong srv_adaptive_checkpoint; extern ulong srv_adaptive_checkpoint;
......
...@@ -407,7 +407,7 @@ UNIV_INTERN ulong srv_ibuf_accel_rate = 100; ...@@ -407,7 +407,7 @@ UNIV_INTERN ulong srv_ibuf_accel_rate = 100;
UNIV_INTERN ulint srv_checkpoint_age_target = 0; UNIV_INTERN ulint srv_checkpoint_age_target = 0;
UNIV_INTERN ulong srv_flush_neighbor_pages = 1; /* 0:disable 1:enable */ UNIV_INTERN ulong srv_flush_neighbor_pages = 1; /* 0:disable 1:enable */
UNIV_INTERN ulong srv_enable_unsafe_group_commit = 0; /* 0:disable 1:enable */ UNIV_INTERN ulong srv_deprecated_enable_unsafe_group_commit = 0;
UNIV_INTERN ulong srv_read_ahead = 3; /* 1: random 2: linear 3: Both */ UNIV_INTERN ulong srv_read_ahead = 3; /* 1: random 2: linear 3: Both */
UNIV_INTERN ulong srv_adaptive_checkpoint = 0; /* 0: none 1: reflex 2: estimate */ UNIV_INTERN ulong srv_adaptive_checkpoint = 0; /* 0: none 1: reflex 2: estimate */
......
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