[ 
https://issues.apache.org/jira/browse/PHOENIX-6776?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=17625341#comment-17625341
 ] 

ASF GitHub Bot commented on PHOENIX-6776:
-----------------------------------------

kadirozde commented on code in PR #1517:
URL: https://github.com/apache/phoenix/pull/1517#discussion_r1007397278


##########
phoenix-core/src/it/java/org/apache/phoenix/end2end/PreMatureTimelyAbortScanIt.java:
##########
@@ -0,0 +1,98 @@
+package org.apache.phoenix.end2end;
+
+import org.apache.phoenix.coprocessor.BaseScannerRegionObserver;
+import org.apache.phoenix.exception.SQLExceptionCode;
+import org.apache.phoenix.query.QueryServices;
+import org.apache.phoenix.thirdparty.com.google.common.collect.Maps;
+import org.apache.phoenix.util.ReadOnlyProps;
+import org.junit.BeforeClass;
+import org.junit.Test;
+import org.junit.experimental.categories.Category;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import java.sql.Connection;
+import java.sql.DriverManager;
+import java.sql.ResultSet;
+import java.sql.SQLException;
+import java.util.Map;
+
+import static org.junit.Assert.*;
+@Category(ParallelStatsDisabledTest.class)
+public class PreMatureTimelyAbortScanIt extends ParallelStatsDisabledIT {
+    static final Logger LOG = 
LoggerFactory.getLogger(PreMatureTimelyAbortScanIt.class);
+
+    @BeforeClass
+    public static synchronized void doSetup() throws Exception {
+        Map<String, String> props = Maps.newHashMapWithExpectedSize(1);
+        props.put(BaseScannerRegionObserver.PHOENIX_MAX_LOOKBACK_AGE_CONF_KEY, 
Integer.toString(60*60)); // An hour
+        props.put(QueryServices.USE_STATS_FOR_PARALLELIZATION, 
Boolean.toString(false));
+        props.put(QueryServices.PHOENIX_SERVER_PAGE_SIZE_MS, 
Integer.toString(0));
+        setUpTestDriver(new ReadOnlyProps(props.entrySet().iterator()));
+    }
+
+    private String getUniqueUrl() {
+        return url + generateUniqueName();
+    }
+
+    @Test
+    public void testPreMatureScannerAbortForCount() throws Exception {
+
+        try (Connection conn = DriverManager.getConnection(getUniqueUrl())) {
+            conn.createStatement().execute("CREATE TABLE LONG_BUG (ID INTEGER 
PRIMARY KEY, AMOUNT DECIMAL)");
+        }
+        try (Connection conn = DriverManager.getConnection(getUniqueUrl())) {
+            for (int i = 0; i<500000 ; i++) {
+                int amount = -50000 + i;
+                String s = "UPSERT INTO LONG_BUG (ID, AMOUNT) VALUES( " + i + 
", " + amount + ")";
+                conn.createStatement().execute(s);
+                conn.commit();
+            }
+        }
+
+        try {
+            Connection conn = DriverManager.getConnection(getUniqueUrl());
+            Runnable runnable = new Runnable() {
+                @Override
+                public void run() {
+                    try {
+                        ResultSet resultSet = 
conn.createStatement().executeQuery(

Review Comment:
   @lokiore, in general we do not want to use thread sleep as we can only guess 
the required sleep time and it changes from one system to another. This can 
make the test flapping. You can implement this test without having threads. In 
PhoenixConnection, you can define a testing only method to set the connection 
state to closing. After getting the connection, set the connection state 
closing using this method. Then you run the test code without creating threads 
and without closing the connection.





> Abort scans of closed connections at ScanningResultIterator
> -----------------------------------------------------------
>
>                 Key: PHOENIX-6776
>                 URL: https://issues.apache.org/jira/browse/PHOENIX-6776
>             Project: Phoenix
>          Issue Type: Improvement
>            Reporter: Kadir Ozdemir
>            Assignee: Lokesh Khurana
>            Priority: Major
>
> The server side paging feature introduced by PHOENIX-6211 breaks a scan into 
> timed scan operations on the server side and returns an intermediate result 
> for each operation. This intermediate result could be a valid result or a 
> dummy result. The HBase scans are wrapped by ScanningResultIterator in 
> Phoenix. If the next call on a scan returns a dummy or empty result, 
> ScanningResultIterator ignores this result and call the next method on the 
> scan again. However, if the Phoenix connection is closed, we should abort the 
> scan instead of continuing scanning. This will result in timely abort of 
> scans and release of resources (especially when phoenix.server.page.size.ms 
> is set to a small value, e.g., 5 sec).
>  



--
This message was sent by Atlassian Jira
(v8.20.10#820010)

Reply via email to