|
1 | 1 | /* |
2 | | - Copyright (c) 2004, 2014, Oracle and/or its affiliates. All rights reserved. |
| 2 | + Copyright (c) 2004, 2016, Oracle and/or its affiliates. All rights reserved. |
3 | 3 |
|
4 | 4 | This program is free software; you can redistribute it and/or modify |
5 | 5 | it under the terms of the GNU General Public License as published by |
@@ -979,14 +979,36 @@ BackupRestore::rebuild_indexes(const TableS& table) |
979 | 979 | const NDB_TICKS start = NdbTick_getCurrentTicks(); |
980 | 980 | info << "Rebuilding index `" << idx_name << "` on table `" |
981 | 981 | << tab_name << "` ..." << flush; |
982 | | - if ((dict->getIndex(idx_name, tab_name) == NULL) |
983 | | - && (dict->createIndex(* idx, 1) != 0)) |
| 982 | + bool done = false; |
| 983 | + for(int retries = 0; retries<11; retries++) |
| 984 | + { |
| 985 | + if ((dict->getIndex(idx_name, tab_name) == NULL) |
| 986 | + && (dict->createIndex(* idx, 1) != 0)) |
| 987 | + { |
| 988 | + if(dict->getNdbError().status == NdbError::TemporaryError) |
| 989 | + { |
| 990 | + err << "retry sleep 50 ms on error " << |
| 991 | + dict->getNdbError().code << endl; |
| 992 | + NdbSleep_MilliSleep(50); |
| 993 | + continue; // retry on temporary error |
| 994 | + } |
| 995 | + else |
| 996 | + { |
| 997 | + break; |
| 998 | + } |
| 999 | + } |
| 1000 | + else |
| 1001 | + { |
| 1002 | + done = true; |
| 1003 | + break; |
| 1004 | + } |
| 1005 | + } |
| 1006 | + if(!done) |
984 | 1007 | { |
985 | 1008 | info << "FAIL!" << endl; |
986 | 1009 | err << "Rebuilding index `" << idx_name << "` on table `" |
987 | 1010 | << tab_name <<"` failed: "; |
988 | 1011 | err << dict->getNdbError() << endl; |
989 | | - |
990 | 1012 | return false; |
991 | 1013 | } |
992 | 1014 | const NDB_TICKS stop = NdbTick_getCurrentTicks(); |
@@ -2511,13 +2533,32 @@ BackupRestore::endOfTables(){ |
2511 | 2533 | idx->setName(split_idx[3].c_str()); |
2512 | 2534 | if (m_restore_meta && !m_disable_indexes && !m_rebuild_indexes) |
2513 | 2535 | { |
2514 | | - if (dict->createIndex(* idx) != 0) |
| 2536 | + bool done = false; |
| 2537 | + for(unsigned int retries = 0; retries < 11; retries++) |
| 2538 | + { |
| 2539 | + if(dict->createIndex(* idx) == 0) |
| 2540 | + { |
| 2541 | + done = true; // success |
| 2542 | + break; |
| 2543 | + } |
| 2544 | + else if(dict->getNdbError().status == NdbError::TemporaryError) |
| 2545 | + { |
| 2546 | + err << "retry sleep 50 ms on error " << |
| 2547 | + dict->getNdbError().code << endl; |
| 2548 | + NdbSleep_MilliSleep(50); |
| 2549 | + continue; // retry on temporary error |
| 2550 | + } |
| 2551 | + else |
| 2552 | + { |
| 2553 | + break; // error out on permanent error |
| 2554 | + } |
| 2555 | + } |
| 2556 | + if(!done) |
2515 | 2557 | { |
2516 | 2558 | delete idx; |
2517 | 2559 | err << "Failed to create index `" << split_idx[3].c_str() |
2518 | 2560 | << "` on `" << table_name << "`" << endl |
2519 | 2561 | << dict->getNdbError() << endl; |
2520 | | - |
2521 | 2562 | return false; |
2522 | 2563 | } |
2523 | 2564 | info << "Successfully created index `" << split_idx[3].c_str() |
|
0 commit comments