Below is the list of changes that have just been committed into a local
5.0 repository of serg. When serg does a push these changes will
be propagated to the main repository and, within 24 hours after the
push, to the public repository.
For information on how to access the public repository
see http://dev.mysql.com/doc/mysql/en/installing-source-tree.html
ChangeSet
1.1817 05/03/16 12:45:08 serg@stripped +3 -0
sql/ha_innodb.cc
protect prepare-...-commit with a mutex to ensure that commits in binlog and in the
innodb have the same order
store binlog position with the commit
sql/handler.cc
1.148 05/03/16 12:45:00 serg@stripped +0 -3
ha_prepare cannot return -1
sql/ha_innodb.cc
1.176 05/03/16 12:45:00 serg@stripped +29 -11
protect prepare-...-commit with a mutex to ensure that commits in binlog and in the
innodb have the same order
store binlog position with the commit
innobase/include/trx0trx.h
1.44 05/03/16 12:44:59 serg@stripped +3 -2
comment modified
# This is a BitKeeper patch. What follows are the unified diffs for the
# set of deltas contained in the patch. The rest of the patch, the part
# that BitKeeper cares about, is below these diffs.
# User: serg
# Host: serg.mylan
# Root: /usr/home/serg/Abk/mysql-5.0
--- 1.147/sql/handler.cc Wed Mar 16 08:41:57 2005
+++ 1.148/sql/handler.cc Wed Mar 16 12:45:00 2005
@@ -526,7 +526,6 @@
/*
RETURN
- -1 - cannot prepare
0 - ok
1 - error, transaction was rolled back
*/
@@ -539,8 +538,6 @@
#ifdef USING_TRANSACTIONS
if (trans->nht)
{
- if (trans->no_2pc)
- DBUG_RETURN(-1);
for (; *ht; ht++)
{
int err;
--- 1.43/innobase/include/trx0trx.h Sun Mar 13 11:47:34 2005
+++ 1.44/innobase/include/trx0trx.h Wed Mar 16 12:44:59 2005
@@ -390,8 +390,9 @@
dulint table_id; /* table id if the preceding field is
TRUE */
/*------------------------------*/
- int active_trans; /* whether a transaction in MySQL
- is active */
+ int active_trans; /* 1 - if a transaction in MySQL
+ is active. 2 - if prepare_commit_mutex
+ was taken */
void* mysql_thd; /* MySQL thread handle corresponding
to this trx, or NULL */
char** mysql_query_str;/* pointer to the field in mysqld_thd
--- 1.175/sql/ha_innodb.cc Mon Mar 14 14:47:36 2005
+++ 1.176/sql/ha_innodb.cc Wed Mar 16 12:45:00 2005
@@ -45,7 +45,8 @@
#include "ha_innodb.h"
-pthread_mutex_t innobase_mutex;
+pthread_mutex_t innobase_share_mutex, // to protect innobase_open_files
+ prepare_commit_mutex; // to force correct commit order in binlog
bool innodb_inited= 0;
/* Store MySQL definition of 'byte': in Linux it is char while InnoDB
@@ -1266,7 +1267,8 @@
(void) hash_init(&innobase_open_tables,system_charset_info, 32, 0, 0,
(hash_get_key) innobase_get_key, 0, 0);
- pthread_mutex_init(&innobase_mutex, MY_MUTEX_INIT_FAST);
+ pthread_mutex_init(&innobase_share_mutex, MY_MUTEX_INIT_FAST);
+ pthread_mutex_init(&prepare_commit_mutex, MY_MUTEX_INIT_FAST);
innodb_inited= 1;
/* If this is a replication slave and we needed to do a crash recovery,
@@ -1320,7 +1322,8 @@
hash_free(&innobase_open_tables);
my_free(internal_innobase_data_file_path,
MYF(MY_ALLOW_ZERO_PTR));
- pthread_mutex_destroy(&innobase_mutex);
+ pthread_mutex_destroy(&innobase_share_mutex);
+ pthread_mutex_destroy(&prepare_commit_mutex);
}
DBUG_RETURN(err);
@@ -1478,9 +1481,20 @@
/* We were instructed to commit the whole transaction, or
this is an SQL statement end and autocommit is on */
+ /* We need current binlog position for HotBackup to work.
+ Note, the position is current because of prepare_commit_mutex */
+ trx->mysql_log_file_name = mysql_bin_log.get_log_fname();
+ trx->mysql_log_offset =
+ (ib_longlong)mysql_bin_log.get_log_file()->pos_in_file;
+
innobase_commit_low(trx);
+ if (trx->active_trans == 2) {
+
+ pthread_mutex_unlock(&prepare_commit_mutex);
+ }
trx->active_trans = 0;
+
} else {
/* We just mark the SQL statement ended and do not do a
transaction commit */
@@ -5842,7 +5856,7 @@
static INNOBASE_SHARE *get_share(const char *table_name)
{
INNOBASE_SHARE *share;
- pthread_mutex_lock(&innobase_mutex);
+ pthread_mutex_lock(&innobase_share_mutex);
uint length=(uint) strlen(table_name);
if (!(share=(INNOBASE_SHARE*) hash_search(&innobase_open_tables,
(mysql_byte*) table_name,
@@ -5856,7 +5870,7 @@
strmov(share->table_name,table_name);
if (my_hash_insert(&innobase_open_tables, (mysql_byte*) share))
{
- pthread_mutex_unlock(&innobase_mutex);
+ pthread_mutex_unlock(&innobase_share_mutex);
my_free((gptr) share,0);
return 0;
}
@@ -5865,13 +5879,13 @@
}
}
share->use_count++;
- pthread_mutex_unlock(&innobase_mutex);
+ pthread_mutex_unlock(&innobase_share_mutex);
return share;
}
static void free_share(INNOBASE_SHARE *share)
{
- pthread_mutex_lock(&innobase_mutex);
+ pthread_mutex_lock(&innobase_share_mutex);
if (!--share->use_count)
{
hash_delete(&innobase_open_tables, (mysql_byte*) share);
@@ -5879,7 +5893,7 @@
pthread_mutex_destroy(&share->mutex);
my_free((gptr) share, MYF(0));
}
- pthread_mutex_unlock(&innobase_mutex);
+ pthread_mutex_unlock(&innobase_share_mutex);
}
/*********************************************************************
@@ -6318,14 +6332,18 @@
FALSE - the current SQL statement ended */
{
int error = 0;
- trx_t* trx;
+ trx_t* trx = check_trx_exists(thd);
+
+ if (thd->lex->sql_command != SQLCOM_XA_PREPARE) {
+
+ pthread_mutex_lock(&prepare_commit_mutex);
+ trx->active_trans = 2;
+ }
if (!thd->variables.innodb_support_xa) {
return(0);
}
-
- trx = check_trx_exists(thd);
trx->xid=thd->transaction.xid;
| Thread |
|---|
| • bk commit into 5.0 tree (serg:1.1817) | Sergei Golubchik | 16 Mar |