From 10dd58f227444bd337d48124fa0ffa0e631da661 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Wojciech=20B=C4=85czkowski?= Date: Mon, 20 Nov 2023 08:34:27 +0100 Subject: [PATCH 1/3] Add test method for empty pages Adds a test method to SimpleStatementCcmIT that checks if SimpleStatement with page size 1 correctly fetches all rows. Covers issue #254. --- .../driver/core/cql/SimpleStatementCcmIT.java | 27 +++++++++++++++++++ 1 file changed, 27 insertions(+) diff --git a/integration-tests/src/test/java/com/datastax/oss/driver/core/cql/SimpleStatementCcmIT.java b/integration-tests/src/test/java/com/datastax/oss/driver/core/cql/SimpleStatementCcmIT.java index a237c23a9ef..e59413e91be 100644 --- a/integration-tests/src/test/java/com/datastax/oss/driver/core/cql/SimpleStatementCcmIT.java +++ b/integration-tests/src/test/java/com/datastax/oss/driver/core/cql/SimpleStatementCcmIT.java @@ -367,4 +367,31 @@ public void should_use_page_size() { // Should have only fetched 10 (page size) rows. assertThat(result.remaining()).isEqualTo(10); } + + @Test + public void should_not_fail_on_empty_pages() { + SESSION_RULE + .session() + .execute( + "CREATE KEYSPACE IF NOT EXISTS ks WITH REPLICATION = {'class': 'SimpleStrategy', 'replication_factor': 1}"); + + SESSION_RULE + .session() + .execute("CREATE TABLE IF NOT EXISTS ks.t (pk int, ck int, v int, PRIMARY KEY(pk, ck))"); + + for (int i = 0; i < 50; i++) { + SESSION_RULE.session().execute("INSERT INTO ks.t(pk, ck, v) VALUES (?, ?, ?)", i, i, 15); + SESSION_RULE.session().execute("INSERT INTO ks.t(pk, ck, v) VALUES (?, ?, ?)", i, i, 32); + } + + SESSION_RULE.session().execute("INSERT INTO ks.t(pk, ck, v) VALUES (?, ?, ?)", 8, 8, 14); + SESSION_RULE.session().execute("INSERT INTO ks.t(pk, ck, v) VALUES (?, ?, ?)", 11, 11, 14); + SESSION_RULE.session().execute("INSERT INTO ks.t(pk, ck, v) VALUES (?, ?, ?)", 14, 14, 14); + + SimpleStatement st = + SimpleStatement.newInstance("SELECT * FROM ks.t WHERE v = 14 ALLOW FILTERING"); + st = st.setPageSize(1); + List allRows = SESSION_RULE.session().execute(st).all(); + assertThat(allRows.size()).isEqualTo(3); + } } From c9f3eb63f391d0838eecef11fe2a8c05d4f0fcc4 Mon Sep 17 00:00:00 2001 From: Piotr Grabowski Date: Mon, 30 Oct 2023 14:28:14 +0100 Subject: [PATCH 2/3] Properly handle empty pages in MultiPageResultSet If there are multiple empty pages consecutively, the old logic did not handle the situation correctly. Use a while loop to move past many possible empty pages. (cherry picked from commit 40da47a784fe1fa2b77a384587976e857513ea9b) --- .../oss/driver/internal/core/cql/MultiPageResultSet.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/core/src/main/java/com/datastax/oss/driver/internal/core/cql/MultiPageResultSet.java b/core/src/main/java/com/datastax/oss/driver/internal/core/cql/MultiPageResultSet.java index e80b442726d..de9d292d129 100644 --- a/core/src/main/java/com/datastax/oss/driver/internal/core/cql/MultiPageResultSet.java +++ b/core/src/main/java/com/datastax/oss/driver/internal/core/cql/MultiPageResultSet.java @@ -93,7 +93,7 @@ protected Row computeNext() { } private void maybeMoveToNextPage() { - if (!currentRows.hasNext() && currentPage.hasMorePages()) { + while (!currentRows.hasNext() && currentPage.hasMorePages()) { BlockingOperation.checkNotDriverThread(); AsyncResultSet nextPage = CompletableFutures.getUninterruptibly(currentPage.fetchNextPage()); From a06c36b0db8991b486430c469f7e2b45f4d8e580 Mon Sep 17 00:00:00 2001 From: Piotr Grabowski Date: Mon, 15 Jan 2024 16:32:26 +0100 Subject: [PATCH 3/3] Pin scylla-ccm version Use a pinned version of scylla-ccm instead of master to prevent accidental breakage of Java Driver CI. --- .github/workflows/tests@v1.yml | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/.github/workflows/tests@v1.yml b/.github/workflows/tests@v1.yml index a716c4220fc..a2f4b3b4afe 100644 --- a/.github/workflows/tests@v1.yml +++ b/.github/workflows/tests@v1.yml @@ -98,7 +98,7 @@ jobs: - name: Setup Python 3 uses: actions/setup-python@v2 with: - python-version: '3.x' + python-version: '3.11' - name: Fetch Scylla and Cassandra versions id: fetch-versions @@ -134,11 +134,11 @@ jobs: - name: Setup Python 3 uses: actions/setup-python@v2 with: - python-version: '3.x' + python-version: '3.11' - name: Setup environment run: | - pip3 install https://github.com/scylladb/scylla-ccm/archive/master.zip + pip3 install https://github.com/scylladb/scylla-ccm/archive/a93125bc6ad7dd5c9694331e89dc1fb212431ffe.zip - name: Run integration tests on Cassandra (${{ matrix.cassandra-version }}) run: mvn -B -e verify -Dccm.version=${{ matrix.cassandra-version }} -Dfmt.skip=true -Dclirr.skip=true -Danimal.sniffer.skip=true @@ -186,11 +186,11 @@ jobs: - name: Setup Python 3 uses: actions/setup-python@v2 with: - python-version: '3.x' + python-version: '3.11' - name: Setup environment run: | - pip3 install https://github.com/scylladb/scylla-ccm/archive/master.zip + pip3 install https://github.com/scylladb/scylla-ccm/archive/a93125bc6ad7dd5c9694331e89dc1fb212431ffe.zip sudo sh -c "echo 2097152 > /proc/sys/fs/aio-max-nr" - name: Run integration tests on Scylla (${{ matrix.scylla-version }}) run: mvn -B verify -Dccm.version=${{ matrix.scylla-version }} -Dccm.scylla=true -Dfmt.skip=true -Dclirr.skip=true -Danimal.sniffer.skip=true @@ -213,4 +213,4 @@ jobs: if: ${{ failure() }} with: name: ccm-logs-scylla-${{ matrix.scylla-version }} - path: /tmp/ccm*/ccm*/node*/logs/* \ No newline at end of file + path: /tmp/ccm*/ccm*/node*/logs/*