AWS Error Code: ValidationException, AWS Error Message: Consistent reads are not supported in global secondary indexes

I started using Amazon DynamoDB and had a problem with the request.

I have a Dev_Testgame1_Mail table with id as the main hash key and after three global secondary indexes,

  • fromPlayerId (Hash Key)
  • toPlayerId (hash key) + isRead (range key)
  • toPlayerId (Hash Key) + endDate (Range Key)

I have above code to execute a request,

**DynamoDBMail hashKObject = new DynamoDBMail();
            hashKObject.setToPlayerId(playerId);
Condition endDateRangeKeyCondition = new Condition();
            //endDateRangeKeyCondition.withComparisonOperator(ComparisonOperator.NULL).withAttributeValueList(new AttributeValue().withB(Utils.convertDateToByteBuffer(DateUtil.getUtcDateTime())));
            endDateRangeKeyCondition.withComparisonOperator(ComparisonOperator.NULL);

            DynamoDBQueryExpression<DynamoDBMail> queryExpression = new DynamoDBQueryExpression<DynamoDBMail>();
            queryExpression.withHashKeyValues(hashKObject).withRangeKeyCondition("endDate", endDateRangeKeyCondition);
            queryExpression.withIndexName("gsi_tp_enddt").withLimit(pageSize).withScanIndexForward(false);
            return dynamodbMapper.queryPage(DynamoDBMail.class, queryExpression, new DynamoDBMapperConfig(TableNameOverride.withTableNamePrefix(Utils.getDynamoDBTableNamePrefix(gameId, env))));**

And I get the following error:

com.amazonaws.AmazonServiceException: Status code: 400, AWS service: AmazonDynamoDBv2, AWS Request ID: GUUBV24K2O40T276R9NNN0EKB7VV4KQNSO5AEMVJF66Q9ASUAAJG, AWS Error code: non-valid secondary read error message: ValidationException

.

+3
1

queryExpression false. :

queryExpression.withConsistentRead(false);

queryExpression.setConsistentRead(false);

return dynamodbMapper.queryPage(DynamoDBMail.class, queryExpression, new DynamoDBMapperConfig(TableNameOverride.withTableNamePrefix(Utils.getDynamoDBTableNamePrefix(gameId, env))));

, , NULL RangeKeyCondition - .

+7

All Articles