3833 Martin Skold 2012-03-07 [merge]
Merge from 71
modified:
mysql-test/suite/ndb/r/ndb_auto_increment.result
mysql-test/suite/ndb/t/ndb_auto_increment.test
sql/ha_ndbcluster.cc
storage/ndb/clusterj/clusterj-tie/src/main/java/com/mysql/clusterj/tie/ClusterConnectionImpl.java
storage/ndb/src/common/debugger/SignalLoggerManager.cpp
3832 John David Duncan 2012-03-06 [merge]
Merge
modified:
storage/ndb/memcache/src/ndb_engine_errors.cc
storage/ndb/memcache/src/ndb_error_logger.cc
=== modified file 'mysql-test/suite/ndb/r/ndb_auto_increment.result'
--- a/mysql-test/suite/ndb/r/ndb_auto_increment.result 2011-09-15 09:12:39 +0000
+++ b/mysql-test/suite/ndb/r/ndb_auto_increment.result 2012-03-07 12:19:58 +0000
@@ -536,3 +536,26 @@ SELECT id from t1;
id
3
DROP TABLE t1;
+create table t1 (a serial) engine ndb;
+set @@insert_id=1;
+insert into t1 values(null);
+insert into t1 values(null);
+insert into t1 values(null);
+insert into t1 values(null);
+set @@insert_id=17;
+insert into t1 values(null);
+insert into t1 values(null);
+insert into t1 values(null);
+select * from t1 order by a;
+a
+1
+2
+3
+4
+17
+18
+19
+set @@insert_id=1;
+insert into t1 values(null);
+ERROR 23000: Duplicate entry '1' for key 'a'
+drop table t1;
=== modified file 'mysql-test/suite/ndb/t/ndb_auto_increment.test'
--- a/mysql-test/suite/ndb/t/ndb_auto_increment.test 2011-09-15 09:12:39 +0000
+++ b/mysql-test/suite/ndb/t/ndb_auto_increment.test 2012-03-07 12:19:58 +0000
@@ -429,3 +429,30 @@ INSERT IGNORE INTO t1 (data) VALUES (6),
SELECT id from t1;
DROP TABLE t1;
+
+#
+# Bug #13731134 AUTO-INC COUNTER IS NOT UPDATED WITH EXPLICIT @@INSERT_ID SET
+#
+
+create table t1 (a serial) engine ndb;
+
+set @@insert_id=1;
+insert into t1 values(null);
+
+connection server2;
+
+insert into t1 values(null);
+insert into t1 values(null);
+insert into t1 values(null);
+set @@insert_id=17;
+insert into t1 values(null);
+insert into t1 values(null);
+insert into t1 values(null);
+select * from t1 order by a;
+
+set @@insert_id=1;
+--error ER_DUP_ENTRY
+insert into t1 values(null);
+
+connection server1;
+drop table t1;
=== modified file 'sql/ha_ndbcluster.cc'
--- a/sql/ha_ndbcluster.cc 2012-02-23 15:41:31 +0000
+++ b/sql/ha_ndbcluster.cc 2012-03-07 12:38:54 +0000
@@ -4783,7 +4783,8 @@ int ha_ndbcluster::ndb_write_row(uchar *
m_skip_auto_increment= FALSE;
if ((error= update_auto_increment()))
DBUG_RETURN(error);
- m_skip_auto_increment= (insert_id_for_cur_row == 0);
+ m_skip_auto_increment= (insert_id_for_cur_row == 0 ||
+ thd->auto_inc_intervals_forced.nb_elements());
}
/*
=== modified file 'storage/ndb/clusterj/clusterj-tie/src/main/java/com/mysql/clusterj/tie/ClusterConnectionImpl.java'
--- a/storage/ndb/clusterj/clusterj-tie/src/main/java/com/mysql/clusterj/tie/ClusterConnectionImpl.java 2012-03-06 02:25:21 +0000
+++ b/storage/ndb/clusterj/clusterj-tie/src/main/java/com/mysql/clusterj/tie/ClusterConnectionImpl.java 2012-03-06 16:51:07 +0000
@@ -73,7 +73,7 @@ public class ClusterConnectionImpl
private static final String USE_SMART_VALUE_HANDLER_NAME = "com.mysql.clusterj.UseSmartValueHandler";
private static final boolean USE_SMART_VALUE_HANDLER =
- ClusterJHelper.getBooleanProperty(USE_SMART_VALUE_HANDLER_NAME, "false");
+ ClusterJHelper.getBooleanProperty(USE_SMART_VALUE_HANDLER_NAME, "true");
/** Connect to the MySQL Cluster
*
@@ -196,6 +196,7 @@ public class ClusterConnectionImpl
/**
* Get the cached NdbRecord implementation for this cluster connection.
+ * Use a ConcurrentHashMap for best multithread performance.
* There are three possibilities:
* <ul><li>Case 1: return the already-cached NdbRecord
* </li><li>Case 2: return a new instance created by this method
@@ -214,7 +215,16 @@ public class ClusterConnectionImpl
if (logger.isDebugEnabled())logger.debug("NdbRecordImpl found for " + tableName);
return result;
} else {
- NdbRecordImpl newNdbRecordImpl = new NdbRecordImpl(storeTable, dictionaryForNdbRecord);
+ // dictionary is single thread
+ NdbRecordImpl newNdbRecordImpl;
+ synchronized (dictionaryForNdbRecord) {
+ // try again; another thread might have beat us
+ result = ndbRecordImplMap.get(tableName);
+ if (result != null) {
+ return result;
+ }
+ newNdbRecordImpl = new NdbRecordImpl(storeTable, dictionaryForNdbRecord);
+ }
NdbRecordImpl winner = ndbRecordImplMap.putIfAbsent(tableName, newNdbRecordImpl);
if (winner == null) {
// case 2: the previous value was null, so return the new (winning) value
=== modified file 'storage/ndb/src/common/debugger/SignalLoggerManager.cpp'
--- a/storage/ndb/src/common/debugger/SignalLoggerManager.cpp 2012-02-23 15:41:31 +0000
+++ b/storage/ndb/src/common/debugger/SignalLoggerManager.cpp 2012-03-07 12:38:54 +0000
@@ -67,8 +67,11 @@ SignalLoggerManager::~SignalLoggerManage
FILE *
SignalLoggerManager::setOutputStream(FILE * output)
{
- if(outputStream != 0){
+ if (outputStream != 0)
+ {
+ lock();
fflush(outputStream);
+ unlock();
}
FILE * out = outputStream;
@@ -85,8 +88,12 @@ SignalLoggerManager::getOutputStream() c
void
SignalLoggerManager::flushSignalLog()
{
- if(outputStream != 0)
+ if (outputStream != 0)
+ {
+ lock();
fflush(outputStream);
+ unlock();
+ }
}
void
No bundle (reason: useless for push emails).
| Thread |
|---|
| • bzr push into mysql-5.5-cluster-7.2 branch (Martin.Skold:3832 to 3833) | Martin Skold | 8 Mar |