[ 
https://issues.apache.org/jira/browse/DERBY-3037?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12562589#action_12562589
 ] 

Mamta A. Satoor commented on DERBY-3037:
----------------------------------------

I spent some time on Dan's suggestion
***********************
What is the purpose of commit() closing the language result sets? If it's to 
close JDBC ResultSets that are marked close at commit then a possibility is to 
only close language result sets that return rows (returnRows() returns true). 
That would leave language result sets that do not return rows open, but by 
definition (I think) those are the ones that are actively executing and the 
very ones we don't want to close. :-) 
***********************

While debugging through the commit code path, I found that the current check 
for what languages resultset should be closed is the exact opposite of what we 
are thinking of trying. I have included the code path stack trace below
Thread [main] (Suspended)       
        ac601a400fx0117xafb0x415ax00000045b6980(BaseActivation).reset() line: 
337       
        GenericLanguageConnectionContext.resetActivations(boolean) line: 2748   
        GenericLanguageConnectionContext.doCommit(boolean, boolean, int, 
boolean) line: 1125    
        GenericLanguageConnectionContext.userCommit() line: 1003        
        TransactionResourceImpl.commit() line: 237      
        EmbedConnection40(EmbedConnection).commit() line: 1288  
        DERBY_3304_Repro.doConnCommitInt() line: 137    
        ac601a400fx0117xafb0x415ax00000045b6980.e0() line: not available        
        DirectCall.invoke(Object) line: 139     
        RowResultSet.getNextRowCore() line: 148 
        RowResultSet(BasicNoPutResultSetImpl).getNextRow() line: 460    
        EmbedResultSet40(EmbedResultSet).movePosition(int, int, String) line: 
425       
        EmbedResultSet40(EmbedResultSet).next() line: 369       
        DERBY_3304_Repro.doSingleDriver() line: 71      
        DERBY_3304_Repro.main(String[]) line: 104       

Here, the Java stored procedure is issuing a commit and the code path for the 
commit is as shown above. In the reset() method in BaseActivation (that is 
where the above stack trace is), we decide what resultsets should be closed 
based on following logic
                // if resultset holdability after commit is false, close it
                if (resultSet != null) {
                        if (!resultSetHoldability || !resultSet.returnsRows()) 
{                        
                                // would really like to check if it is open,
                                // this is as close as we can approximate that.
                                resultSet.close();
                        } else if (resultSet.returnsRows()) {
                                resultSet.clearCurrentRow();
                        }
                }

So, if the result set holdability is false, we close the language resultset 
whether it returns rows or not, which sounds correct. 
If the result set holdability is true, we close the resultset if it does not 
return rows. But for resultsets that do return rows and their holdablity is 
true, we simply clear the current row.  

> Language ResultSet.finish() is called even when the ResultSet is going to be 
> re-used.
> -------------------------------------------------------------------------------------
>
>                 Key: DERBY-3037
>                 URL: https://issues.apache.org/jira/browse/DERBY-3037
>             Project: Derby
>          Issue Type: Bug
>          Components: SQL
>    Affects Versions: 10.4.0.0
>            Reporter: Daniel John Debrunner
>            Assignee: Mamta A. Satoor
>             Fix For: 10.3.2.2, 10.4.0.0
>
>         Attachments: DERBY3037_patch_not_ready_for_commit_v2_diff.txt, 
> DERBY3037_patch_not_ready_for_commit_v2_stat.txt, 
> Derby_3037_AlterTableConstantActionChanges_v1_diff.txt, 
> Derby_3037_AlterTableConstantActionChanges_v1_stat.txt, DERBY_3304_Repro.java
>
>
> DERBY-827 (correctly) changed the lifetime of the language ResultSet tree to 
> be the lifetime of the activation, but did not fix up the correct calls to 
> ResultSet.close() and ResultSet.finish().
> A language ResultSet's lifetime should be driven by the activation, so 
> activation.close() should call finish() on its ResultSet.
> EmbedResultSet should call close on its language ResultSet (theResults field) 
> when the JDBC ResultSet is closed, it should not be calling finish() on its 
> ResultSet.
> See comments in DERBY-827 for some more details and issues.

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.

Reply via email to