Skip to content
This repository has been archived by the owner on Feb 20, 2023. It is now read-only.

Commit

Permalink
Use a slightly better way for waiting.
Browse files Browse the repository at this point in the history
  • Loading branch information
Calculuser committed May 15, 2019
1 parent d74a0f5 commit f2d6f32
Showing 1 changed file with 4 additions and 0 deletions.
4 changes: 4 additions & 0 deletions src/storage/index/index_manager.cpp
Expand Up @@ -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<std::string> &key_attrs) {
// Setup the oid and constraint type for the index
Expand Down Expand Up @@ -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.
Expand Down Expand Up @@ -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 *>(index_entry->GetBigIntColumn("indexptr"));
Expand Down

0 comments on commit f2d6f32

Please sign in to comment.