From d0081d0de80932a1bb235ad84e3dbd533e23b9a1 Mon Sep 17 00:00:00 2001 From: Yuqi Du Date: Thu, 15 Feb 2024 09:32:46 -0800 Subject: [PATCH 1/4] add creation msg --- .../stargate/sgv2/jsonapi/exception/ErrorCode.java | 5 ++++- .../exception/mappers/ThrowableToErrorMapper.java | 7 +++++++ .../model/impl/CreateCollectionOperation.java | 12 +++++++++++- 3 files changed, 22 insertions(+), 2 deletions(-) diff --git a/src/main/java/io/stargate/sgv2/jsonapi/exception/ErrorCode.java b/src/main/java/io/stargate/sgv2/jsonapi/exception/ErrorCode.java index 172815ded0..ad83f18e88 100644 --- a/src/main/java/io/stargate/sgv2/jsonapi/exception/ErrorCode.java +++ b/src/main/java/io/stargate/sgv2/jsonapi/exception/ErrorCode.java @@ -136,7 +136,10 @@ public enum ErrorCode { INVALID_QUERY("Invalid query"), DRIVER_TIMEOUT("Driver timeout"), DRIVER_CLOSED_CONNECTION("Driver request connection is closed"), - NO_NODE_AVAILABLE("No node was available to execute the query"); + NO_NODE_AVAILABLE("No node was available to execute the query"), + NO_INDEX_ERROR( + "The collection has indexes creation failure, recommend to recreate the collection"), + COLLECTION_CREATION_ERROR("Collection creation failure, recommend to recreate the collection"); private final String message; diff --git a/src/main/java/io/stargate/sgv2/jsonapi/exception/mappers/ThrowableToErrorMapper.java b/src/main/java/io/stargate/sgv2/jsonapi/exception/mappers/ThrowableToErrorMapper.java index 5ef8793d6e..fb64a2b57b 100644 --- a/src/main/java/io/stargate/sgv2/jsonapi/exception/mappers/ThrowableToErrorMapper.java +++ b/src/main/java/io/stargate/sgv2/jsonapi/exception/mappers/ThrowableToErrorMapper.java @@ -57,6 +57,13 @@ public final class ThrowableToErrorMapper { if (message.contains("vector> executeCollectionCreation(QueryExecutor que return Uni.createFrom().item(false); } }); - return indexResult.onItem().transform(SchemaChangeResult::new); + return indexResult + .onItem() + .transform( + res -> { + if (!res) { + // table creation failure or index creation failure + return ErrorCode.COLLECTION_CREATION_ERROR.toApiException(); + } else { + return new SchemaChangeResult(true); + } + }); } /** From 234d1320fe2de35a08923f73adc02eb4cfbc9cbb Mon Sep 17 00:00:00 2001 From: Yuqi Du Date: Thu, 15 Feb 2024 13:34:35 -0800 Subject: [PATCH 2/4] fix comments --- .../java/io/stargate/sgv2/jsonapi/exception/ErrorCode.java | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/main/java/io/stargate/sgv2/jsonapi/exception/ErrorCode.java b/src/main/java/io/stargate/sgv2/jsonapi/exception/ErrorCode.java index ad83f18e88..c16f6aaa58 100644 --- a/src/main/java/io/stargate/sgv2/jsonapi/exception/ErrorCode.java +++ b/src/main/java/io/stargate/sgv2/jsonapi/exception/ErrorCode.java @@ -138,8 +138,9 @@ public enum ErrorCode { DRIVER_CLOSED_CONNECTION("Driver request connection is closed"), NO_NODE_AVAILABLE("No node was available to execute the query"), NO_INDEX_ERROR( - "The collection has indexes creation failure, recommend to recreate the collection"), - COLLECTION_CREATION_ERROR("Collection creation failure, recommend to recreate the collection"); + "Collection creation failure (unable to create indexes). Recommend re-creating the collection"), + COLLECTION_CREATION_ERROR( + "Collection creation failure (unable to create table). Recommend re-creating the collection"); private final String message; From 209c97333fe5a637a4537887bdc2cc52ff03023e Mon Sep 17 00:00:00 2001 From: Yuqi Du Date: Fri, 16 Feb 2024 16:23:06 -0800 Subject: [PATCH 3/4] fix comments --- .../java/io/stargate/sgv2/jsonapi/exception/ErrorCode.java | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/src/main/java/io/stargate/sgv2/jsonapi/exception/ErrorCode.java b/src/main/java/io/stargate/sgv2/jsonapi/exception/ErrorCode.java index c16f6aaa58..bc0c0d3292 100644 --- a/src/main/java/io/stargate/sgv2/jsonapi/exception/ErrorCode.java +++ b/src/main/java/io/stargate/sgv2/jsonapi/exception/ErrorCode.java @@ -137,8 +137,7 @@ public enum ErrorCode { DRIVER_TIMEOUT("Driver timeout"), DRIVER_CLOSED_CONNECTION("Driver request connection is closed"), NO_NODE_AVAILABLE("No node was available to execute the query"), - NO_INDEX_ERROR( - "Collection creation failure (unable to create indexes). Recommend re-creating the collection"), + NO_INDEX_ERROR("Faulty collection (missing indexes). Recommend re-creating the collection"), COLLECTION_CREATION_ERROR( "Collection creation failure (unable to create table). Recommend re-creating the collection"); From 1a402cdd6f87ac518d949049e353dd1b670db0e9 Mon Sep 17 00:00:00 2001 From: Yuqi Du Date: Tue, 20 Feb 2024 11:09:52 -0800 Subject: [PATCH 4/4] show failed createCollection collection name --- .../operation/model/impl/CreateCollectionOperation.java | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/main/java/io/stargate/sgv2/jsonapi/service/operation/model/impl/CreateCollectionOperation.java b/src/main/java/io/stargate/sgv2/jsonapi/service/operation/model/impl/CreateCollectionOperation.java index 3e6cf8ca06..344912776c 100644 --- a/src/main/java/io/stargate/sgv2/jsonapi/service/operation/model/impl/CreateCollectionOperation.java +++ b/src/main/java/io/stargate/sgv2/jsonapi/service/operation/model/impl/CreateCollectionOperation.java @@ -177,7 +177,8 @@ private Uni> executeCollectionCreation(QueryExecutor que res -> { if (!res) { // table creation failure or index creation failure - return ErrorCode.COLLECTION_CREATION_ERROR.toApiException(); + return ErrorCode.COLLECTION_CREATION_ERROR.toApiException( + "provided collection ('%s')", name); } else { return new SchemaChangeResult(true); }