You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@ignite.apache.org by "korlov42 (via GitHub)" <gi...@apache.org> on 2024/12/16 11:45:52 UTC

[PR] IGNITE-24005 Sql. Rollback implicit tx when query is timed out [ignite-3]

korlov42 opened a new pull request, #4907:
URL: https://github.com/apache/ignite-3/pull/4907

   https://issues.apache.org/jira/browse/IGNITE-24005
   
   ------------
   Thank you for submitting the pull request.
   
   To streamline the review process of the patch and ensure better code quality
   we ask both an author and a reviewer to verify the following:
   
   ### The Review Checklist
   - [ ] **Formal criteria:** TC status, codestyle, mandatory documentation. Also make sure to complete the following:  
   \- There is a single JIRA ticket related to the pull request.  
   \- The web-link to the pull request is attached to the JIRA ticket.  
   \- The JIRA ticket has the Patch Available state.  
   \- The description of the JIRA ticket explains WHAT was made, WHY and HOW.  
   \- The pull request title is treated as the final commit message. The following pattern must be used: IGNITE-XXXX Change summary where XXXX - number of JIRA issue.
   - [ ] **Design:** new code conforms with the design principles of the components it is added to.
   - [ ] **Patch quality:** patch cannot be split into smaller pieces, its size must be reasonable.
   - [ ] **Code quality:** code is clean and readable, necessary developer documentation is added if needed.
   - [ ] **Tests code quality:** test set covers positive/negative scenarios, happy/edge cases. Tests are effective in terms of execution time and resources.
   
   ### Notes
   - [Apache Ignite Coding Guidelines](https://cwiki.apache.org/confluence/display/IGNITE/Java+Code+Style+Guide)


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


Re: [PR] IGNITE-24005 Sql. Rollback implicit tx when query is timed out [ignite-3]

Posted by "xtern (via GitHub)" <gi...@apache.org>.
xtern commented on code in PR #4907:
URL: https://github.com/apache/ignite-3/pull/4907#discussion_r1888843980


##########
modules/sql-engine/src/main/java/org/apache/ignite/internal/sql/engine/exec/fsm/CursorInitializationPhaseHandler.java:
##########
@@ -54,11 +55,9 @@ public Result handle(Query query) {
 
                     query.cursor = cursor;
 
-                    query.cancel.add(timeout -> {
-                        if (!timeout) {
-                            cursor.closeAsync(true);
-                        }
-                    });
+                    query.cancel.add(timeout -> dataCursor.cancelAsync(
+                            timeout ? CancellationReason.TIMEOUT : CancellationReason.CANCEL

Review Comment:
   I reread the ticket description and I want to clarify that if it is difficult to write a reproducer, then you can ignore this note.
   
   At first I thought we don't have a test for timeout that starts an implicit RW transaction.



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


Re: [PR] IGNITE-24005 Sql. Rollback implicit tx when query is timed out [ignite-3]

Posted by "korlov42 (via GitHub)" <gi...@apache.org>.
korlov42 merged PR #4907:
URL: https://github.com/apache/ignite-3/pull/4907


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


Re: [PR] IGNITE-24005 Sql. Rollback implicit tx when query is timed out [ignite-3]

Posted by "korlov42 (via GitHub)" <gi...@apache.org>.
korlov42 commented on code in PR #4907:
URL: https://github.com/apache/ignite-3/pull/4907#discussion_r1889797052


##########
modules/sql-engine/src/main/java/org/apache/ignite/internal/sql/engine/exec/fsm/CursorInitializationPhaseHandler.java:
##########
@@ -54,11 +55,9 @@ public Result handle(Query query) {
 
                     query.cursor = cursor;
 
-                    query.cancel.add(timeout -> {
-                        if (!timeout) {
-                            cursor.closeAsync(true);
-                        }
-                    });
+                    query.cancel.add(timeout -> dataCursor.cancelAsync(
+                            timeout ? CancellationReason.TIMEOUT : CancellationReason.CANCEL

Review Comment:
   > can we also remove the code that adds timeout handling in executeDdl and executeKill methods of ExecutionServiceImpl?
   
   Unfortunately, this is not only about removal from these two methods. We also need to remove according tests from `ExecutionServiceImplTest` (which is ok) and write another somewhere replacing old ones (since we would like to rely on cancellation code in one of the ExecutionPhase, new tests must involve `TestCluster`). I believe this is out of the scope of current issue. Besides, we already has [IGNITE-23792](https://issues.apache.org/jira/browse/IGNITE-23792), thus I would prefer to don't touch this part in my PR, If you don't mind.
   
   > сan we add a test that will reproduce (constantly) the issue that this patch solves?
   tbh, I have no idea how to make it to _steadily_ reproduces this race. During investigation, I just added `Thread.sleep(2)` before adding cancellation handling for cursor, but this is not acceptable to have `sleep()` in the production code for this. To make sure (kinda) that problem is gone, I've run JDBC job on TC 15 times and got no failures. For my previous patch tests had failed after ~5th iterations. 



##########
modules/sql-engine/src/main/java/org/apache/ignite/internal/sql/engine/exec/fsm/CursorInitializationPhaseHandler.java:
##########
@@ -54,11 +55,9 @@ public Result handle(Query query) {
 
                     query.cursor = cursor;
 
-                    query.cancel.add(timeout -> {
-                        if (!timeout) {
-                            cursor.closeAsync(true);
-                        }
-                    });
+                    query.cancel.add(timeout -> dataCursor.cancelAsync(
+                            timeout ? CancellationReason.TIMEOUT : CancellationReason.CANCEL

Review Comment:
   > can we also remove the code that adds timeout handling in executeDdl and executeKill methods of ExecutionServiceImpl?
   
   Unfortunately, this is not only about removal from these two methods. We also need to remove according tests from `ExecutionServiceImplTest` (which is ok) and write another somewhere replacing old ones (since we would like to rely on cancellation code in one of the ExecutionPhase, new tests must involve `TestCluster`). I believe this is out of the scope of current issue. Besides, we already has [IGNITE-23792](https://issues.apache.org/jira/browse/IGNITE-23792), thus I would prefer to don't touch this part in my PR, If you don't mind.
   
   > сan we add a test that will reproduce (constantly) the issue that this patch solves?
   
   tbh, I have no idea how to make it to _steadily_ reproduces this race. During investigation, I just added `Thread.sleep(2)` before adding cancellation handling for cursor, but this is not acceptable to have `sleep()` in the production code for this. To make sure (kinda) that problem is gone, I've run JDBC job on TC 15 times and got no failures. For my previous patch tests had failed after ~5th iterations. 



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


Re: [PR] IGNITE-24005 Sql. Rollback implicit tx when query is timed out [ignite-3]

Posted by "korlov42 (via GitHub)" <gi...@apache.org>.
korlov42 commented on code in PR #4907:
URL: https://github.com/apache/ignite-3/pull/4907#discussion_r1889797052


##########
modules/sql-engine/src/main/java/org/apache/ignite/internal/sql/engine/exec/fsm/CursorInitializationPhaseHandler.java:
##########
@@ -54,11 +55,9 @@ public Result handle(Query query) {
 
                     query.cursor = cursor;
 
-                    query.cancel.add(timeout -> {
-                        if (!timeout) {
-                            cursor.closeAsync(true);
-                        }
-                    });
+                    query.cancel.add(timeout -> dataCursor.cancelAsync(
+                            timeout ? CancellationReason.TIMEOUT : CancellationReason.CANCEL

Review Comment:
   > can we also remove the code that adds timeout handling in executeDdl and executeKill methods of ExecutionServiceImpl?
   
   Unfortunately, this is not only about removal from these two methods. We also need to remove according tests from `ExecutionServiceImplTest` (which is ok) and write another somewhere replacing old ones (since we would like to rely on cancellation code in one of the ExecutionPhase, new tests must involve `TestCluster`). I believe this is out of the scope of current issue. Besides, we already has [IGNITE-23792](https://issues.apache.org/jira/browse/IGNITE-23792), thus I would prefer to don't touch this part in my PR, If you don't mind.
   
   > сan we add a test that will reproduce (constantly) the issue that this patch solves?
   
   tbh, I have no idea how to make it to _steadily_ reproduces this race. During investigation, I just added `Thread.sleep(2)` before adding cancellation handling for cursor, but this is not acceptable to have `sleep()` in the production code for this. To make sure (kinda) that problem is gone, I've run JDBC job on TC 15 times ([proof](https://ci.ignite.apache.org/buildConfiguration/ApacheIgnite3xGradle_Test_IntegrationTests_ModuleJdbc?branch=pull%2F4907#all-projects)) and got no failures. For my previous patch tests had failed after ~5th iterations. 



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


Re: [PR] IGNITE-24005 Sql. Rollback implicit tx when query is timed out [ignite-3]

Posted by "xtern (via GitHub)" <gi...@apache.org>.
xtern commented on code in PR #4907:
URL: https://github.com/apache/ignite-3/pull/4907#discussion_r1888843980


##########
modules/sql-engine/src/main/java/org/apache/ignite/internal/sql/engine/exec/fsm/CursorInitializationPhaseHandler.java:
##########
@@ -54,11 +55,9 @@ public Result handle(Query query) {
 
                     query.cursor = cursor;
 
-                    query.cancel.add(timeout -> {
-                        if (!timeout) {
-                            cursor.closeAsync(true);
-                        }
-                    });
+                    query.cancel.add(timeout -> dataCursor.cancelAsync(
+                            timeout ? CancellationReason.TIMEOUT : CancellationReason.CANCEL

Review Comment:
   I reread the ticket description and I want to clarify that if it is difficult to write a reproducer, then you can ignore this note.



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


Re: [PR] IGNITE-24005 Sql. Rollback implicit tx when query is timed out [ignite-3]

Posted by "xtern (via GitHub)" <gi...@apache.org>.
xtern commented on code in PR #4907:
URL: https://github.com/apache/ignite-3/pull/4907#discussion_r1888805693


##########
modules/sql-engine/src/main/java/org/apache/ignite/internal/sql/engine/exec/fsm/CursorInitializationPhaseHandler.java:
##########
@@ -54,11 +55,9 @@ public Result handle(Query query) {
 
                     query.cursor = cursor;
 
-                    query.cancel.add(timeout -> {
-                        if (!timeout) {
-                            cursor.closeAsync(true);
-                        }
-                    });
+                    query.cancel.add(timeout -> dataCursor.cancelAsync(
+                            timeout ? CancellationReason.TIMEOUT : CancellationReason.CANCEL

Review Comment:
   1. can we also remove the code that adds timeout handling in `executeDdl` and `executeKill` methods of  `ExecutionServiceImpl`?
   2. сan we add a test that will reproduce the issue that this patch solves?



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


Re: [PR] IGNITE-24005 Sql. Rollback implicit tx when query is timed out [ignite-3]

Posted by "xtern (via GitHub)" <gi...@apache.org>.
xtern commented on code in PR #4907:
URL: https://github.com/apache/ignite-3/pull/4907#discussion_r1888843980


##########
modules/sql-engine/src/main/java/org/apache/ignite/internal/sql/engine/exec/fsm/CursorInitializationPhaseHandler.java:
##########
@@ -54,11 +55,9 @@ public Result handle(Query query) {
 
                     query.cursor = cursor;
 
-                    query.cancel.add(timeout -> {
-                        if (!timeout) {
-                            cursor.closeAsync(true);
-                        }
-                    });
+                    query.cancel.add(timeout -> dataCursor.cancelAsync(
+                            timeout ? CancellationReason.TIMEOUT : CancellationReason.CANCEL

Review Comment:
   I reread the ticket description and I want to clarify that if it is difficult to write a reproducer, then you can ignore this note.
   
   At first I thought we didn't have a timeout test that triggers an implicit RW transaction. We do have those, 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


Re: [PR] IGNITE-24005 Sql. Rollback implicit tx when query is timed out [ignite-3]

Posted by "xtern (via GitHub)" <gi...@apache.org>.
xtern commented on code in PR #4907:
URL: https://github.com/apache/ignite-3/pull/4907#discussion_r1888805074


##########
modules/sql-engine/src/main/java/org/apache/ignite/internal/sql/engine/exec/fsm/CursorInitializationPhaseHandler.java:
##########
@@ -54,11 +55,9 @@ public Result handle(Query query) {
 
                     query.cursor = cursor;
 
-                    query.cancel.add(timeout -> {

Review Comment:
   1. can we also remove the code that adds timeout handling in `executeDdl` and `executeKill` methods of  `ExecutionServiceImpl`?
   2. сan we add a test that will reproduce the issue the patch solves?



##########
modules/sql-engine/src/main/java/org/apache/ignite/internal/sql/engine/exec/fsm/CursorInitializationPhaseHandler.java:
##########
@@ -54,11 +55,9 @@ public Result handle(Query query) {
 
                     query.cursor = cursor;
 
-                    query.cancel.add(timeout -> {
-                        if (!timeout) {
-                            cursor.closeAsync(true);
-                        }
-                    });
+                    query.cancel.add(timeout -> dataCursor.cancelAsync(
+                            timeout ? CancellationReason.TIMEOUT : CancellationReason.CANCEL

Review Comment:
   1. can we also remove the code that adds timeout handling in `executeDdl` and `executeKill` methods of  `ExecutionServiceImpl`?
   2. сan we add a test that will reproduce the issue the patch solves?



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


Re: [PR] IGNITE-24005 Sql. Rollback implicit tx when query is timed out [ignite-3]

Posted by "xtern (via GitHub)" <gi...@apache.org>.
xtern commented on code in PR #4907:
URL: https://github.com/apache/ignite-3/pull/4907#discussion_r1888843980


##########
modules/sql-engine/src/main/java/org/apache/ignite/internal/sql/engine/exec/fsm/CursorInitializationPhaseHandler.java:
##########
@@ -54,11 +55,9 @@ public Result handle(Query query) {
 
                     query.cursor = cursor;
 
-                    query.cancel.add(timeout -> {
-                        if (!timeout) {
-                            cursor.closeAsync(true);
-                        }
-                    });
+                    query.cancel.add(timeout -> dataCursor.cancelAsync(
+                            timeout ? CancellationReason.TIMEOUT : CancellationReason.CANCEL

Review Comment:
   I reread the ticket description and I want to clarify that if it is difficult to write a reproducer, then you can ignore this note.
   
   At first I thought we don't have a test for timeout that starts an implicit RW transaction. We do have those, 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


Re: [PR] IGNITE-24005 Sql. Rollback implicit tx when query is timed out [ignite-3]

Posted by "xtern (via GitHub)" <gi...@apache.org>.
xtern commented on code in PR #4907:
URL: https://github.com/apache/ignite-3/pull/4907#discussion_r1888805693


##########
modules/sql-engine/src/main/java/org/apache/ignite/internal/sql/engine/exec/fsm/CursorInitializationPhaseHandler.java:
##########
@@ -54,11 +55,9 @@ public Result handle(Query query) {
 
                     query.cursor = cursor;
 
-                    query.cancel.add(timeout -> {
-                        if (!timeout) {
-                            cursor.closeAsync(true);
-                        }
-                    });
+                    query.cancel.add(timeout -> dataCursor.cancelAsync(
+                            timeout ? CancellationReason.TIMEOUT : CancellationReason.CANCEL

Review Comment:
   1. can we also remove the code that adds timeout handling in `executeDdl` and `executeKill` methods of  `ExecutionServiceImpl`?
   2. сan we add a test that will reproduce (constantly) the issue that this patch solves?



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


Re: [PR] IGNITE-24005 Sql. Rollback implicit tx when query is timed out [ignite-3]

Posted by "xtern (via GitHub)" <gi...@apache.org>.
xtern commented on code in PR #4907:
URL: https://github.com/apache/ignite-3/pull/4907#discussion_r1888805074


##########
modules/sql-engine/src/main/java/org/apache/ignite/internal/sql/engine/exec/fsm/CursorInitializationPhaseHandler.java:
##########
@@ -54,11 +55,9 @@ public Result handle(Query query) {
 
                     query.cursor = cursor;
 
-                    query.cancel.add(timeout -> {

Review Comment:
   1. can we also remove the code that adds timeout handling in `executeDdl` and `executeKill` methods of  `ExecutionServiceImpl`?
   2. сan we add a test that will reproduce the issue the patch solves?



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


Re: [PR] IGNITE-24005 Sql. Rollback implicit tx when query is timed out [ignite-3]

Posted by "xtern (via GitHub)" <gi...@apache.org>.
xtern commented on code in PR #4907:
URL: https://github.com/apache/ignite-3/pull/4907#discussion_r1888843980


##########
modules/sql-engine/src/main/java/org/apache/ignite/internal/sql/engine/exec/fsm/CursorInitializationPhaseHandler.java:
##########
@@ -54,11 +55,9 @@ public Result handle(Query query) {
 
                     query.cursor = cursor;
 
-                    query.cancel.add(timeout -> {
-                        if (!timeout) {
-                            cursor.closeAsync(true);
-                        }
-                    });
+                    query.cancel.add(timeout -> dataCursor.cancelAsync(
+                            timeout ? CancellationReason.TIMEOUT : CancellationReason.CANCEL

Review Comment:
   I reread the ticket description and I want to clarify that if it is difficult to write a reproducer, then you can ignore this note.



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