-
Notifications
You must be signed in to change notification settings - Fork 40
Fix the DynamoDB metadata table upsert operation #2769
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from 2 commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||||||
|---|---|---|---|---|---|---|---|---|
|
|
@@ -97,6 +97,7 @@ public class DynamoAdmin implements DistributedStorageAdmin { | |||||||
| public static final String DEFAULT_NO_BACKUP = "false"; | ||||||||
| public static final String DEFAULT_REQUEST_UNIT = "10"; | ||||||||
| private static final int DEFAULT_WAITING_DURATION_SECS = 3; | ||||||||
| @VisibleForTesting static final int DEFAULT_MAX_RETRY_COUNT = 10; | ||||||||
|
|
||||||||
| @VisibleForTesting static final String PARTITION_KEY = "concatenatedPartitionKey"; | ||||||||
| @VisibleForTesting static final String CLUSTERING_KEY = "concatenatedClusteringKey"; | ||||||||
|
|
@@ -238,15 +239,26 @@ public void createNamespace(String nonPrefixedNamespace, Map<String, String> opt | |||||||
| private void upsertIntoNamespacesTable(Namespace namespace) throws ExecutionException { | ||||||||
| Map<String, AttributeValue> itemValues = new HashMap<>(); | ||||||||
| itemValues.put(NAMESPACES_ATTR_NAME, AttributeValue.builder().s(namespace.prefixed()).build()); | ||||||||
| try { | ||||||||
| client.putItem( | ||||||||
| PutItemRequest.builder() | ||||||||
| .tableName(ScalarDbUtils.getFullTableName(metadataNamespace, NAMESPACES_TABLE)) | ||||||||
| .item(itemValues) | ||||||||
| .build()); | ||||||||
| } catch (Exception e) { | ||||||||
| throw new ExecutionException( | ||||||||
| "Inserting the " + namespace + " namespace into the namespaces table failed", e); | ||||||||
| int retryCount = 0; | ||||||||
|
||||||||
| while (true) { | ||||||||
| try { | ||||||||
| client.putItem( | ||||||||
| PutItemRequest.builder() | ||||||||
| .tableName(ScalarDbUtils.getFullTableName(metadataNamespace, NAMESPACES_TABLE)) | ||||||||
| .item(itemValues) | ||||||||
| .build()); | ||||||||
| return; | ||||||||
| } catch (ResourceNotFoundException e) { | ||||||||
| if (retryCount >= DEFAULT_MAX_RETRY_COUNT) { | ||||||||
| throw new ExecutionException( | ||||||||
| "Inserting the " + namespace + " namespace into the namespaces table failed", e); | ||||||||
| } | ||||||||
| Uninterruptibles.sleepUninterruptibly(waitingDurationSecs, TimeUnit.SECONDS); | ||||||||
|
||||||||
| Uninterruptibles.sleepUninterruptibly(waitingDurationSecs, TimeUnit.SECONDS); | |
| long backoffDelay = calculateExponentialBackoffWithJitter(retryCount); | |
| Uninterruptibles.sleepUninterruptibly(backoffDelay, TimeUnit.MILLISECONDS); |
Uh oh!
There was an error while loading. Please reload this page.