diff --git a/src/storage/index/index_manager.cpp b/src/storage/index/index_manager.cpp index f1569fbe6f..a3ca6bc8d4 100644 --- a/src/storage/index/index_manager.cpp +++ b/src/storage/index/index_manager.cpp @@ -9,6 +9,8 @@ namespace terrier::storage::index { +static const int WAITING_TIMEOUT_MILLIS = 1000; + Index *IndexManager::GetEmptyIndex(catalog::index_oid_t index_oid, SqlTable *sql_table, bool unique_index, const std::vector &key_attrs) { // Setup the oid and constraint type for the index @@ -97,6 +99,7 @@ catalog::index_oid_t IndexManager::Create(catalog::db_oid_t db_oid, catalog::nam // Wait for all transactions older than the timestamp of previous transaction commit // TODO(jiaqizuo): use more efficient way to wait for all previous transactions to complete. while (txn_mgr->OldestTransactionStartTime() < commit_time) { + std::this_thread::sleep_for(std::chrono::milliseconds(WAITING_TIMEOUT_MILLIS)); } // Start the second transaction to insert all keys into the index. @@ -141,6 +144,7 @@ bool IndexManager::Drop(catalog::db_oid_t db_oid, catalog::namespace_oid_t ns_oi // Wait for all transactions older than the timestamp of previous transaction commit // TODO(xueyuanz): use more efficient way to wait for all previous transactions to complete. while (txn_mgr->OldestTransactionStartTime() < commit_time) { + std::this_thread::sleep_for(std::chrono::milliseconds(WAITING_TIMEOUT_MILLIS)); } // Now we can safely destruct the index_entry Index *index = reinterpret_cast(index_entry->GetBigIntColumn("indexptr"));