You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@phoenix.apache.org by GitBox <gi...@apache.org> on 2020/10/13 13:27:15 UTC

[GitHub] [phoenix] virajjasani opened a new pull request #919: PHOENIX-6185 : Propagate info available in SQLExceptionInfo to OPERATION_TIMED_OUT

virajjasani opened a new pull request #919:
URL: https://github.com/apache/phoenix/pull/919


   


----------------------------------------------------------------
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.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [phoenix] shahrs87 commented on a change in pull request #919: PHOENIX-6185 : Propagate info available in SQLExceptionInfo to SQLTimeoutException

Posted by GitBox <gi...@apache.org>.
shahrs87 commented on a change in pull request #919:
URL: https://github.com/apache/phoenix/pull/919#discussion_r505733497



##########
File path: phoenix-core/src/it/java/org/apache/phoenix/end2end/OperationTimeoutWithReasonIT.java
##########
@@ -0,0 +1,98 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.phoenix.end2end;
+
+import org.apache.phoenix.util.EnvironmentEdge;
+import org.apache.phoenix.util.EnvironmentEdgeManager;
+import org.junit.Test;
+
+import java.sql.Connection;
+import java.sql.DriverManager;
+import java.sql.PreparedStatement;
+import java.sql.ResultSet;
+import java.sql.SQLException;
+import java.sql.Statement;
+
+import static org.apache.phoenix.exception.SQLExceptionCode.OPERATION_TIMED_OUT;
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertTrue;
+import static org.junit.Assert.fail;
+
+public class OperationTimeoutWithReasonIT extends ParallelStatsDisabledIT {
+
+    private static final class MyClock extends EnvironmentEdge {
+        private long time;
+        private final long delay;
+
+        public MyClock (long time, long delay) {
+            this.time = time;
+            this.delay = delay;
+        }
+
+        @Override
+        public long currentTime() {
+            long currentTime = this.time;
+            this.time += this.delay;
+            return currentTime;
+        }
+    }
+
+    @Test
+    public void testOperationTimeout() throws SQLException {
+        final String tableName = generateUniqueName();
+        final String ddl = "CREATE TABLE " + tableName
+            + " (COL1 VARCHAR NOT NULL PRIMARY KEY, COL2 VARCHAR)";
+        try (Connection conn = DriverManager.getConnection(getUrl());
+                 Statement stmt = conn.createStatement()) {
+            stmt.execute(ddl);
+            final String dml = String.format("UPSERT INTO %s VALUES (?, ?)",
+                tableName);
+            try(PreparedStatement prepStmt = conn.prepareStatement(dml)) {
+                for (int i = 1; i <= 100; i++) {
+                    prepStmt.setString(1, "key" + i);
+                    prepStmt.setString(2, "value" + i);
+                    prepStmt.executeUpdate();
+                }
+            }
+            conn.commit();
+        }
+
+        try (Connection conn = DriverManager.getConnection(getUrl());
+             Statement stmt = conn.createStatement()) {
+            stmt.setQueryTimeout(5); // 5 sec
+            ResultSet rs = stmt.executeQuery(String.format("SELECT * FROM %s",
+                tableName));
+            // Use custom EnvironmentEdge to timeout query with a longer delay in ms
+            MyClock clock = new MyClock(10, 10000);
+            EnvironmentEdgeManager.injectEdge(clock);
+            try {
+                rs.next();
+                fail();
+            } catch (SQLException e) {
+                assertEquals(OPERATION_TIMED_OUT.getErrorCode(),
+                    e.getErrorCode());
+                assertTrue(e.getMessage().contains("Query couldn't be " +
+                    "completed in the allotted time: 5000 ms"));

Review comment:
       @virajjasani  Can we just write a unit test creating OPERATION_TIMED_OUT exception with custom message and custom fake exception. Ideally we wouldn't even need integration test but the test that you wrote is very nice.




----------------------------------------------------------------
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.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [phoenix] virajjasani commented on pull request #919: PHOENIX-6185 : Propagate info available in SQLExceptionInfo to SQLTimeoutException

Posted by GitBox <gi...@apache.org>.
virajjasani commented on pull request #919:
URL: https://github.com/apache/phoenix/pull/919#issuecomment-708173899


   It's strange that build data is not available on ci-hadoop. Perhaps some clearn up took place?


----------------------------------------------------------------
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.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [phoenix] shahrs87 commented on a change in pull request #919: PHOENIX-6185 : Propagate info available in SQLExceptionInfo to SQLTimeoutException

Posted by GitBox <gi...@apache.org>.
shahrs87 commented on a change in pull request #919:
URL: https://github.com/apache/phoenix/pull/919#discussion_r505624689



##########
File path: phoenix-core/src/main/java/org/apache/phoenix/exception/SQLExceptionCode.java
##########
@@ -453,8 +453,13 @@ public SQLException newException(SQLExceptionInfo info) {
     OPERATION_TIMED_OUT(6000, "TIM01", "Operation timed out.", new Factory() {
         @Override
         public SQLException newException(SQLExceptionInfo info) {
-            return new SQLTimeoutException(OPERATION_TIMED_OUT.getMessage(),
-                    OPERATION_TIMED_OUT.getSQLState(), OPERATION_TIMED_OUT.getErrorCode());
+            final String reason =
+                (info.getMessage() != null ? info.getMessage() : "")

Review comment:
       > info.getMessage() != null ? info.getMessage() : ""
   
   In else condition, can we use OPERATION_TIMED_OUT.getMessage(). Atleast we will know it was operation timed out.
   




----------------------------------------------------------------
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.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [phoenix] virajjasani commented on pull request #919: PHOENIX-6185 : Propagate info available in SQLExceptionInfo to SQLTimeoutException

Posted by GitBox <gi...@apache.org>.
virajjasani commented on pull request #919:
URL: https://github.com/apache/phoenix/pull/919#issuecomment-709390900


   @gjacoby126 checkstyle is fixed, should be visible in next build. This applies directly to 4.x. Would you like me to create 4.x PR?


----------------------------------------------------------------
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.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [phoenix] stoty commented on pull request #919: PHOENIX-6185 : Propagate info available in SQLExceptionInfo to SQLTimeoutException

Posted by GitBox <gi...@apache.org>.
stoty commented on pull request #919:
URL: https://github.com/apache/phoenix/pull/919#issuecomment-709496926


   :broken_heart: **-1 overall**
   
   
   
   
   
   
   | Vote | Subsystem | Runtime | Comment |
   |:----:|----------:|--------:|:--------|
   | +0 :ok: |  reexec  |   0m 30s |  Docker mode activated.  |
   ||| _ Prechecks _ |
   | +1 :green_heart: |  dupname  |   0m  0s |  No case conflicting files found.  |
   | +1 :green_heart: |  hbaseanti  |   0m  0s |  Patch does not have any anti-patterns.  |
   | +1 :green_heart: |  @author  |   0m  1s |  The patch does not contain any @author tags.  |
   | -1 :x: |  test4tests  |   0m  0s |  The patch doesn't appear to include any new or modified tests. Please justify why no new tests are needed for this patch. Also please list what manual steps were performed to verify this patch.  |
   ||| _ master Compile Tests _ |
   | +1 :green_heart: |  mvninstall  |  36m 31s |  master passed  |
   | +1 :green_heart: |  compile  |   0m 56s |  master passed  |
   | +1 :green_heart: |  checkstyle  |   0m 44s |  master passed  |
   | +1 :green_heart: |  javadoc  |   0m 45s |  master passed  |
   | +0 :ok: |  spotbugs  |   2m 50s |  phoenix-core in master has 973 extant spotbugs warnings.  |
   ||| _ Patch Compile Tests _ |
   | +1 :green_heart: |  mvninstall  |  32m 48s |  the patch passed  |
   | +1 :green_heart: |  compile  |   0m 52s |  the patch passed  |
   | +1 :green_heart: |  javac  |   0m 52s |  the patch passed  |
   | +1 :green_heart: |  checkstyle  |   0m 44s |  phoenix-core: The patch generated 0 new + 580 unchanged - 1 fixed = 580 total (was 581)  |
   | +1 :green_heart: |  whitespace  |   0m  0s |  The patch has no whitespace issues.  |
   | +1 :green_heart: |  javadoc  |   0m 43s |  the patch passed  |
   | +1 :green_heart: |  spotbugs  |   2m 59s |  the patch passed  |
   ||| _ Other Tests _ |
   | -1 :x: |  unit  |  94m 47s |  phoenix-core in the patch failed.  |
   | +1 :green_heart: |  asflicense  |   0m 28s |  The patch does not generate ASF License warnings.  |
   |  |   | 178m 18s |   |
   
   
   | Reason | Tests |
   |-------:|:------|
   | Failed junit tests | phoenix.end2end.UpsertSelectIT |
   |   | phoenix.end2end.ParameterizedIndexUpgradeToolIT |
   
   
   | Subsystem | Report/Notes |
   |----------:|:-------------|
   | Docker | ClientAPI=1.40 ServerAPI=1.40 base: https://ci-hadoop.apache.org/job/Phoenix/job/Phoenix-PreCommit-GitHub-PR/job/PR-919/3/artifact/yetus-general-check/output/Dockerfile |
   | GITHUB PR | https://github.com/apache/phoenix/pull/919 |
   | Optional Tests | dupname asflicense javac javadoc unit spotbugs hbaseanti checkstyle compile |
   | uname | Linux 88d54f4246cb 4.15.0-112-generic #113-Ubuntu SMP Thu Jul 9 23:41:39 UTC 2020 x86_64 x86_64 x86_64 GNU/Linux |
   | Build tool | maven |
   | Personality | dev/phoenix-personality.sh |
   | git revision | master / fe7c46c |
   | Default Java | Private Build-1.8.0_242-8u242-b08-0ubuntu3~16.04-b08 |
   | unit | https://ci-hadoop.apache.org/job/Phoenix/job/Phoenix-PreCommit-GitHub-PR/job/PR-919/3/artifact/yetus-general-check/output/patch-unit-phoenix-core.txt |
   |  Test Results | https://ci-hadoop.apache.org/job/Phoenix/job/Phoenix-PreCommit-GitHub-PR/job/PR-919/3/testReport/ |
   | Max. process+thread count | 7105 (vs. ulimit of 30000) |
   | modules | C: phoenix-core U: phoenix-core |
   | Console output | https://ci-hadoop.apache.org/job/Phoenix/job/Phoenix-PreCommit-GitHub-PR/job/PR-919/3/console |
   | versions | git=2.7.4 maven=3.3.9 spotbugs=4.1.3 |
   | Powered by | Apache Yetus 0.12.0 https://yetus.apache.org |
   
   
   This message was automatically generated.
   
   


----------------------------------------------------------------
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.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [phoenix] shahrs87 commented on a change in pull request #919: PHOENIX-6185 : Propagate info available in SQLExceptionInfo to SQLTimeoutException

Posted by GitBox <gi...@apache.org>.
shahrs87 commented on a change in pull request #919:
URL: https://github.com/apache/phoenix/pull/919#discussion_r505624689



##########
File path: phoenix-core/src/main/java/org/apache/phoenix/exception/SQLExceptionCode.java
##########
@@ -453,8 +453,13 @@ public SQLException newException(SQLExceptionInfo info) {
     OPERATION_TIMED_OUT(6000, "TIM01", "Operation timed out.", new Factory() {
         @Override
         public SQLException newException(SQLExceptionInfo info) {
-            return new SQLTimeoutException(OPERATION_TIMED_OUT.getMessage(),
-                    OPERATION_TIMED_OUT.getSQLState(), OPERATION_TIMED_OUT.getErrorCode());
+            final String reason =
+                (info.getMessage() != null ? info.getMessage() : "")

Review comment:
       > info.getMessage() != null ? info.getMessage() : ""
   
   In else block, can we use OPERATION_TIMED_OUT.getMessage(). Atleast we will know it was operation timed out.
   




----------------------------------------------------------------
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.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [phoenix] stoty commented on pull request #919: PHOENIX-6185 : Propagate info available in SQLExceptionInfo to SQLTimeoutException

Posted by GitBox <gi...@apache.org>.
stoty commented on pull request #919:
URL: https://github.com/apache/phoenix/pull/919#issuecomment-709605600


   :broken_heart: **-1 overall**
   
   
   
   
   
   
   | Vote | Subsystem | Runtime | Comment |
   |:----:|----------:|--------:|:--------|
   | +0 :ok: |  reexec  |   0m 31s |  Docker mode activated.  |
   ||| _ Prechecks _ |
   | +1 :green_heart: |  dupname  |   0m  0s |  No case conflicting files found.  |
   | +1 :green_heart: |  hbaseanti  |   0m  0s |  Patch does not have any anti-patterns.  |
   | +1 :green_heart: |  @author  |   0m  0s |  The patch does not contain any @author tags.  |
   | +1 :green_heart: |  test4tests  |   0m  0s |  The patch appears to include 1 new or modified test files.  |
   ||| _ master Compile Tests _ |
   | -1 :x: |  mvninstall  |  36m 51s |  root in master failed.  |
   | +1 :green_heart: |  compile  |   0m 56s |  master passed  |
   | +1 :green_heart: |  checkstyle  |   0m 44s |  master passed  |
   | +1 :green_heart: |  javadoc  |   0m 42s |  master passed  |
   | +0 :ok: |  spotbugs  |   2m 54s |  phoenix-core in master has 973 extant spotbugs warnings.  |
   ||| _ Patch Compile Tests _ |
   | -1 :x: |  mvninstall  |  32m 52s |  root in the patch failed.  |
   | +1 :green_heart: |  compile  |   0m 54s |  the patch passed  |
   | +1 :green_heart: |  javac  |   0m 54s |  the patch passed  |
   | +1 :green_heart: |  checkstyle  |   0m 44s |  phoenix-core: The patch generated 0 new + 580 unchanged - 1 fixed = 580 total (was 581)  |
   | +1 :green_heart: |  whitespace  |   0m  0s |  The patch has no whitespace issues.  |
   | +1 :green_heart: |  javadoc  |   0m 44s |  the patch passed  |
   | +1 :green_heart: |  spotbugs  |   3m  0s |  the patch passed  |
   ||| _ Other Tests _ |
   | -1 :x: |  unit  |  95m 22s |  phoenix-core in the patch failed.  |
   | +1 :green_heart: |  asflicense  |   0m 22s |  The patch does not generate ASF License warnings.  |
   |  |   | 179m  9s |   |
   
   
   | Subsystem | Report/Notes |
   |----------:|:-------------|
   | Docker | ClientAPI=1.40 ServerAPI=1.40 base: https://ci-hadoop.apache.org/job/Phoenix/job/Phoenix-PreCommit-GitHub-PR/job/PR-919/5/artifact/yetus-general-check/output/Dockerfile |
   | GITHUB PR | https://github.com/apache/phoenix/pull/919 |
   | Optional Tests | dupname asflicense javac javadoc unit spotbugs hbaseanti checkstyle compile |
   | uname | Linux 9c7dffc0a44f 4.15.0-112-generic #113-Ubuntu SMP Thu Jul 9 23:41:39 UTC 2020 x86_64 x86_64 x86_64 GNU/Linux |
   | Build tool | maven |
   | Personality | dev/phoenix-personality.sh |
   | git revision | master / 628fa0d |
   | Default Java | Private Build-1.8.0_242-8u242-b08-0ubuntu3~16.04-b08 |
   | mvninstall | https://ci-hadoop.apache.org/job/Phoenix/job/Phoenix-PreCommit-GitHub-PR/job/PR-919/5/artifact/yetus-general-check/output/branch-mvninstall-root.txt |
   | mvninstall | https://ci-hadoop.apache.org/job/Phoenix/job/Phoenix-PreCommit-GitHub-PR/job/PR-919/5/artifact/yetus-general-check/output/patch-mvninstall-root.txt |
   | unit | https://ci-hadoop.apache.org/job/Phoenix/job/Phoenix-PreCommit-GitHub-PR/job/PR-919/5/artifact/yetus-general-check/output/patch-unit-phoenix-core.txt |
   |  Test Results | https://ci-hadoop.apache.org/job/Phoenix/job/Phoenix-PreCommit-GitHub-PR/job/PR-919/5/testReport/ |
   | Max. process+thread count | 6912 (vs. ulimit of 30000) |
   | modules | C: phoenix-core U: phoenix-core |
   | Console output | https://ci-hadoop.apache.org/job/Phoenix/job/Phoenix-PreCommit-GitHub-PR/job/PR-919/5/console |
   | versions | git=2.7.4 maven=3.3.9 spotbugs=4.1.3 |
   | Powered by | Apache Yetus 0.12.0 https://yetus.apache.org |
   
   
   This message was automatically generated.
   
   


----------------------------------------------------------------
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.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [phoenix] virajjasani commented on a change in pull request #919: PHOENIX-6185 : Propagate info available in SQLExceptionInfo to SQLTimeoutException

Posted by GitBox <gi...@apache.org>.
virajjasani commented on a change in pull request #919:
URL: https://github.com/apache/phoenix/pull/919#discussion_r505755842



##########
File path: phoenix-core/src/it/java/org/apache/phoenix/end2end/OperationTimeoutWithReasonIT.java
##########
@@ -0,0 +1,98 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.phoenix.end2end;
+
+import org.apache.phoenix.util.EnvironmentEdge;
+import org.apache.phoenix.util.EnvironmentEdgeManager;
+import org.junit.Test;
+
+import java.sql.Connection;
+import java.sql.DriverManager;
+import java.sql.PreparedStatement;
+import java.sql.ResultSet;
+import java.sql.SQLException;
+import java.sql.Statement;
+
+import static org.apache.phoenix.exception.SQLExceptionCode.OPERATION_TIMED_OUT;
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertTrue;
+import static org.junit.Assert.fail;
+
+public class OperationTimeoutWithReasonIT extends ParallelStatsDisabledIT {
+
+    private static final class MyClock extends EnvironmentEdge {
+        private long time;
+        private final long delay;
+
+        public MyClock (long time, long delay) {
+            this.time = time;
+            this.delay = delay;
+        }
+
+        @Override
+        public long currentTime() {
+            long currentTime = this.time;
+            this.time += this.delay;
+            return currentTime;
+        }
+    }
+
+    @Test
+    public void testOperationTimeout() throws SQLException {
+        final String tableName = generateUniqueName();
+        final String ddl = "CREATE TABLE " + tableName
+            + " (COL1 VARCHAR NOT NULL PRIMARY KEY, COL2 VARCHAR)";
+        try (Connection conn = DriverManager.getConnection(getUrl());
+                 Statement stmt = conn.createStatement()) {
+            stmt.execute(ddl);
+            final String dml = String.format("UPSERT INTO %s VALUES (?, ?)",
+                tableName);
+            try(PreparedStatement prepStmt = conn.prepareStatement(dml)) {
+                for (int i = 1; i <= 100; i++) {
+                    prepStmt.setString(1, "key" + i);
+                    prepStmt.setString(2, "value" + i);
+                    prepStmt.executeUpdate();
+                }
+            }
+            conn.commit();
+        }
+
+        try (Connection conn = DriverManager.getConnection(getUrl());
+             Statement stmt = conn.createStatement()) {
+            stmt.setQueryTimeout(5); // 5 sec
+            ResultSet rs = stmt.executeQuery(String.format("SELECT * FROM %s",
+                tableName));
+            // Use custom EnvironmentEdge to timeout query with a longer delay in ms
+            MyClock clock = new MyClock(10, 10000);
+            EnvironmentEdgeManager.injectEdge(clock);
+            try {
+                rs.next();
+                fail();
+            } catch (SQLException e) {
+                assertEquals(OPERATION_TIMED_OUT.getErrorCode(),
+                    e.getErrorCode());
+                assertTrue(e.getMessage().contains("Query couldn't be " +
+                    "completed in the allotted time: 5000 ms"));

Review comment:
       Done. Let's keep both unit and IT.
   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.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [phoenix] virajjasani commented on a change in pull request #919: PHOENIX-6185 : Propagate info available in SQLExceptionInfo to SQLTimeoutException

Posted by GitBox <gi...@apache.org>.
virajjasani commented on a change in pull request #919:
URL: https://github.com/apache/phoenix/pull/919#discussion_r505759040



##########
File path: phoenix-core/src/test/java/org/apache/phoenix/util/SQLExceptionCodeTest.java
##########
@@ -0,0 +1,59 @@
+/*
+ *  Licensed to the Apache Software Foundation (ASF) under one or more
+ *  contributor license agreements.  See the NOTICE file distributed with
+ *  this work for additional information regarding copyright ownership.
+ *  The ASF licenses this file to You under the Apache License, Version 2.0
+ *  (the "License"); you may not use this file except in compliance with
+ *  the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *  Unless required by applicable law or agreed to in writing, software
+ *  distributed under the License is distributed on an "AS IS" BASIS,
+ *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ *  See the License for the specific language governing permissions and
+ *  limitations under the License.
+ */
+
+package org.apache.phoenix.util;
+
+import com.sun.javaws.exceptions.InvalidArgumentException;

Review comment:
       Oh, I actually meant `IllegalArgumentException`, let me change 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.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [phoenix] gjacoby126 merged pull request #919: PHOENIX-6185 : Propagate info available in SQLExceptionInfo to SQLTimeoutException

Posted by GitBox <gi...@apache.org>.
gjacoby126 merged pull request #919:
URL: https://github.com/apache/phoenix/pull/919


   


----------------------------------------------------------------
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.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [phoenix] virajjasani commented on a change in pull request #919: PHOENIX-6185 : Propagate info available in SQLExceptionInfo to SQLTimeoutException

Posted by GitBox <gi...@apache.org>.
virajjasani commented on a change in pull request #919:
URL: https://github.com/apache/phoenix/pull/919#discussion_r505730341



##########
File path: phoenix-core/src/it/java/org/apache/phoenix/end2end/OperationTimeoutWithReasonIT.java
##########
@@ -0,0 +1,98 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.phoenix.end2end;
+
+import org.apache.phoenix.util.EnvironmentEdge;
+import org.apache.phoenix.util.EnvironmentEdgeManager;
+import org.junit.Test;
+
+import java.sql.Connection;
+import java.sql.DriverManager;
+import java.sql.PreparedStatement;
+import java.sql.ResultSet;
+import java.sql.SQLException;
+import java.sql.Statement;
+
+import static org.apache.phoenix.exception.SQLExceptionCode.OPERATION_TIMED_OUT;
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertTrue;
+import static org.junit.Assert.fail;
+
+public class OperationTimeoutWithReasonIT extends ParallelStatsDisabledIT {
+
+    private static final class MyClock extends EnvironmentEdge {
+        private long time;
+        private final long delay;
+
+        public MyClock (long time, long delay) {
+            this.time = time;
+            this.delay = delay;
+        }
+
+        @Override
+        public long currentTime() {
+            long currentTime = this.time;
+            this.time += this.delay;
+            return currentTime;
+        }
+    }
+
+    @Test
+    public void testOperationTimeout() throws SQLException {
+        final String tableName = generateUniqueName();
+        final String ddl = "CREATE TABLE " + tableName
+            + " (COL1 VARCHAR NOT NULL PRIMARY KEY, COL2 VARCHAR)";
+        try (Connection conn = DriverManager.getConnection(getUrl());
+                 Statement stmt = conn.createStatement()) {
+            stmt.execute(ddl);
+            final String dml = String.format("UPSERT INTO %s VALUES (?, ?)",
+                tableName);
+            try(PreparedStatement prepStmt = conn.prepareStatement(dml)) {
+                for (int i = 1; i <= 100; i++) {
+                    prepStmt.setString(1, "key" + i);
+                    prepStmt.setString(2, "value" + i);
+                    prepStmt.executeUpdate();
+                }
+            }
+            conn.commit();
+        }
+
+        try (Connection conn = DriverManager.getConnection(getUrl());
+             Statement stmt = conn.createStatement()) {
+            stmt.setQueryTimeout(5); // 5 sec
+            ResultSet rs = stmt.executeQuery(String.format("SELECT * FROM %s",
+                tableName));
+            // Use custom EnvironmentEdge to timeout query with a longer delay in ms
+            MyClock clock = new MyClock(10, 10000);
+            EnvironmentEdgeManager.injectEdge(clock);
+            try {
+                rs.next();
+                fail();
+            } catch (SQLException e) {
+                assertEquals(OPERATION_TIMED_OUT.getErrorCode(),
+                    e.getErrorCode());
+                assertTrue(e.getMessage().contains("Query couldn't be " +
+                    "completed in the allotted time: 5000 ms"));

Review comment:
       Actually it is null in this case because for the test, rootCause is not provided here (BaseResultIterators):
   ```
       throw new SQLExceptionInfo.Builder(OPERATION_TIMED_OUT).setMessage(
               ". Query couldn't be completed in the allotted time: "
                       + queryTimeOut + " ms").build().buildException();
   ```
   However, I tested by manually adding rootCause and receiving on test side. Hence, it is working fine but since relevant source code does not add root cause, `e.getCause() != null` would not be true 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.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [phoenix] stoty commented on pull request #919: PHOENIX-6185 : Propagate info available in SQLExceptionInfo to SQLTimeoutException

Posted by GitBox <gi...@apache.org>.
stoty commented on pull request #919:
URL: https://github.com/apache/phoenix/pull/919#issuecomment-709384745


   :broken_heart: **-1 overall**
   
   
   
   
   
   
   | Vote | Subsystem | Runtime | Comment |
   |:----:|----------:|--------:|:--------|
   | +0 :ok: |  reexec  |  15m 44s |  Docker mode activated.  |
   ||| _ Prechecks _ |
   | +1 :green_heart: |  dupname  |   0m  0s |  No case conflicting files found.  |
   | +1 :green_heart: |  hbaseanti  |   0m  0s |  Patch does not have any anti-patterns.  |
   | +1 :green_heart: |  @author  |   0m  0s |  The patch does not contain any @author tags.  |
   | -1 :x: |  test4tests  |   0m  0s |  The patch doesn't appear to include any new or modified tests. Please justify why no new tests are needed for this patch. Also please list what manual steps were performed to verify this patch.  |
   ||| _ master Compile Tests _ |
   | +1 :green_heart: |  mvninstall  |  57m 59s |  master passed  |
   | +1 :green_heart: |  compile  |   1m 27s |  master passed  |
   | +1 :green_heart: |  checkstyle  |   0m 58s |  master passed  |
   | +1 :green_heart: |  javadoc  |   1m 10s |  master passed  |
   | +0 :ok: |  spotbugs  |   5m 14s |  phoenix-core in master has 973 extant spotbugs warnings.  |
   ||| _ Patch Compile Tests _ |
   | +1 :green_heart: |  mvninstall  |  54m 59s |  the patch passed  |
   | +1 :green_heart: |  compile  |   1m 33s |  the patch passed  |
   | +1 :green_heart: |  javac  |   1m 33s |  the patch passed  |
   | -1 :x: |  checkstyle  |   1m  2s |  phoenix-core: The patch generated 3 new + 580 unchanged - 1 fixed = 583 total (was 581)  |
   | +1 :green_heart: |  whitespace  |   0m  0s |  The patch has no whitespace issues.  |
   | +1 :green_heart: |  javadoc  |   1m 15s |  the patch passed  |
   | +1 :green_heart: |  spotbugs  |   5m 43s |  the patch passed  |
   ||| _ Other Tests _ |
   | -1 :x: |  unit  | 295m 42s |  phoenix-core in the patch failed.  |
   | +1 :green_heart: |  asflicense  |   0m 36s |  The patch does not generate ASF License warnings.  |
   |  |   | 447m  0s |   |
   
   
   | Reason | Tests |
   |-------:|:------|
   | Failed junit tests | phoenix.end2end.join.HashJoinNoIndexIT |
   |   | phoenix.end2end.index.IndexMetadataIT |
   
   
   | Subsystem | Report/Notes |
   |----------:|:-------------|
   | Docker | ClientAPI=1.40 ServerAPI=1.40 base: https://ci-hadoop.apache.org/job/Phoenix/job/Phoenix-PreCommit-GitHub-PR/job/PR-919/2/artifact/yetus-general-check/output/Dockerfile |
   | GITHUB PR | https://github.com/apache/phoenix/pull/919 |
   | Optional Tests | dupname asflicense javac javadoc unit spotbugs hbaseanti checkstyle compile |
   | uname | Linux 607d8335a5d8 4.15.0-112-generic #113-Ubuntu SMP Thu Jul 9 23:41:39 UTC 2020 x86_64 x86_64 x86_64 GNU/Linux |
   | Build tool | maven |
   | Personality | dev/phoenix-personality.sh |
   | git revision | master / 5b2eeb6 |
   | Default Java | Private Build-1.8.0_242-8u242-b08-0ubuntu3~16.04-b08 |
   | checkstyle | https://ci-hadoop.apache.org/job/Phoenix/job/Phoenix-PreCommit-GitHub-PR/job/PR-919/2/artifact/yetus-general-check/output/diff-checkstyle-phoenix-core.txt |
   | unit | https://ci-hadoop.apache.org/job/Phoenix/job/Phoenix-PreCommit-GitHub-PR/job/PR-919/2/artifact/yetus-general-check/output/patch-unit-phoenix-core.txt |
   |  Test Results | https://ci-hadoop.apache.org/job/Phoenix/job/Phoenix-PreCommit-GitHub-PR/job/PR-919/2/testReport/ |
   | Max. process+thread count | 6588 (vs. ulimit of 30000) |
   | modules | C: phoenix-core U: phoenix-core |
   | Console output | https://ci-hadoop.apache.org/job/Phoenix/job/Phoenix-PreCommit-GitHub-PR/job/PR-919/2/console |
   | versions | git=2.7.4 maven=3.3.9 spotbugs=4.1.3 |
   | Powered by | Apache Yetus 0.12.0 https://yetus.apache.org |
   
   
   This message was automatically generated.
   
   


----------------------------------------------------------------
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.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [phoenix] virajjasani commented on a change in pull request #919: PHOENIX-6185 : Propagate info available in SQLExceptionInfo to SQLTimeoutException

Posted by GitBox <gi...@apache.org>.
virajjasani commented on a change in pull request #919:
URL: https://github.com/apache/phoenix/pull/919#discussion_r505730341



##########
File path: phoenix-core/src/it/java/org/apache/phoenix/end2end/OperationTimeoutWithReasonIT.java
##########
@@ -0,0 +1,98 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.phoenix.end2end;
+
+import org.apache.phoenix.util.EnvironmentEdge;
+import org.apache.phoenix.util.EnvironmentEdgeManager;
+import org.junit.Test;
+
+import java.sql.Connection;
+import java.sql.DriverManager;
+import java.sql.PreparedStatement;
+import java.sql.ResultSet;
+import java.sql.SQLException;
+import java.sql.Statement;
+
+import static org.apache.phoenix.exception.SQLExceptionCode.OPERATION_TIMED_OUT;
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertTrue;
+import static org.junit.Assert.fail;
+
+public class OperationTimeoutWithReasonIT extends ParallelStatsDisabledIT {
+
+    private static final class MyClock extends EnvironmentEdge {
+        private long time;
+        private final long delay;
+
+        public MyClock (long time, long delay) {
+            this.time = time;
+            this.delay = delay;
+        }
+
+        @Override
+        public long currentTime() {
+            long currentTime = this.time;
+            this.time += this.delay;
+            return currentTime;
+        }
+    }
+
+    @Test
+    public void testOperationTimeout() throws SQLException {
+        final String tableName = generateUniqueName();
+        final String ddl = "CREATE TABLE " + tableName
+            + " (COL1 VARCHAR NOT NULL PRIMARY KEY, COL2 VARCHAR)";
+        try (Connection conn = DriverManager.getConnection(getUrl());
+                 Statement stmt = conn.createStatement()) {
+            stmt.execute(ddl);
+            final String dml = String.format("UPSERT INTO %s VALUES (?, ?)",
+                tableName);
+            try(PreparedStatement prepStmt = conn.prepareStatement(dml)) {
+                for (int i = 1; i <= 100; i++) {
+                    prepStmt.setString(1, "key" + i);
+                    prepStmt.setString(2, "value" + i);
+                    prepStmt.executeUpdate();
+                }
+            }
+            conn.commit();
+        }
+
+        try (Connection conn = DriverManager.getConnection(getUrl());
+             Statement stmt = conn.createStatement()) {
+            stmt.setQueryTimeout(5); // 5 sec
+            ResultSet rs = stmt.executeQuery(String.format("SELECT * FROM %s",
+                tableName));
+            // Use custom EnvironmentEdge to timeout query with a longer delay in ms
+            MyClock clock = new MyClock(10, 10000);
+            EnvironmentEdgeManager.injectEdge(clock);
+            try {
+                rs.next();
+                fail();
+            } catch (SQLException e) {
+                assertEquals(OPERATION_TIMED_OUT.getErrorCode(),
+                    e.getErrorCode());
+                assertTrue(e.getMessage().contains("Query couldn't be " +
+                    "completed in the allotted time: 5000 ms"));

Review comment:
       Actually it is null in this case because for the test, rootCause is not provided here (BaseResultIterators):
   ```
       throw new SQLExceptionInfo.Builder(OPERATION_TIMED_OUT).setMessage(
               ". Query couldn't be completed in the allotted time: "
                       + queryTimeOut + " ms").build().buildException();
   ```
   However, I tested by manually adding rootCause and receiving on test side.




----------------------------------------------------------------
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.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [phoenix] virajjasani commented on a change in pull request #919: PHOENIX-6185 : Propagate info available in SQLExceptionInfo to SQLTimeoutException

Posted by GitBox <gi...@apache.org>.
virajjasani commented on a change in pull request #919:
URL: https://github.com/apache/phoenix/pull/919#discussion_r505642018



##########
File path: phoenix-core/src/main/java/org/apache/phoenix/exception/SQLExceptionCode.java
##########
@@ -453,8 +453,13 @@ public SQLException newException(SQLExceptionInfo info) {
     OPERATION_TIMED_OUT(6000, "TIM01", "Operation timed out.", new Factory() {
         @Override
         public SQLException newException(SQLExceptionInfo info) {
-            return new SQLTimeoutException(OPERATION_TIMED_OUT.getMessage(),
-                    OPERATION_TIMED_OUT.getSQLState(), OPERATION_TIMED_OUT.getErrorCode());
+            final String reason =
+                (info.getMessage() != null ? info.getMessage() : "")
+                    + (info.getRootCause() != null ? " , rootCause: "
+                    + info.getRootCause() : "");
+            return new SQLTimeoutException(reason,

Review comment:
       Done




----------------------------------------------------------------
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.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [phoenix] shahrs87 commented on a change in pull request #919: PHOENIX-6185 : Propagate info available in SQLExceptionInfo to SQLTimeoutException

Posted by GitBox <gi...@apache.org>.
shahrs87 commented on a change in pull request #919:
URL: https://github.com/apache/phoenix/pull/919#discussion_r505632721



##########
File path: phoenix-core/src/main/java/org/apache/phoenix/exception/SQLExceptionCode.java
##########
@@ -453,8 +453,13 @@ public SQLException newException(SQLExceptionInfo info) {
     OPERATION_TIMED_OUT(6000, "TIM01", "Operation timed out.", new Factory() {
         @Override
         public SQLException newException(SQLExceptionInfo info) {
-            return new SQLTimeoutException(OPERATION_TIMED_OUT.getMessage(),
-                    OPERATION_TIMED_OUT.getSQLState(), OPERATION_TIMED_OUT.getErrorCode());
+            final String reason =
+                (info.getMessage() != null ? info.getMessage() : "")
+                    + (info.getRootCause() != null ? " , rootCause: "
+                    + info.getRootCause() : "");
+            return new SQLTimeoutException(reason,

Review comment:
       Sorry missed this in my previous review.
   If there is root cause exception present, you should use this constructor to create SQLtimeoutException
   ```
   public SQLTimeoutException(String reason,
                      String SQLState,
                      int vendorCode,
                      Throwable cause)
   ```




----------------------------------------------------------------
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.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [phoenix] stoty commented on pull request #919: PHOENIX-6185 : Propagate info available in SQLExceptionInfo to SQLTimeoutException

Posted by GitBox <gi...@apache.org>.
stoty commented on pull request #919:
URL: https://github.com/apache/phoenix/pull/919#issuecomment-708038035


   :broken_heart: **-1 overall**
   
   
   
   
   
   
   | Vote | Subsystem | Runtime | Comment |
   |:----:|----------:|--------:|:--------|
   | +0 :ok: |  reexec  |   1m  9s |  Docker mode activated.  |
   ||| _ Prechecks _ |
   | +1 :green_heart: |  dupname  |   0m  0s |  No case conflicting files found.  |
   | +1 :green_heart: |  hbaseanti  |   0m  0s |  Patch does not have any anti-patterns.  |
   | +1 :green_heart: |  @author  |   0m  0s |  The patch does not contain any @author tags.  |
   | -1 :x: |  test4tests  |   0m  0s |  The patch doesn't appear to include any new or modified tests. Please justify why no new tests are needed for this patch. Also please list what manual steps were performed to verify this patch.  |
   ||| _ master Compile Tests _ |
   | +1 :green_heart: |  mvninstall  |  45m  8s |  master passed  |
   | +1 :green_heart: |  compile  |   1m  2s |  master passed  |
   | +1 :green_heart: |  checkstyle  |   0m 39s |  master passed  |
   | +1 :green_heart: |  javadoc  |   0m 48s |  master passed  |
   | +0 :ok: |  spotbugs  |   3m  7s |  phoenix-core in master has 973 extant spotbugs warnings.  |
   ||| _ Patch Compile Tests _ |
   | +1 :green_heart: |  mvninstall  |  42m  2s |  the patch passed  |
   | +1 :green_heart: |  compile  |   0m 57s |  the patch passed  |
   | +1 :green_heart: |  javac  |   0m 57s |  the patch passed  |
   | -1 :x: |  checkstyle  |   0m 40s |  phoenix-core: The patch generated 3 new + 580 unchanged - 1 fixed = 583 total (was 581)  |
   | +1 :green_heart: |  whitespace  |   0m  0s |  The patch has no whitespace issues.  |
   | +1 :green_heart: |  javadoc  |   0m 48s |  the patch passed  |
   | +1 :green_heart: |  spotbugs  |   3m 18s |  the patch passed  |
   ||| _ Other Tests _ |
   | -1 :x: |  unit  | 123m 21s |  phoenix-core in the patch failed.  |
   | +1 :green_heart: |  asflicense  |   0m 22s |  The patch does not generate ASF License warnings.  |
   |  |   | 225m 43s |   |
   
   
   | Reason | Tests |
   |-------:|:------|
   | Failed junit tests | phoenix.end2end.UpgradeIT |
   |   | phoenix.end2end.ConcurrentMutationsExtendedIT |
   
   
   | Subsystem | Report/Notes |
   |----------:|:-------------|
   | Docker | ClientAPI=1.40 ServerAPI=1.40 base: https://ci-hadoop.apache.org/job/Phoenix/job/Phoenix-PreCommit-GitHub-PR/job/PR-919/1/artifact/yetus-general-check/output/Dockerfile |
   | GITHUB PR | https://github.com/apache/phoenix/pull/919 |
   | Optional Tests | dupname asflicense javac javadoc unit spotbugs hbaseanti checkstyle compile |
   | uname | Linux ebfb4a51b34f 4.15.0-112-generic #113-Ubuntu SMP Thu Jul 9 23:41:39 UTC 2020 x86_64 x86_64 x86_64 GNU/Linux |
   | Build tool | maven |
   | Personality | dev/phoenix-personality.sh |
   | git revision | master / b4afc08 |
   | Default Java | Private Build-1.8.0_242-8u242-b08-0ubuntu3~16.04-b08 |
   | checkstyle | https://ci-hadoop.apache.org/job/Phoenix/job/Phoenix-PreCommit-GitHub-PR/job/PR-919/1/artifact/yetus-general-check/output/diff-checkstyle-phoenix-core.txt |
   | unit | https://ci-hadoop.apache.org/job/Phoenix/job/Phoenix-PreCommit-GitHub-PR/job/PR-919/1/artifact/yetus-general-check/output/patch-unit-phoenix-core.txt |
   |  Test Results | https://ci-hadoop.apache.org/job/Phoenix/job/Phoenix-PreCommit-GitHub-PR/job/PR-919/1/testReport/ |
   | Max. process+thread count | 6152 (vs. ulimit of 30000) |
   | modules | C: phoenix-core U: phoenix-core |
   | Console output | https://ci-hadoop.apache.org/job/Phoenix/job/Phoenix-PreCommit-GitHub-PR/job/PR-919/1/console |
   | versions | git=2.7.4 maven=3.3.9 spotbugs=4.1.3 |
   | Powered by | Apache Yetus 0.12.0 https://yetus.apache.org |
   
   
   This message was automatically generated.
   
   


----------------------------------------------------------------
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.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [phoenix] virajjasani commented on pull request #919: PHOENIX-6185 : Propagate info available in SQLExceptionInfo to SQLTimeoutException

Posted by GitBox <gi...@apache.org>.
virajjasani commented on pull request #919:
URL: https://github.com/apache/phoenix/pull/919#issuecomment-708190750


   `UpgradeIT` and `ConcurrentMutationsExtendedIT` are passing locally. However, for effective checkstyle change of 2, we need build data. Will try after sometime because as of now, no new build is getting triggered.


----------------------------------------------------------------
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.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [phoenix] shahrs87 commented on a change in pull request #919: PHOENIX-6185 : Propagate info available in SQLExceptionInfo to SQLTimeoutException

Posted by GitBox <gi...@apache.org>.
shahrs87 commented on a change in pull request #919:
URL: https://github.com/apache/phoenix/pull/919#discussion_r505758010



##########
File path: phoenix-core/src/test/java/org/apache/phoenix/util/SQLExceptionCodeTest.java
##########
@@ -0,0 +1,59 @@
+/*
+ *  Licensed to the Apache Software Foundation (ASF) under one or more
+ *  contributor license agreements.  See the NOTICE file distributed with
+ *  this work for additional information regarding copyright ownership.
+ *  The ASF licenses this file to You under the Apache License, Version 2.0
+ *  (the "License"); you may not use this file except in compliance with
+ *  the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *  Unless required by applicable law or agreed to in writing, software
+ *  distributed under the License is distributed on an "AS IS" BASIS,
+ *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ *  See the License for the specific language governing permissions and
+ *  limitations under the License.
+ */
+
+package org.apache.phoenix.util;
+
+import com.sun.javaws.exceptions.InvalidArgumentException;

Review comment:
       Do we use exceptions from this package anywhere else ? Haven't come across this library. Can we add some generic exception ?




----------------------------------------------------------------
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.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [phoenix] shahrs87 commented on a change in pull request #919: PHOENIX-6185 : Propagate info available in SQLExceptionInfo to SQLTimeoutException

Posted by GitBox <gi...@apache.org>.
shahrs87 commented on a change in pull request #919:
URL: https://github.com/apache/phoenix/pull/919#discussion_r505722662



##########
File path: phoenix-core/src/it/java/org/apache/phoenix/end2end/OperationTimeoutWithReasonIT.java
##########
@@ -0,0 +1,98 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.phoenix.end2end;
+
+import org.apache.phoenix.util.EnvironmentEdge;
+import org.apache.phoenix.util.EnvironmentEdgeManager;
+import org.junit.Test;
+
+import java.sql.Connection;
+import java.sql.DriverManager;
+import java.sql.PreparedStatement;
+import java.sql.ResultSet;
+import java.sql.SQLException;
+import java.sql.Statement;
+
+import static org.apache.phoenix.exception.SQLExceptionCode.OPERATION_TIMED_OUT;
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertTrue;
+import static org.junit.Assert.fail;
+
+public class OperationTimeoutWithReasonIT extends ParallelStatsDisabledIT {
+
+    private static final class MyClock extends EnvironmentEdge {
+        private long time;
+        private final long delay;
+
+        public MyClock (long time, long delay) {
+            this.time = time;
+            this.delay = delay;
+        }
+
+        @Override
+        public long currentTime() {
+            long currentTime = this.time;
+            this.time += this.delay;
+            return currentTime;
+        }
+    }
+
+    @Test
+    public void testOperationTimeout() throws SQLException {
+        final String tableName = generateUniqueName();
+        final String ddl = "CREATE TABLE " + tableName
+            + " (COL1 VARCHAR NOT NULL PRIMARY KEY, COL2 VARCHAR)";
+        try (Connection conn = DriverManager.getConnection(getUrl());
+                 Statement stmt = conn.createStatement()) {
+            stmt.execute(ddl);
+            final String dml = String.format("UPSERT INTO %s VALUES (?, ?)",
+                tableName);
+            try(PreparedStatement prepStmt = conn.prepareStatement(dml)) {
+                for (int i = 1; i <= 100; i++) {
+                    prepStmt.setString(1, "key" + i);
+                    prepStmt.setString(2, "value" + i);
+                    prepStmt.executeUpdate();
+                }
+            }
+            conn.commit();
+        }
+
+        try (Connection conn = DriverManager.getConnection(getUrl());
+             Statement stmt = conn.createStatement()) {
+            stmt.setQueryTimeout(5); // 5 sec
+            ResultSet rs = stmt.executeQuery(String.format("SELECT * FROM %s",
+                tableName));
+            // Use custom EnvironmentEdge to timeout query with a longer delay in ms
+            MyClock clock = new MyClock(10, 10000);
+            EnvironmentEdgeManager.injectEdge(clock);
+            try {
+                rs.next();
+                fail();
+            } catch (SQLException e) {
+                assertEquals(OPERATION_TIMED_OUT.getErrorCode(),
+                    e.getErrorCode());
+                assertTrue(e.getMessage().contains("Query couldn't be " +
+                    "completed in the allotted time: 5000 ms"));

Review comment:
       Should we check that e.getCause() != null ?




----------------------------------------------------------------
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.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [phoenix] virajjasani commented on a change in pull request #919: PHOENIX-6185 : Propagate info available in SQLExceptionInfo to SQLTimeoutException

Posted by GitBox <gi...@apache.org>.
virajjasani commented on a change in pull request #919:
URL: https://github.com/apache/phoenix/pull/919#discussion_r505730341



##########
File path: phoenix-core/src/it/java/org/apache/phoenix/end2end/OperationTimeoutWithReasonIT.java
##########
@@ -0,0 +1,98 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.phoenix.end2end;
+
+import org.apache.phoenix.util.EnvironmentEdge;
+import org.apache.phoenix.util.EnvironmentEdgeManager;
+import org.junit.Test;
+
+import java.sql.Connection;
+import java.sql.DriverManager;
+import java.sql.PreparedStatement;
+import java.sql.ResultSet;
+import java.sql.SQLException;
+import java.sql.Statement;
+
+import static org.apache.phoenix.exception.SQLExceptionCode.OPERATION_TIMED_OUT;
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertTrue;
+import static org.junit.Assert.fail;
+
+public class OperationTimeoutWithReasonIT extends ParallelStatsDisabledIT {
+
+    private static final class MyClock extends EnvironmentEdge {
+        private long time;
+        private final long delay;
+
+        public MyClock (long time, long delay) {
+            this.time = time;
+            this.delay = delay;
+        }
+
+        @Override
+        public long currentTime() {
+            long currentTime = this.time;
+            this.time += this.delay;
+            return currentTime;
+        }
+    }
+
+    @Test
+    public void testOperationTimeout() throws SQLException {
+        final String tableName = generateUniqueName();
+        final String ddl = "CREATE TABLE " + tableName
+            + " (COL1 VARCHAR NOT NULL PRIMARY KEY, COL2 VARCHAR)";
+        try (Connection conn = DriverManager.getConnection(getUrl());
+                 Statement stmt = conn.createStatement()) {
+            stmt.execute(ddl);
+            final String dml = String.format("UPSERT INTO %s VALUES (?, ?)",
+                tableName);
+            try(PreparedStatement prepStmt = conn.prepareStatement(dml)) {
+                for (int i = 1; i <= 100; i++) {
+                    prepStmt.setString(1, "key" + i);
+                    prepStmt.setString(2, "value" + i);
+                    prepStmt.executeUpdate();
+                }
+            }
+            conn.commit();
+        }
+
+        try (Connection conn = DriverManager.getConnection(getUrl());
+             Statement stmt = conn.createStatement()) {
+            stmt.setQueryTimeout(5); // 5 sec
+            ResultSet rs = stmt.executeQuery(String.format("SELECT * FROM %s",
+                tableName));
+            // Use custom EnvironmentEdge to timeout query with a longer delay in ms
+            MyClock clock = new MyClock(10, 10000);
+            EnvironmentEdgeManager.injectEdge(clock);
+            try {
+                rs.next();
+                fail();
+            } catch (SQLException e) {
+                assertEquals(OPERATION_TIMED_OUT.getErrorCode(),
+                    e.getErrorCode());
+                assertTrue(e.getMessage().contains("Query couldn't be " +
+                    "completed in the allotted time: 5000 ms"));

Review comment:
       Actually it is null in this case because for the test, rootCause is not provided here (BaseResultIterators):
   ```
                               throw new SQLExceptionInfo.Builder(OPERATION_TIMED_OUT).setMessage(
                                       ". Query couldn't be completed in the allotted time: "
                                               + queryTimeOut + " ms").build().buildException();
   ```
   However, I tested by manually adding rootCause and receiving on test side.




----------------------------------------------------------------
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.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org