diff options
author | unknown <tomas@whalegate.ndb.mysql.com> | 2007-05-14 12:15:27 +0200 |
---|---|---|
committer | unknown <tomas@whalegate.ndb.mysql.com> | 2007-05-14 12:15:27 +0200 |
commit | 5a5aafd3078578f474248d3025cbcdda6a1a914a (patch) | |
tree | 070015c44f133522dcd4a4c100629842f48d018c /sql/ha_ndbcluster.cc | |
parent | 18e6090c376e4347a3b2041244e2b1a2fb269c2f (diff) | |
download | mariadb-git-5a5aafd3078578f474248d3025cbcdda6a1a914a.tar.gz |
Bug #28410 ndb: no retry sleep when getting autoincrement
- add retry sleep to allow temprary error to go away
Diffstat (limited to 'sql/ha_ndbcluster.cc')
-rw-r--r-- | sql/ha_ndbcluster.cc | 59 |
1 files changed, 36 insertions, 23 deletions
diff --git a/sql/ha_ndbcluster.cc b/sql/ha_ndbcluster.cc index 0e9dfcef5fb..0f3a42bbce7 100644 --- a/sql/ha_ndbcluster.cc +++ b/sql/ha_ndbcluster.cc @@ -2309,16 +2309,24 @@ int ha_ndbcluster::write_row(byte *record) { // Table has hidden primary key Ndb *ndb= get_ndb(); - int ret; Uint64 auto_value; uint retries= NDB_AUTO_INCREMENT_RETRIES; - do { - ret= ndb->getAutoIncrementValue((const NDBTAB *) m_table, auto_value, 1); - } while (ret == -1 && - --retries && - ndb->getNdbError().status == NdbError::TemporaryError); - if (ret == -1) - ERR_RETURN(ndb->getNdbError()); + int retry_sleep= 30; /* 30 milliseconds, transaction */ + for (;;) + { + if (ndb->getAutoIncrementValue((const NDBTAB *) m_table, + auto_value, 1) == -1) + { + if (--retries && + ndb->getNdbError().status == NdbError::TemporaryError); + { + my_sleep(retry_sleep); + continue; + } + ERR_RETURN(ndb->getNdbError()); + } + break; + } if (set_hidden_key(op, table->s->fields, (const byte*)&auto_value)) ERR_RETURN(op->getNdbError()); } @@ -4855,22 +4863,27 @@ ulonglong ha_ndbcluster::get_auto_increment() m_rows_to_insert - m_rows_inserted : ((m_rows_to_insert > m_autoincrement_prefetch) ? m_rows_to_insert : m_autoincrement_prefetch)); - int ret; uint retries= NDB_AUTO_INCREMENT_RETRIES; - do { - ret= - m_skip_auto_increment ? - ndb->readAutoIncrementValue((const NDBTAB *) m_table, auto_value) : - ndb->getAutoIncrementValue((const NDBTAB *) m_table, auto_value, cache_size); - } while (ret == -1 && - --retries && - ndb->getNdbError().status == NdbError::TemporaryError); - if (ret == -1) - { - const NdbError err= ndb->getNdbError(); - sql_print_error("Error %lu in ::get_auto_increment(): %s", - (ulong) err.code, err.message); - DBUG_RETURN(~(ulonglong) 0); + int retry_sleep= 30; /* 30 milliseconds, transaction */ + for (;;) + { + if (m_skip_auto_increment && + ndb->readAutoIncrementValue((const NDBTAB *) m_table, auto_value) || + ndb->getAutoIncrementValue((const NDBTAB *) m_table, + auto_value, cache_size)) + { + if (--retries && + ndb->getNdbError().status == NdbError::TemporaryError); + { + my_sleep(retry_sleep); + continue; + } + const NdbError err= ndb->getNdbError(); + sql_print_error("Error %lu in ::get_auto_increment(): %s", + (ulong) err.code, err.message); + DBUG_RETURN(~(ulonglong) 0); + } + break; } DBUG_RETURN((longlong)auto_value); } |