我是 DynamoDB 的新手,我在 JVM 中有一个本地实例正在运行,但是当我尝试创建一个定义为
GlobalSecondaryIndexUpdate stockIndex = new GlobalSecondaryIndexUpdate()
.withCreate(new CreateGlobalSecondaryIndexAction()
.withIndexName("StockIndex")
.withKeySchema(new KeySchemaElement().withAttributeName("stock").withKeyType(KeyType.RANGE), // Partition key
new KeySchemaElement().withAttributeName("date").withKeyType(KeyType.RANGE)) // Compound key?
.withProjection(new Projection().withProjectionType(projectionType)));
我得到一个未知的内部故障,例如:
Caused by: com.amazonaws.services.dynamodbv2.model.AmazonDynamoDBException: The request processing has failed because of an unknown error, exception or failure. (Service: AmazonDynamoDBv2; Status Code: 500; Error Code: InternalFailure; Request ID: dccfbf27-2e33-463c-b36e-97a432f4cd6b)
at com.amazonaws.http.AmazonHttpClient$RequestExecutor.handleErrorResponse(AmazonHttpClient.java:1588)
at com.amazonaws.http.AmazonHttpClient$RequestExecutor.executeOneRequest(AmazonHttpClient.java:1258)
at com.amazonaws.http.AmazonHttpClient$RequestExecutor.executeHelper(AmazonHttpClient.java:1030)
at com.amazonaws.http.AmazonHttpClient$RequestExecutor.doExecute(AmazonHttpClient.java:742)
at com.amazonaws.http.AmazonHttpClient$RequestExecutor.executeWithTimer(AmazonHttpClient.java:716)
at com.amazonaws.http.AmazonHttpClient$RequestExecutor.execute(AmazonHttpClient.java:699)
at com.amazonaws.http.AmazonHttpClient$RequestExecutor.access$500(AmazonHttpClient.java:667)
at com.amazonaws.http.AmazonHttpClient$RequestExecutionBuilderImpl.execute(AmazonHttpClient.java:649)
at com.amazonaws.http.AmazonHttpClient.execute(AmazonHttpClient.java:513)
at com.amazonaws.services.dynamodbv2.AmazonDynamoDBClient.doInvoke(AmazonDynamoDBClient.java:2089)
at com.amazonaws.services.dynamodbv2.AmazonDynamoDBClient.invoke(AmazonDynamoDBClient.java:2065)
at com.amazonaws.services.dynamodbv2.AmazonDynamoDBClient.executeUpdateTable(AmazonDynamoDBClient.java:1921)
尝试创建 GSI 时。我定义的索引是错误的,还是 DynamoDB Local 不支持?
2018 年 7 月 30 日更新:
我测试使用:
// StockIndex
GlobalSecondaryIndexUpdate stockIndex = new GlobalSecondaryIndexUpdate()
.withCreate(new CreateGlobalSecondaryIndexAction()
.withIndexName("StockIndex")
.withKeySchema(
new KeySchemaElement().withAttributeName("stock").withKeyType(KeyType.HASH)) // Partition key
new KeySchemaElement().withAttributeName("date").withKeyType(KeyType.RANGE)) // Compound key?
.withProjection(new Projection().withProjectionType(ProjectionType.ALL)));
以及没有 RANGE 键date
,但两次我都得到了同样的模糊 InternalFailure
。我怀疑 DynamoDB 本地实例根本不支持 GSI(尽管使用说明中根本没有提到二级索引)