Skip to content

Commit

Permalink
Fix intermittent failures in distributed concurrency testing
Browse files Browse the repository at this point in the history
  • Loading branch information
dwayneberry authored and andrewseidl committed Jan 4, 2021
1 parent 890651f commit 2cd04e0
Show file tree
Hide file tree
Showing 5 changed files with 34 additions and 15 deletions.
4 changes: 3 additions & 1 deletion LockMgr/LockMgr.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,9 @@ ChunkKey chunk_key_for_table(const Catalog_Namespace::Catalog& cat,
ChunkKey chunk_key{cat.getCurrentDB().dbId, tdp->tableId};
return chunk_key;
} else {
throw std::runtime_error("Table/View " + tableName + " does not exist.");
throw std::runtime_error("Table/View " + tableName + " for catalog " +
cat.getCurrentDB().dbName +
" does not exist, could not generate chunk key");
}
}

Expand Down
6 changes: 4 additions & 2 deletions LockMgr/LockMgr.h
Original file line number Diff line number Diff line change
Expand Up @@ -121,7 +121,8 @@ class TableSchemaLockContainer<ReadLock>
const auto td = cat.getMetadataForTable(table_id);
if (!td) {
throw std::runtime_error("Table/View ID " + std::to_string(table_id) +
" does not exist.");
" for catalog " + cat.getCurrentDB().dbName +
" does not exist. Cannot aquire read lock");
}
VLOG(1) << "Acquiring Table Schema Read Lock for table: " << td->tableName;
return TableSchemaLockContainer<ReadLock>(
Expand Down Expand Up @@ -153,7 +154,8 @@ class TableSchemaLockContainer<WriteLock>
const auto td = cat.getMetadataForTable(table_id);
if (!td) {
throw std::runtime_error("Table/View ID " + std::to_string(table_id) +
" does not exist.");
" for catalog " + cat.getCurrentDB().dbName +
" does not exist. Cannot aquire write lock");
}
VLOG(1) << "Acquiring Table Schema Write Lock for table: " << td->tableName;
return TableSchemaLockContainer<WriteLock>(
Expand Down
4 changes: 3 additions & 1 deletion Tests/CreateAndDropTableDdlTest.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1329,7 +1329,9 @@ TEST_P(DropTableTest, NonExistingTableWithIfExists) {

TEST_P(DropTableTest, NonExistentTableWithoutIfExists) {
std::string query = getDropTableQuery(GetParam(), "test_table_2");
queryAndAssertException(query, "Exception: Table/View test_table_2 does not exist.");
queryAndAssertException(query,
"Exception: Table/View test_table_2 for catalog omnisci does "
"not exist, could not generate chunk key");
}

TEST_P(DropTableTest, UnauthorizedUser) {
Expand Down
3 changes: 2 additions & 1 deletion Tests/ForeignTableDmlTest.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -4439,7 +4439,8 @@ TEST_F(AlterForeignTableTest, NonExistantOption) {
TEST_F(AlterForeignTableTest, TableDoesNotExist) {
queryAndAssertException(
"ALTER FOREIGN TABLE test_foreign_table RENAME TO renamed_table;",
"Exception: Table/View test_foreign_table does not exist.");
"Exception: Table/View test_foreign_table for catalog omnisci does not exist, "
"could not generate chunk key");
}

TEST_F(AlterForeignTableTest, Table) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ private void runTest(
throws Exception {
int num_threads = 5;
final int runs = 5;
final int num_rows = 400;
final int max_num_rows = 400;
final int fragment_size = 25;
Exception exceptions[] = new Exception[num_threads];

Expand All @@ -78,9 +78,14 @@ public void run() {
MapdTestClient user =
MapdTestClient.getClient("localhost", 6274, db, dbUser, dbPassword);

user.runSql("CREATE TABLE " + tableName
sql = "CREATE TABLE " + tableName
+ "(x BIGINT, y INTEGER, z SMALLINT, a TINYINT, f FLOAT, d DOUBLE, deci DECIMAL(18,6), str TEXT ENCODING NONE) WITH (FRAGMENT_SIZE = "
+ fragment_size + ")");
+ fragment_size + ")";
logger.info(logPrefix + " " + sql);
user.runSql(sql);

Random rand = new Random(tid);
int num_rows = rand.nextInt(max_num_rows);

for (int i = 0; i < num_rows; i++) {
final String integer_val = Integer.toString(i);
Expand All @@ -97,12 +102,14 @@ public void run() {
fp_val,
deci_val,
str_val);
user.runSql("INSERT INTO " + tableName + " VALUES "
+ "(" + values_string + ")");
sql = "INSERT INTO " + tableName + " VALUES "
+ "(" + values_string + ")";
user.runSql(sql);
if (i == 0) {
logger.info(logPrefix + " " + sql);
}
}

Random rand = new Random(tid);

sql = "ALTER TABLE " + tableName + " ADD COLUMN zz TEXT ENCODING DICT(8);";
logger.info(logPrefix + " " + sql);
user.runSql(sql);
Expand All @@ -117,8 +124,11 @@ public void run() {
logger.info(logPrefix + " " + sql);
user.runSql(sql);

sql = "status";
user.get_status();
sql = "hardware";
user.get_hardware_info();
sql = "memory";
user.get_memory("cpu");

sql = "DELETE FROM " + tableName + " WHERE y = " + rand.nextInt(num_rows)
Expand Down Expand Up @@ -148,8 +158,10 @@ public void run() {
user.runSql(sql);

} catch (Exception e) {
logger.error(logPrefix + " Caught Exception: " + e.getMessage(), e);
exceptions[threadId] = e;
logger.error(logPrefix + " While running query '" + sql
+ "' it threw this: " + e.getMessage());
exceptions[threadId] = new Exception(
" While running query '" + sql + "' it threw this: " + e);
}
}
}
Expand All @@ -164,7 +176,7 @@ public void run() {

for (Exception e : exceptions) {
if (null != e) {
logger.error("Exception: " + e.getMessage(), e);
logger.error("Exception during threaded runs: " + e.getMessage());
throw e;
}
}
Expand Down

0 comments on commit 2cd04e0

Please sign in to comment.