Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Attempt to reopen an open cursor] in "Execute->Fetch->Cancel->Close->Execute->Fetch->Error" [CORE3984] #4317

Open
firebird-automations opened this issue Nov 16, 2012 · 5 comments

Comments

@firebird-automations
Copy link
Collaborator

Submitted by: @ibprovider

Server Version :2.5.3.26543 [Windows, SuperClassic, 64bit]
Client Version :2.5.3.26543 [Windows, 32bit]
Database ODS :11.2
Database Dialect:3

Connection through "localhost".

Work from 32bit application.

-----------------------------------------------
Common scenario:
1. thread1: execute statement "select ID,DUMMY from SP_PAUSE_FETCH(1000,10000000)"
2. thread2: fetch one row
3. thread1: cancel fetch (and wait the finish of cancelation)
4. thread1: close cursor
5. thread1: execute statment again
6. thread2: fetch one row -> ERROR "Attempt to reopen an open cursor"

-----------------------------------------------
Sequence of ISC API calls:
11:[Thr 10032][16.11.2012 12:51:57]ISC_API_IN [#⁠000001]: isc_dsql_allocate_statement(...,db_handle=&00000002,stmt_handle=&00000000)
12:[Thr 10032][16.11.2012 12:51:57]ISC_API_OUT[#⁠000001]: isc_dsql_allocate_statement(...,db_handle=&00000002,stmt_handle=&00000004) return OK.
13:[Thr 10032][16.11.2012 12:51:57]ISC_API_IN [#⁠000002]: isc_dsql_prepare(...,tr_handle=&00000003,stmt_handle=&00000004,...)
[stmt_text len:50]
select ID,DUMMY from SP_PAUSE_FETCH(1000,10000000)
[/stmt_text]
14:[Thr 10032][16.11.2012 12:51:57]ISC_API_OUT[#⁠000002]: isc_dsql_prepare(...,tr_handle=&00000003,stmt_handle=&00000004,...) return OK.
15:[Thr 10032][16.11.2012 12:51:57]ISC_API_IN [#⁠000003]: isc_dsql_execute2(...,tr_handle=&00000003,stmt_handle=&00000004,...)
16:[Thr 10032][16.11.2012 12:51:57]ISC_API_OUT[#⁠000003]: isc_dsql_execute2(...,tr_handle=&00000003,stmt_handle=&00000004,...) return OK.
17:[Thr 2284][16.11.2012 12:51:57]ISC_API_IN [#⁠000004]: isc_dsql_fetch(...,stmt_handle=&00000004,...)
18:[Thr 10032][16.11.2012 12:51:57]ISC_API_IN [#⁠000005]: fb_cancel_operation(,db_handle=&00000002,option=3)
19:[Thr 10032][16.11.2012 12:51:57]ISC_API_OUT[#⁠000005]: fb_cancel_operation(,db_handle=&00000002,option=3) return OK.
20:[Thr 10032][16.11.2012 12:51:57]ISC_API_IN [#⁠000006]: fb_cancel_operation(,db_handle=&00000002,option=3)
21:[Thr 10032][16.11.2012 12:51:57]ISC_API_OUT[#⁠000006]: fb_cancel_operation(,db_handle=&00000002,option=3) return OK.
22:[Thr 2284][16.11.2012 12:51:57]ISC_API_OUT[#⁠000004]: isc_dsql_fetch(...,stmt_handle=&00000004,...) return ERROR [335544794]
operation was cancelled
23:[Thr 10032][16.11.2012 12:51:57]ISC_API_IN [#⁠000007]: isc_dsql_free_statement(...,stmt_handle=&00000004,1)
24:[Thr 10032][16.11.2012 12:51:57]ISC_API_OUT[#⁠000007]: isc_dsql_free_statement(...,stmt_handle=&00000004,1) return OK.
25:[Thr 10032][16.11.2012 12:51:57]ISC_API_IN [#⁠000008]: isc_dsql_execute2(...,tr_handle=&00000003,stmt_handle=&00000004,...)
26:[Thr 10032][16.11.2012 12:51:57]ISC_API_OUT[#⁠000008]: isc_dsql_execute2(...,tr_handle=&00000003,stmt_handle=&00000004,...) return OK.
27:[Thr 2284][16.11.2012 12:51:57]ISC_API_IN [#⁠000009]: isc_dsql_fetch(...,stmt_handle=&00000004,...)
28:[Thr 2284][16.11.2012 12:51:57]ISC_API_OUT[#⁠000009]: isc_dsql_fetch(...,stmt_handle=&00000004,...) return ERROR [335544569]
Dynamic SQL Error
SQL error code = -502
Attempt to reopen an open cursor
29:[Thr 10032][16.11.2012 12:51:57]ISC_API_IN [#⁠000010]: isc_dsql_free_statement(...,stmt_handle=&00000004,1)
30:[Thr 10032][16.11.2012 12:51:57]ISC_API_OUT[#⁠000010]: isc_dsql_free_statement(...,stmt_handle=&00000004,1) return OK.
31:[Thr 10032][16.11.2012 12:51:57]ISC_API_IN [#⁠000011]: isc_dsql_free_statement(...,stmt_handle=&00000004,2)
32:[Thr 10032][16.11.2012 12:51:57]ISC_API_OUT[#⁠000011]: isc_dsql_free_statement(...,stmt_handle=&00000000,2) return OK.

-------------
In line 23-24 I close my open cursor
In line 25-26 I re-execute statement

Why in line 28 (operation #⁠000009) I obtain the error "Attempt to reopen an open cursor" ?

---------- [Test stored procedure]
CREATE PROCEDURE SP_PAUSE_FETCH(N INTEGER, PAUSE INTEGER)
RETURNS (ID INTEGER,DUMMY VARCHAR(32000))
AS
DECLARE VARIABLE P INTEGER;
DECLARE VARIABLE S INTEGER;
BEGIN
ID=0;

DUMMY='';
P=0;
WHILE(P<32000)DO
BEGIN
DUMMY=DUMMY||'A';
P=P+1;
END

S=0;
WHILE(S=0)DO
BEGIN
P=0;
WHILE(P<PAUSE) DO P=P+1;

IF(ID<N)THEN
BEGIN
ID=ID+1;
SUSPEND;
END
ELSE
BEGIN
S=1;
END
END
END
---------- [/Test stored procedure]

@firebird-automations
Copy link
Collaborator Author

Commented by: @asfernandes

Does the problem happens with the windows local protocol?

@firebird-automations
Copy link
Collaborator Author

Commented by: @ibprovider

Local protocol not supports a 'cancel' operations ...

@firebird-automations
Copy link
Collaborator Author

Commented by: @ibprovider

Seem the problem at fbclient layer.

I think, op_cancel should send to port directly. Not through send_packet function.

@firebird-automations
Copy link
Collaborator Author

Commented by: @ibprovider

Sending of op_cancel directly is works, but not helps.

----
In general, you can close this ticket, because this problem was resolved in my own client to firebird.

@firebird-automations
Copy link
Collaborator Author

Commented by: @ibprovider

Additional information (idea)

When application executes FETCH, fbclient (lazy_send mode) can send three packets: (1) op_close_stmt (for previous cursor), (2) op_execute_stmt (open new cursor), (3) op_fetch (work with new cursor)

cancel of operation (in separated thread) can interrupt (1) op_close_stmt. But server in any case continues the execution of (2) and (3).

I think fbclient.dll loses the error for (1) and returns the error for (2)

?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant