Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,8 @@ public class TableStateManager {
private final ConcurrentMap<TableName, TableState.State> tableName2State =
new ConcurrentHashMap<>();

private final ConcurrentMap<TableName, Integer> creating = new ConcurrentHashMap<>();
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ConcurrentMap.newKeySet


TableStateManager(MasterServices master) {
this.master = master;
}
Expand Down Expand Up @@ -104,12 +106,32 @@ public boolean isTablePresent(TableName tableName) throws IOException {
ReadWriteLock lock = tnLock.getLock(tableName);
lock.readLock().lock();
try {
return readMetaState(tableName) != null;
return readMetaState(tableName) != null && !isCreating(tableName);
} finally {
lock.readLock().unlock();
}
}

/**
* Set a table as being created.
* @param tableName name of table being created
*/
public void updateCreating(TableName tableName) {
creating.put(tableName, 1);
}

/**
* Notify that a table is created.
* @param tableName name of table created
*/
public void finishCreating(TableName tableName) {
creating.remove(tableName);
}

private boolean isCreating(TableName tableName) {
return creating.containsKey(tableName);
}

/**
* Return all tables in given states.
* @param states filter by states
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -105,6 +105,7 @@ protected Flow executeFromState(final MasterProcedureEnv env, final CreateTableS
setNextState(CreateTableState.CREATE_TABLE_ASSIGN_REGIONS);
break;
case CREATE_TABLE_ASSIGN_REGIONS:
env.getMasterServices().getTableStateManager().updateCreating(getTableName());
setEnablingState(env, getTableName());
addChildProcedure(
env.getAssignmentManager().createRoundRobinAssignProcedures(newRegions));
Expand All @@ -114,6 +115,7 @@ protected Flow executeFromState(final MasterProcedureEnv env, final CreateTableS
// XXX: this stage should be named as set table enabled, as now we will cache the
// descriptor after writing fs layout.
setEnabledState(env, getTableName());
env.getMasterServices().getTableStateManager().finishCreating(getTableName());
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actually, the sub procedure will be execute after this line has been executed, so the solution here can not solve the problem described in the issue...

setNextState(CreateTableState.CREATE_TABLE_POST_OPERATION);
break;
case CREATE_TABLE_POST_OPERATION:
Expand Down