Привет, я реализую блокировку DynamoDb в моем коде.У меня есть метод, который содержит 2 идентификатора и на основе 2 идентификаторов я создаю несколько записей в таблице в DynamoDB.Я реализовал код, как показано ниже (SAMPLE CODE):
Class Test {
public void testLocking() {
String pid;
String pid2;
//creating the lock and then using it as :
AcquireLockOptions optionsMain = AcquireLockOptions.builder(pid).build();
Optional<LockItem> lockItemMain = Optional.empty();
try {
lockItemMain = lockClient.tryAcquireLock(optionsMain);
if (lockItemMain.isPresent()) {
// do some operation and store the object in dynamodb:
dynamoDBMapper.save();
} catch (LockNotGrantedException e) {
//logging.
}
finally {
if (lockItemMain.isPresent()) {
logger.debug("Releasing the lock 1 :: ");
boolean status = lockClient.releaseLock(lockItemMain.get());
logger.info(LOCK_STATUS_STRING, status);
}
}
}
AcquireLockOptions optionsTemp = AcquireLockOptions.builder(pid2).build();
Optional<LockItem> lockItemTemp = Optional.empty();
try {
lockItemTemp = lockClient.tryAcquireLock(optionsTemp);
if (lockItemTemp.isPresent()) {
// do some operation and store the object in dynamodb:
dynamoDBMapper.save();
} catch (LockNotGrantedException e) {
//logging.
}
finally {
if (lockItemTemp.isPresent()) {
logger.debug("Releasing the lock 2 :: ");
boolean status = lockClient.releaseLock(lockItemTemp.get());
logger.info(LOCK_STATUS_STRING, status);
}
}
}
}
}
Когда этот код запускается, я вижу, что первая блокировка успешно освобождается, а запись для нее удаляется из таблицы блокировок.Но когда он собирается освободить 2-ю блокировку, происходит сбой за исключением:
com.amazonaws.AbortedException: at com.amazonaws.internal.SdkFilterInputStream.abortIfNeeded (SdkFilterInputStream.java:53) ~ [application.jar :?] в com.amazonaws.internal.SdkFilterInputStream.markSupported (SdkFilterInputStream.java:117) ~ [application.jar :?] в com.amazonaws.http.AmazonHttpClient $ RequestExecutor.executeHelper: Amazonjavap: () AmazonH~ [application.jar :?] на com.amazonaws.http.AmazonHttpClient $ RequestExecutor.doExecute (AmazonHttpClient.java:745) ~ [application.jar :?] на com.amazonaws.http.AmazonHttpClient $ RequestExecutor.executeHithpith (.java: 719) ~ [application.jar :?] на com.amazonaws.http.AmazonHttpClient $ RequestExecutor.execute (AmazonHttpClient.java:701) ~ [application.jar :?] на com.amazonaws.http.AmazonHttpClient $ RequestExecutor.доступ к $ 500 (AmazonHttpClient.java:669) ~ [application.jar :?] на com.amazonaws.http.AmazonHttpClient $ RequestExecutionBuilderImpl.exeмилый (AmazonHttpClient.java:651) ~ [application.jar :?] в com.amazonaws.http.AmazonHttpClient.execute (AmazonHttpClient.java:515) ~ [application.jar :?] в com.amazonaws.services.dynamodbv2.AmazonDynamoDBClient.doInvoke (AmazonDynamoDBClient.java:3609) |services.dynamodbv2.AmazonDynamoDBClient.invoke (AmazonDynamoDBClient.java:3567) ~ [application.jar :?] at com.amazonaws.services.dynamodbv2.AmazonDynamoDBClient.executeDeleteItem (AmazonDynamoDBClient.java.11: 11: 11)com.amazonaws.services.dynamodbv2.AmazonDynamoDBClient.deleteItem (AmazonDynamoDBClient.java:1132) ~ [application.jar :?] at com.amazonaws.services.dynamodbv2.AmazonDynamoDBLockClient.releaseLock (AmazonDynamjjLjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjj) [):?] at com.amazonaws.services.dynamodbv2.AmazonDynamoDBLockClient.releaseLock (AmazonDynamoDBLockClient.java:581) ~ [application.jar:?]
Невозможно выяснить причину.Любые выводы будут оценены!Благодаря.