Skip to content

Commit

Permalink
keep synchronized for regions
Browse files Browse the repository at this point in the history
Signed-off-by: PengFei Li <[email protected]>
  • Loading branch information
banmoy committed Aug 23, 2023
1 parent 3314894 commit 96c9158
Showing 1 changed file with 12 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -419,11 +419,18 @@ protected TableRegion getCacheRegion(String uniqueKey, String database, String t

TableRegion region = regions.get(uniqueKey);
if (region == null) {
StreamLoadTableProperties tableProperties = properties.getTableProperties(uniqueKey);
region = new TransactionTableRegion(uniqueKey, database, table, this,
tableProperties, streamLoader, maxRetries, retryIntervalInMs);
regions.put(uniqueKey, region);
flushQ.offer((TransactionTableRegion) region);
// currently write() will not be called concurrently, so regions will also not be
// created concurrently, but for future extension, protect it with synchronized
synchronized (regions) {
region = regions.get(uniqueKey);
if (region == null) {
StreamLoadTableProperties tableProperties = properties.getTableProperties(uniqueKey);
region = new TransactionTableRegion(uniqueKey, database, table, this,
tableProperties, streamLoader, maxRetries, retryIntervalInMs);
regions.put(uniqueKey, region);
flushQ.offer((TransactionTableRegion) region);
}
}
}
return region;
}
Expand Down

0 comments on commit 96c9158

Please sign in to comment.