From 67b0a1298e693aea6529470c1248fcb70b31465b Mon Sep 17 00:00:00 2001 From: maheshrajamani <99678631+maheshrajamani@users.noreply.github.com> Date: Wed, 10 Jan 2024 14:07:04 -0500 Subject: [PATCH 1/4] Changes to have ddl and count profiles --- .../cqldriver/executor/QueryExecutor.java | 17 +++++++++++++++++ .../service/operation/model/ReadOperation.java | 2 +- src/main/resources/application.conf | 10 +++++++++- 3 files changed, 27 insertions(+), 2 deletions(-) diff --git a/src/main/java/io/stargate/sgv2/jsonapi/service/cqldriver/executor/QueryExecutor.java b/src/main/java/io/stargate/sgv2/jsonapi/service/cqldriver/executor/QueryExecutor.java index c4071a106f..0aa337d72d 100644 --- a/src/main/java/io/stargate/sgv2/jsonapi/service/cqldriver/executor/QueryExecutor.java +++ b/src/main/java/io/stargate/sgv2/jsonapi/service/cqldriver/executor/QueryExecutor.java @@ -58,6 +58,22 @@ public Uni executeRead( .completionStage(cqlSessionCache.getSession().executeAsync(simpleStatement)); } + /** + * Execute count query with bound statement. + * + * @param simpleStatement - Simple statement with query and parameters. The table name used in the + * query must have keyspace prefixed. + * @return AsyncResultSet + */ + public Uni executeCount(SimpleStatement simpleStatement) { + simpleStatement = + simpleStatement + .setExecutionProfileName("count") + .setConsistencyLevel(operationsConfig.queriesConfig().consistency().reads()); + return Uni.createFrom() + .completionStage(cqlSessionCache.getSession().executeAsync(simpleStatement)); + } + /** * Execute vector search query with bound statement. * @@ -117,6 +133,7 @@ public Uni executeSchemaChange(SimpleStatement boundStatement) { .getSession() .executeAsync( boundStatement + .setExecutionProfileName("ddl") .setIdempotent(true) .setSerialConsistencyLevel( operationsConfig.queriesConfig().consistency().schemaChanges()))); diff --git a/src/main/java/io/stargate/sgv2/jsonapi/service/operation/model/ReadOperation.java b/src/main/java/io/stargate/sgv2/jsonapi/service/operation/model/ReadOperation.java index 8ce9521e96..df89768d89 100644 --- a/src/main/java/io/stargate/sgv2/jsonapi/service/operation/model/ReadOperation.java +++ b/src/main/java/io/stargate/sgv2/jsonapi/service/operation/model/ReadOperation.java @@ -353,7 +353,7 @@ private String extractPageStateFromResultSet(AsyncResultSet rSet) { default Uni countDocuments( QueryExecutor queryExecutor, SimpleStatement simpleStatement) { return queryExecutor - .executeRead(simpleStatement, Optional.empty(), 1) + .executeCount(simpleStatement) .onItem() .transform( rSet -> { diff --git a/src/main/resources/application.conf b/src/main/resources/application.conf index a4520eced8..bed7aebbfe 100644 --- a/src/main/resources/application.conf +++ b/src/main/resources/application.conf @@ -43,10 +43,18 @@ datastax-java-driver { show-stack-traces = true } } - basic.request.timeout = 10 seconds + basic.request.timeout = 20 seconds profiles { slow { basic.request.timeout = 30 seconds } + + ddl { + basic.request.timeout = 30 seconds + } + + count { + basic.request.timeout = 60 seconds + } } } \ No newline at end of file From d5986ba2f9235dae7bd0015a012359bb58714ce9 Mon Sep 17 00:00:00 2001 From: maheshrajamani <99678631+maheshrajamani@users.noreply.github.com> Date: Wed, 10 Jan 2024 14:10:44 -0500 Subject: [PATCH 2/4] Changes to have ddl and count profiles --- .../operation/model/impl/CountOperationTest.java | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) diff --git a/src/test/java/io/stargate/sgv2/jsonapi/service/operation/model/impl/CountOperationTest.java b/src/test/java/io/stargate/sgv2/jsonapi/service/operation/model/impl/CountOperationTest.java index bf1d620ded..3daf84721d 100644 --- a/src/test/java/io/stargate/sgv2/jsonapi/service/operation/model/impl/CountOperationTest.java +++ b/src/test/java/io/stargate/sgv2/jsonapi/service/operation/model/impl/CountOperationTest.java @@ -1,8 +1,6 @@ package io.stargate.sgv2.jsonapi.service.operation.model.impl; import static org.assertj.core.api.Assertions.assertThat; -import static org.mockito.ArgumentMatchers.any; -import static org.mockito.ArgumentMatchers.anyInt; import static org.mockito.ArgumentMatchers.eq; import static org.mockito.Mockito.mock; import static org.mockito.Mockito.when; @@ -50,7 +48,7 @@ public void countWithNoFilter() { AsyncResultSet mockResults = new MockAsyncResultSet(COUNT_RESULT_COLUMNS, rows, null); final AtomicInteger callCount = new AtomicInteger(); QueryExecutor queryExecutor = mock(QueryExecutor.class); - when(queryExecutor.executeRead(eq(stmt), any(), anyInt())) + when(queryExecutor.executeCount(eq(stmt))) .then( invocation -> { callCount.incrementAndGet(); @@ -91,7 +89,7 @@ public void countWithDynamic() { AsyncResultSet mockResults = new MockAsyncResultSet(COUNT_RESULT_COLUMNS, rows, null); final AtomicInteger callCount = new AtomicInteger(); QueryExecutor queryExecutor = mock(QueryExecutor.class); - when(queryExecutor.executeRead(eq(stmt), any(), anyInt())) + when(queryExecutor.executeCount(eq(stmt))) .then( invocation -> { callCount.incrementAndGet(); @@ -141,7 +139,7 @@ public void countWithDynamicNoMatch() { AsyncResultSet mockResults = new MockAsyncResultSet(COUNT_RESULT_COLUMNS, rows, null); final AtomicInteger callCount = new AtomicInteger(); QueryExecutor queryExecutor = mock(QueryExecutor.class); - when(queryExecutor.executeRead(eq(stmt), any(), anyInt())) + when(queryExecutor.executeCount(eq(stmt))) .then( invocation -> { callCount.incrementAndGet(); @@ -189,7 +187,7 @@ public void error() { SimpleStatement stmt = SimpleStatement.newInstance(collectionReadCql); final AtomicInteger callCount = new AtomicInteger(); QueryExecutor queryExecutor = mock(QueryExecutor.class); - when(queryExecutor.executeRead(eq(stmt), any(), anyInt())) + when(queryExecutor.executeCount(eq(stmt))) .then( invocation -> { callCount.incrementAndGet(); From f62f1cc625994156fdfefeab5886e83425b9ea9d Mon Sep 17 00:00:00 2001 From: maheshrajamani <99678631+maheshrajamani@users.noreply.github.com> Date: Wed, 10 Jan 2024 14:36:31 -0500 Subject: [PATCH 3/4] Side effect of insert many default ordering change --- .../stargate/sgv2/jsonapi/api/v1/InsertIntegrationTest.java | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/test/java/io/stargate/sgv2/jsonapi/api/v1/InsertIntegrationTest.java b/src/test/java/io/stargate/sgv2/jsonapi/api/v1/InsertIntegrationTest.java index 01b58a619d..e24244cf38 100644 --- a/src/test/java/io/stargate/sgv2/jsonapi/api/v1/InsertIntegrationTest.java +++ b/src/test/java/io/stargate/sgv2/jsonapi/api/v1/InsertIntegrationTest.java @@ -1312,7 +1312,7 @@ public void withDifferentTypes() { .post(CollectionResource.BASE_PATH, namespaceName, collectionName) .then() .statusCode(200) - .body("status.insertedIds", contains("5", 5)) + .body("status.insertedIds", containsInAnyOrder("5", 5)) .body("data", is(nullValue())) .body("errors", is(nullValue())); @@ -1398,7 +1398,7 @@ public void emptyOptionsAllowed() { .post(CollectionResource.BASE_PATH, namespaceName, collectionName) .then() .statusCode(200) - .body("status.insertedIds", contains("doc4", "doc5")) + .body("status.insertedIds", containsInAnyOrder("doc4", "doc5")) .body("data", is(nullValue())) .body("errors", is(nullValue())); } From 5b8cdf7c6cffc61184446091219f357ce8d97eeb Mon Sep 17 00:00:00 2001 From: maheshrajamani <99678631+maheshrajamani@users.noreply.github.com> Date: Wed, 10 Jan 2024 14:39:42 -0500 Subject: [PATCH 4/4] Side effect of insert many default ordering change --- .../sgv2/jsonapi/api/v1/InsertIntegrationTest.java | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/src/test/java/io/stargate/sgv2/jsonapi/api/v1/InsertIntegrationTest.java b/src/test/java/io/stargate/sgv2/jsonapi/api/v1/InsertIntegrationTest.java index e24244cf38..d7a003dcd3 100644 --- a/src/test/java/io/stargate/sgv2/jsonapi/api/v1/InsertIntegrationTest.java +++ b/src/test/java/io/stargate/sgv2/jsonapi/api/v1/InsertIntegrationTest.java @@ -1152,7 +1152,10 @@ public void orderedDuplicateDocumentNoNamespace() { "_id": "doc5", "username": "user5" } - ] + ], + "options" : { + "ordered" : true + } } } """; @@ -1188,8 +1191,7 @@ public void unordered() { "_id": "doc5", "username": "user5" } - ], - "options": { "ordered": false } + ] } } """;