summaryrefslogtreecommitdiff
path: root/sql
diff options
context:
space:
mode:
authorunknown <mskold@mysql.com>2005-04-15 16:14:08 +0200
committerunknown <mskold@mysql.com>2005-04-15 16:14:08 +0200
commit6b75a704e8534b54f31abf7ce013d94f6d1c380d (patch)
tree579618ce99cca25062b570a6d3a0121713506e75 /sql
parentb112ccb58364631fa2af34dced30fc578d92ed8c (diff)
downloadmariadb-git-6b75a704e8534b54f31abf7ce013d94f6d1c380d.tar.gz
Bug #9839 Column with AUTOINC contains -1 Value on node stop, post review fix
Diffstat (limited to 'sql')
-rw-r--r--sql/ha_ndbcluster.cc23
1 files changed, 18 insertions, 5 deletions
diff --git a/sql/ha_ndbcluster.cc b/sql/ha_ndbcluster.cc
index 242bdec75cb..d14d5f6f5c3 100644
--- a/sql/ha_ndbcluster.cc
+++ b/sql/ha_ndbcluster.cc
@@ -48,6 +48,7 @@ static const char *ha_ndb_ext=".ndb";
#define NDB_HIDDEN_PRIMARY_KEY_LENGTH 8
#define NDB_FAILED_AUTO_INCREMENT ~(Uint64)0
+#define NDB_AUTO_INCREMENT_RETRIES 10
#define ERR_PRINT(err) \
DBUG_PRINT("error", ("%d message: %s", err.code, err.message))
@@ -1839,7 +1840,13 @@ int ha_ndbcluster::write_row(byte *record)
{
// Table has hidden primary key
Ndb *ndb= get_ndb();
- Uint64 auto_value= ndb->getAutoIncrementValue((const NDBTAB *) m_table);
+ Uint64 auto_value= NDB_FAILED_AUTO_INCREMENT;
+ uint retries= NDB_AUTO_INCREMENT_RETRIES;
+ do {
+ auto_value= ndb->getAutoIncrementValue((const NDBTAB *) m_table);
+ } while (auto_value == NDB_FAILED_AUTO_INCREMENT &&
+ --retries &&
+ ndb->getNdbError().status == NdbError::TemporaryError);
if (auto_value == NDB_FAILED_AUTO_INCREMENT)
ERR_RETURN(ndb->getNdbError());
if (set_hidden_key(op, table->fields, (const byte*)&auto_value))
@@ -3974,10 +3981,16 @@ longlong ha_ndbcluster::get_auto_increment()
: (m_rows_to_insert > m_autoincrement_prefetch) ?
m_rows_to_insert
: m_autoincrement_prefetch;
- Uint64 auto_value=
- (m_skip_auto_increment) ?
- ndb->readAutoIncrementValue((const NDBTAB *) m_table)
- : ndb->getAutoIncrementValue((const NDBTAB *) m_table, cache_size);
+ Uint64 auto_value= NDB_FAILED_AUTO_INCREMENT;
+ uint retries= NDB_AUTO_INCREMENT_RETRIES;
+ do {
+ auto_value=
+ (m_skip_auto_increment) ?
+ ndb->readAutoIncrementValue((const NDBTAB *) m_table)
+ : ndb->getAutoIncrementValue((const NDBTAB *) m_table, cache_size);
+ } while (auto_value == NDB_FAILED_AUTO_INCREMENT &&
+ --retries &&
+ ndb->getNdbError().status == NdbError::TemporaryError);
if (auto_value == NDB_FAILED_AUTO_INCREMENT)
ERR_RETURN(ndb->getNdbError());
DBUG_RETURN((longlong)auto_value);