You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@ignite.apache.org by "xtern (via GitHub)" <gi...@apache.org> on 2023/05/17 08:17:03 UTC
[GitHub] [ignite-3] xtern opened a new pull request, #2079: IGNITE-19278 Multiple partition scan requests return an unexpected number of rows.
xtern opened a new pull request, #2079:
URL: https://github.com/apache/ignite-3/pull/2079
(no comment)
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: notifications-unsubscribe@ignite.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [ignite-3] zstan commented on a diff in pull request #2079: IGNITE-19278 Multiple partition scan requests return an unexpected number of rows.
Posted by "zstan (via GitHub)" <gi...@apache.org>.
zstan commented on code in PR #2079:
URL: https://github.com/apache/ignite-3/pull/2079#discussion_r1197543877
##########
modules/runner/src/integrationTest/java/org/apache/ignite/internal/table/ItTableScanTest.java:
##########
@@ -336,6 +337,36 @@ public void testGetAndDeleteDuringPureTableScan() throws Exception {
);
}
+ /**
+ * Ensures that multiple consecutive scan requests with different requested rows amount
+ * return the expected total number of requested rows.
+ *
+ * @throws Exception If failed.
+ */
+ @Test
+ public void testCompositeScanRequest() throws Exception {
+ int[][] demandPairs = {{3, 1}, {1, 3}};
+
+ for (int[] input : demandPairs) {
+ List<BinaryRow> scannedRows = new ArrayList<>();
+ Publisher<BinaryRow> publisher = internalTable.scan(0, null, null, null, null, 0, null);
+ CompletableFuture<Void> scanned = new CompletableFuture<>();
+
+ Subscription subscription = subscribeToPublisher(scannedRows, publisher, scanned);
+
+ subscription.request(input[0]);
+ subscription.request(input[1]);
+
+ int total = input[0] + input[1];
+ waitForCondition(() -> scannedRows.size() == total, 10_000);
+ assertEquals(total, scannedRows.size(), "input=" + Arrays.toString(input));
+
+ // Close the publisher.
+ subscription.request(1_000);
Review Comment:
why do we need such request ? can we just cancel it here ?
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: notifications-unsubscribe@ignite.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [ignite-3] xtern commented on a diff in pull request #2079: IGNITE-19278 Multiple partition scan requests return an unexpected number of rows.
Posted by "xtern (via GitHub)" <gi...@apache.org>.
xtern commented on code in PR #2079:
URL: https://github.com/apache/ignite-3/pull/2079#discussion_r1197568730
##########
modules/runner/src/integrationTest/java/org/apache/ignite/internal/table/ItTableScanTest.java:
##########
@@ -336,6 +337,36 @@ public void testGetAndDeleteDuringPureTableScan() throws Exception {
);
}
+ /**
+ * Ensures that multiple consecutive scan requests with different requested rows amount
+ * return the expected total number of requested rows.
+ *
+ * @throws Exception If failed.
+ */
+ @Test
+ public void testCompositeScanRequest() throws Exception {
+ int[][] demandPairs = {{3, 1}, {1, 3}};
+
+ for (int[] input : demandPairs) {
+ List<BinaryRow> scannedRows = new ArrayList<>();
+ Publisher<BinaryRow> publisher = internalTable.scan(0, null, null, null, null, 0, null);
+ CompletableFuture<Void> scanned = new CompletableFuture<>();
+
+ Subscription subscription = subscribeToPublisher(scannedRows, publisher, scanned);
+
+ subscription.request(input[0]);
+ subscription.request(input[1]);
+
+ int total = input[0] + input[1];
+ waitForCondition(() -> scannedRows.size() == total, 10_000);
+ assertEquals(total, scannedRows.size(), "input=" + Arrays.toString(input));
Review Comment:
Reworked to single line condition.
##########
modules/runner/src/integrationTest/java/org/apache/ignite/internal/table/ItTableScanTest.java:
##########
@@ -336,6 +337,36 @@ public void testGetAndDeleteDuringPureTableScan() throws Exception {
);
}
+ /**
+ * Ensures that multiple consecutive scan requests with different requested rows amount
+ * return the expected total number of requested rows.
+ *
+ * @throws Exception If failed.
+ */
+ @Test
+ public void testCompositeScanRequest() throws Exception {
+ int[][] demandPairs = {{3, 1}, {1, 3}};
+
+ for (int[] input : demandPairs) {
+ List<BinaryRow> scannedRows = new ArrayList<>();
+ Publisher<BinaryRow> publisher = internalTable.scan(0, null, null, null, null, 0, null);
+ CompletableFuture<Void> scanned = new CompletableFuture<>();
+
+ Subscription subscription = subscribeToPublisher(scannedRows, publisher, scanned);
+
+ subscription.request(input[0]);
+ subscription.request(input[1]);
+
+ int total = input[0] + input[1];
+ waitForCondition(() -> scannedRows.size() == total, 10_000);
+ assertEquals(total, scannedRows.size(), "input=" + Arrays.toString(input));
Review Comment:
Reworked to single line condition, thanks.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: notifications-unsubscribe@ignite.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [ignite-3] xtern merged pull request #2079: IGNITE-19278 Multiple partition scan requests return an unexpected number of rows.
Posted by "xtern (via GitHub)" <gi...@apache.org>.
xtern merged PR #2079:
URL: https://github.com/apache/ignite-3/pull/2079
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: notifications-unsubscribe@ignite.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [ignite-3] sanpwc commented on a diff in pull request #2079: IGNITE-19278 Multiple partition scan requests return an unexpected number of rows.
Posted by "sanpwc (via GitHub)" <gi...@apache.org>.
sanpwc commented on code in PR #2079:
URL: https://github.com/apache/ignite-3/pull/2079#discussion_r1197696774
##########
modules/table/src/main/java/org/apache/ignite/internal/table/distributed/storage/InternalTableImpl.java:
##########
@@ -1408,8 +1408,12 @@ private void scanBatch(int n) {
if (binaryRows.size() < n) {
cancel();
- } else if (requestedItemsCnt.addAndGet(Math.negateExact(binaryRows.size())) > 0) {
- scanBatch(Math.min(n, INTERNAL_BATCH_SIZE));
+ } else {
+ long remaining = requestedItemsCnt.addAndGet(Math.negateExact(binaryRows.size()));
+
+ if (remaining > 0) {
+ scanBatch((int) Math.min(remaining, INTERNAL_BATCH_SIZE));
Review Comment:
I believe that it's not correct to request remaining if user specified n < INTERNAL_BATCH_SIZE, so it's actually should be `Math.min(Math.min(remaining, n), INTERNAL_BATCH_SIZE);` What do you think?
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: notifications-unsubscribe@ignite.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [ignite-3] xtern commented on a diff in pull request #2079: IGNITE-19278 Multiple partition scan requests return an unexpected number of rows.
Posted by "xtern (via GitHub)" <gi...@apache.org>.
xtern commented on code in PR #2079:
URL: https://github.com/apache/ignite-3/pull/2079#discussion_r1197557599
##########
modules/runner/src/integrationTest/java/org/apache/ignite/internal/table/ItTableScanTest.java:
##########
@@ -336,6 +337,36 @@ public void testGetAndDeleteDuringPureTableScan() throws Exception {
);
}
+ /**
+ * Ensures that multiple consecutive scan requests with different requested rows amount
+ * return the expected total number of requested rows.
+ *
+ * @throws Exception If failed.
+ */
+ @Test
+ public void testCompositeScanRequest() throws Exception {
+ int[][] demandPairs = {{3, 1}, {1, 3}};
+
+ for (int[] input : demandPairs) {
+ List<BinaryRow> scannedRows = new ArrayList<>();
+ Publisher<BinaryRow> publisher = internalTable.scan(0, null, null, null, null, 0, null);
+ CompletableFuture<Void> scanned = new CompletableFuture<>();
+
+ Subscription subscription = subscribeToPublisher(scannedRows, publisher, scanned);
+
+ subscription.request(input[0]);
+ subscription.request(input[1]);
+
+ int total = input[0] + input[1];
+ waitForCondition(() -> scannedRows.size() == total, 10_000);
+ assertEquals(total, scannedRows.size(), "input=" + Arrays.toString(input));
+
+ // Close the publisher.
+ subscription.request(1_000);
Review Comment:
Done, thanks.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: notifications-unsubscribe@ignite.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [ignite-3] xtern commented on a diff in pull request #2079: IGNITE-19278 Multiple partition scan requests return an unexpected number of rows.
Posted by "xtern (via GitHub)" <gi...@apache.org>.
xtern commented on code in PR #2079:
URL: https://github.com/apache/ignite-3/pull/2079#discussion_r1197878709
##########
modules/runner/src/integrationTest/java/org/apache/ignite/internal/table/ItTableScanTest.java:
##########
@@ -580,6 +581,34 @@ public void testPhantomReads() throws Exception {
}
}
+ /**
+ * Ensures that multiple consecutive scan requests with different requested rows amount
+ * return the expected total number of requested rows.
+ *
+ * @throws Exception If failed.
+ */
+ @Test
+ public void testCompositeScanRequest() throws Exception {
+ int[][] demandPairs = {{3, 1}, {1, 3}};
Review Comment:
Done, thanks
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: notifications-unsubscribe@ignite.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [ignite-3] zstan commented on a diff in pull request #2079: IGNITE-19278 Multiple partition scan requests return an unexpected number of rows.
Posted by "zstan (via GitHub)" <gi...@apache.org>.
zstan commented on code in PR #2079:
URL: https://github.com/apache/ignite-3/pull/2079#discussion_r1197544388
##########
modules/runner/src/integrationTest/java/org/apache/ignite/internal/table/ItTableScanTest.java:
##########
@@ -336,6 +337,36 @@ public void testGetAndDeleteDuringPureTableScan() throws Exception {
);
}
+ /**
+ * Ensures that multiple consecutive scan requests with different requested rows amount
+ * return the expected total number of requested rows.
+ *
+ * @throws Exception If failed.
+ */
+ @Test
+ public void testCompositeScanRequest() throws Exception {
+ int[][] demandPairs = {{3, 1}, {1, 3}};
+
+ for (int[] input : demandPairs) {
+ List<BinaryRow> scannedRows = new ArrayList<>();
+ Publisher<BinaryRow> publisher = internalTable.scan(0, null, null, null, null, 0, null);
+ CompletableFuture<Void> scanned = new CompletableFuture<>();
+
+ Subscription subscription = subscribeToPublisher(scannedRows, publisher, scanned);
+
+ subscription.request(input[0]);
+ subscription.request(input[1]);
+
+ int total = input[0] + input[1];
+ waitForCondition(() -> scannedRows.size() == total, 10_000);
+ assertEquals(total, scannedRows.size(), "input=" + Arrays.toString(input));
Review Comment:
we already check rows in previous line, isn`t it ?
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: notifications-unsubscribe@ignite.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [ignite-3] xtern commented on a diff in pull request #2079: IGNITE-19278 Multiple partition scan requests return an unexpected number of rows.
Posted by "xtern (via GitHub)" <gi...@apache.org>.
xtern commented on code in PR #2079:
URL: https://github.com/apache/ignite-3/pull/2079#discussion_r1197562776
##########
modules/runner/src/integrationTest/java/org/apache/ignite/internal/table/ItTableScanTest.java:
##########
@@ -336,6 +337,36 @@ public void testGetAndDeleteDuringPureTableScan() throws Exception {
);
}
+ /**
+ * Ensures that multiple consecutive scan requests with different requested rows amount
+ * return the expected total number of requested rows.
+ *
+ * @throws Exception If failed.
+ */
+ @Test
+ public void testCompositeScanRequest() throws Exception {
+ int[][] demandPairs = {{3, 1}, {1, 3}};
+
+ for (int[] input : demandPairs) {
+ List<BinaryRow> scannedRows = new ArrayList<>();
+ Publisher<BinaryRow> publisher = internalTable.scan(0, null, null, null, null, 0, null);
+ CompletableFuture<Void> scanned = new CompletableFuture<>();
+
+ Subscription subscription = subscribeToPublisher(scannedRows, publisher, scanned);
+
+ subscription.request(input[0]);
+ subscription.request(input[1]);
+
+ int total = input[0] + input[1];
+ waitForCondition(() -> scannedRows.size() == total, 10_000);
+ assertEquals(total, scannedRows.size(), "input=" + Arrays.toString(input));
Review Comment:
In the previous line, we just wait for a condition. The condition may fail.
But `assertTrue(waitForCondition(...))` will not display the actual number of rows received. Thus, I prefer to do the final check with an explicit `assertEquals(...)`. If you insist on adding `assertTrue` I can redo it.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: notifications-unsubscribe@ignite.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [ignite-3] sanpwc commented on a diff in pull request #2079: IGNITE-19278 Multiple partition scan requests return an unexpected number of rows.
Posted by "sanpwc (via GitHub)" <gi...@apache.org>.
sanpwc commented on code in PR #2079:
URL: https://github.com/apache/ignite-3/pull/2079#discussion_r1197834622
##########
modules/runner/src/integrationTest/java/org/apache/ignite/internal/table/ItTableScanTest.java:
##########
@@ -580,6 +581,34 @@ public void testPhantomReads() throws Exception {
}
}
+ /**
+ * Ensures that multiple consecutive scan requests with different requested rows amount
+ * return the expected total number of requested rows.
+ *
+ * @throws Exception If failed.
+ */
+ @Test
+ public void testCompositeScanRequest() throws Exception {
+ int[][] demandPairs = {{3, 1}, {1, 3}};
Review Comment:
Parametrized test? Up to you though.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: notifications-unsubscribe@ignite.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [ignite-3] sanpwc commented on a diff in pull request #2079: IGNITE-19278 Multiple partition scan requests return an unexpected number of rows.
Posted by "sanpwc (via GitHub)" <gi...@apache.org>.
sanpwc commented on code in PR #2079:
URL: https://github.com/apache/ignite-3/pull/2079#discussion_r1197728442
##########
modules/table/src/main/java/org/apache/ignite/internal/table/distributed/storage/InternalTableImpl.java:
##########
@@ -1408,8 +1408,12 @@ private void scanBatch(int n) {
if (binaryRows.size() < n) {
cancel();
- } else if (requestedItemsCnt.addAndGet(Math.negateExact(binaryRows.size())) > 0) {
- scanBatch(Math.min(n, INTERNAL_BATCH_SIZE));
+ } else {
+ long remaining = requestedItemsCnt.addAndGet(Math.negateExact(binaryRows.size()));
+
+ if (remaining > 0) {
+ scanBatch((int) Math.min(remaining, INTERNAL_BATCH_SIZE));
Review Comment:
Yep, you are right.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: notifications-unsubscribe@ignite.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [ignite-3] xtern commented on a diff in pull request #2079: IGNITE-19278 Multiple partition scan requests return an unexpected number of rows.
Posted by "xtern (via GitHub)" <gi...@apache.org>.
xtern commented on code in PR #2079:
URL: https://github.com/apache/ignite-3/pull/2079#discussion_r1197562776
##########
modules/runner/src/integrationTest/java/org/apache/ignite/internal/table/ItTableScanTest.java:
##########
@@ -336,6 +337,36 @@ public void testGetAndDeleteDuringPureTableScan() throws Exception {
);
}
+ /**
+ * Ensures that multiple consecutive scan requests with different requested rows amount
+ * return the expected total number of requested rows.
+ *
+ * @throws Exception If failed.
+ */
+ @Test
+ public void testCompositeScanRequest() throws Exception {
+ int[][] demandPairs = {{3, 1}, {1, 3}};
+
+ for (int[] input : demandPairs) {
+ List<BinaryRow> scannedRows = new ArrayList<>();
+ Publisher<BinaryRow> publisher = internalTable.scan(0, null, null, null, null, 0, null);
+ CompletableFuture<Void> scanned = new CompletableFuture<>();
+
+ Subscription subscription = subscribeToPublisher(scannedRows, publisher, scanned);
+
+ subscription.request(input[0]);
+ subscription.request(input[1]);
+
+ int total = input[0] + input[1];
+ waitForCondition(() -> scannedRows.size() == total, 10_000);
+ assertEquals(total, scannedRows.size(), "input=" + Arrays.toString(input));
Review Comment:
In the previous line, we just wait for a condition. The condition may fail.
But `assertTrue(waitForCondition(...))` will not display the actual number of rows received. Thus, I prefer to do the final check with an explicit `assertEquals(...)`. If you insist on adding `assertTrue` I can redo it.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: notifications-unsubscribe@ignite.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [ignite-3] xtern commented on a diff in pull request #2079: IGNITE-19278 Multiple partition scan requests return an unexpected number of rows.
Posted by "xtern (via GitHub)" <gi...@apache.org>.
xtern commented on code in PR #2079:
URL: https://github.com/apache/ignite-3/pull/2079#discussion_r1197719492
##########
modules/table/src/main/java/org/apache/ignite/internal/table/distributed/storage/InternalTableImpl.java:
##########
@@ -1408,8 +1408,12 @@ private void scanBatch(int n) {
if (binaryRows.size() < n) {
cancel();
- } else if (requestedItemsCnt.addAndGet(Math.negateExact(binaryRows.size())) > 0) {
- scanBatch(Math.min(n, INTERNAL_BATCH_SIZE));
+ } else {
+ long remaining = requestedItemsCnt.addAndGet(Math.negateExact(binaryRows.size()));
+
+ if (remaining > 0) {
+ scanBatch((int) Math.min(remaining, INTERNAL_BATCH_SIZE));
Review Comment:
No, I don't think so, RequestItemsCnt represents the number of requested rows left.
For example, user expects 513 rows total.:
```
request(1) // requestedItemsCnt=1, then call scanBatch(1)
request(512) // just set requestedItemsCnt=513, don't call scanBatch(512)
```
When the first scanBatch (n = 1) completes we have
```
n = 1 (still)
remaining = requestedItemsCnt - processed = 512
```
then (with your suggestion) we will repeat it with n = 1
```
scanBatch(Math.min(n, remaining)) = scanBatch(Math.min(1, 512)) = scanBatch(1)
```
In other worlds we'll do
```
while (remaining-- > 0)
scanBatch(n=1)
```
instead of single `scanBatch(512)`
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: notifications-unsubscribe@ignite.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [ignite-3] xtern commented on a diff in pull request #2079: IGNITE-19278 Multiple partition scan requests return an unexpected number of rows.
Posted by "xtern (via GitHub)" <gi...@apache.org>.
xtern commented on code in PR #2079:
URL: https://github.com/apache/ignite-3/pull/2079#discussion_r1197719492
##########
modules/table/src/main/java/org/apache/ignite/internal/table/distributed/storage/InternalTableImpl.java:
##########
@@ -1408,8 +1408,12 @@ private void scanBatch(int n) {
if (binaryRows.size() < n) {
cancel();
- } else if (requestedItemsCnt.addAndGet(Math.negateExact(binaryRows.size())) > 0) {
- scanBatch(Math.min(n, INTERNAL_BATCH_SIZE));
+ } else {
+ long remaining = requestedItemsCnt.addAndGet(Math.negateExact(binaryRows.size()));
+
+ if (remaining > 0) {
+ scanBatch((int) Math.min(remaining, INTERNAL_BATCH_SIZE));
Review Comment:
No, I don't think so, `requestedItemsCnt` represents the number of requested rows left.
For example, user expects 513 rows total.:
```
request(1) // requestedItemsCnt=1, then call scanBatch(1)
request(512) // just set requestedItemsCnt=513, don't call scanBatch(512)
```
When the first scanBatch (n = 1) completes we have
```
n = 1 (still)
remaining = requestedItemsCnt - processed = 512
```
then (with your suggestion) we will repeat it with n = 1
```
scanBatch(Math.min(n, remaining)) = scanBatch(Math.min(1, 512)) = scanBatch(1)
```
In other worlds we'll do
```
while (remaining-- > 0)
scanBatch(n=1)
```
instead of single `scanBatch(512)`
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: notifications-unsubscribe@ignite.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org