summaryrefslogtreecommitdiff
path: root/ndb
diff options
context:
space:
mode:
authorunknown <tomas@poseidon.ndb.mysql.com>2006-07-06 18:50:44 +0200
committerunknown <tomas@poseidon.ndb.mysql.com>2006-07-06 18:50:44 +0200
commitce554d56a4949cb138efbdfc86fd1cf74383487d (patch)
tree250c145efec2c2ce01b1990f0e22bb51ae58ba24 /ndb
parent123c0a98b43e8669e5bd1d6a4cbfeec108c3c902 (diff)
downloadmariadb-git-ce554d56a4949cb138efbdfc86fd1cf74383487d.tar.gz
Bug #20820 auto inc table not handled correctly when restored from cluster backup
Diffstat (limited to 'ndb')
-rw-r--r--ndb/tools/restore/consumer_restore.cpp40
1 files changed, 29 insertions, 11 deletions
diff --git a/ndb/tools/restore/consumer_restore.cpp b/ndb/tools/restore/consumer_restore.cpp
index bff63c28716..dc1399e73b2 100644
--- a/ndb/tools/restore/consumer_restore.cpp
+++ b/ndb/tools/restore/consumer_restore.cpp
@@ -145,17 +145,38 @@ BackupRestore::finalize_table(const TableS & table){
bool ret= true;
if (!m_restore && !m_restore_meta)
return ret;
- if (table.have_auto_inc())
+ if (!table.have_auto_inc())
+ return ret;
+
+ Uint64 max_val= table.get_max_auto_val();
+ do
{
- Uint64 max_val= table.get_max_auto_val();
- Uint64 auto_val;
+ Uint64 auto_val = ~(Uint64)0;
int r= m_ndb->readAutoIncrementValue(get_table(table.m_dictTable), auto_val);
- if (r == -1 && m_ndb->getNdbError().code != 626)
+ if (r == -1 && m_ndb->getNdbError().status == NdbError::TemporaryError)
+ {
+ NdbSleep_MilliSleep(50);
+ continue; // retry
+ }
+ else if (r == -1 && m_ndb->getNdbError().code != 626)
+ {
ret= false;
- else if (r == -1 || max_val+1 > auto_val)
- ret= m_ndb->setAutoIncrementValue(get_table(table.m_dictTable), max_val+1, false) != -1;
- }
- return ret;
+ }
+ else if ((r == -1 && m_ndb->getNdbError().code == 626) ||
+ max_val+1 > auto_val || auto_val == ~(Uint64)0)
+ {
+ r= m_ndb->setAutoIncrementValue(get_table(table.m_dictTable),
+ max_val+1, false);
+ if (r == -1 &&
+ m_ndb->getNdbError().status == NdbError::TemporaryError)
+ {
+ NdbSleep_MilliSleep(50);
+ continue; // retry
+ }
+ ret = (r == 0);
+ }
+ return (ret);
+ } while (1);
}
bool
@@ -217,9 +238,6 @@ BackupRestore::table(const TableS & table){
err << "Unable to find table: " << split[2].c_str() << endl;
return false;
}
- if(m_restore_meta){
- m_ndb->setAutoIncrementValue(tab, ~(Uint64)0, false);
- }
const NdbDictionary::Table* null = 0;
m_new_tables.fill(table.m_dictTable->getTableId(), null);
m_new_tables[table.m_dictTable->getTableId()] = tab;