Is Accumulo TableOperations.createTable synchronous?

123 views Asked by At

I'm working with Accumulo 1.6.2 and I am seeing an issue where it appears that TableOperations.createTable may return without an exception, but the table still isn't ready.

For example in the following code:

String tableName = "foo";
TableOperations operations = connector.tableOperations();

if(!operations.exists(tableName))
{
  operations.createTable(tableName);
}

//Make a bunch of mutations that write to the table
BatchWriter batchWriter = connector.createBatchWriter(tableName, someConfig);

batchWriter.addMutations(mutations);
batchWriter.close();

When I run a unit test with the above code, I will sometimes get an exception indicating that table foo does not exist. However, the code just created table foo.

The only thing I can think of is that there is a window of time after createTable() returns where the table still might not exist.

The Javadoc doesn't explain the behavior. I also have read an early release copy of Orielly's Accumulo book and it doesn't say either.

What is the correct pattern here? I could add something like the following:

//Make table    
while(!operations.exists(tableName){}
//Do stuff with table

However that seems like a really ugly and potentially bug prone thing to do. I'm hoping there is a better pattern here.

1

There are 1 answers

3
elserj On BEST ANSWER

Creating a table should be a synchronous operation. You should not see an exception with the above example.

If you can provide the specific exception, that might hint at a bug that needs to be fixed.