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

Recursive EXECUTE STATEMENT works wrong [CORE2731] #3126

Closed
firebird-issue-importer opened this issue Nov 5, 2009 · 16 comments
Closed

Recursive EXECUTE STATEMENT works wrong [CORE2731] #3126

firebird-issue-importer opened this issue Nov 5, 2009 · 16 comments

Comments

@firebird-issue-importer
Copy link

firebird-issue-importer commented Nov 5, 2009

Submitted by: @hvlad

Is related to QA422

Attachments:
core-2731-FB_Classic_25_30_40-results-of-query-mon_statements-after-break-hanged-isql.7z
core-2731-fb-Classic_25_30_40-trace-logs-when-running-test-script.7z

Test case

recreate table SQL_SOURCE(
SQL_SOURCE varchar(32000)
);
commit;

insert into SQL_SOURCE values(
'execute block as
declare variable SQL type of column SQL_SOURCE.SQL_SOURCE;
begin
select first(1) SQL_SOURCE from SQL_SOURCE into :SQL;
execute statement :SQL
-- YOUR DB
on external ''127.0.0.1:S:\X.fdb''
as user ''SYSDBA'' password ''masterkey'';
end'
);
commit;

execute block as
declare variable SQL type of column SQL_SOURCE.SQL_SOURCE;
begin
select first(1) SQL_SOURCE from SQL_SOURCE into :SQL;
execute statement :SQL;
end

SS and SC hungs, CS creates a lot of processes.

Yes, test case looks crazy, but recursion must be limited somehow.

Commits: dc3cb55 bc9ad95

@firebird-issue-importer
Copy link
Author

firebird-issue-importer commented Nov 5, 2009

Modified by: @hvlad

assignee: Vlad Khorsun [ hvlad ]

@firebird-issue-importer
Copy link
Author

firebird-issue-importer commented Nov 5, 2009

Modified by: @hvlad

status: Open [ 1 ] => Resolved [ 5 ]

resolution: Fixed [ 1 ]

Fix Version: 2.5 RC2 [ 10372 ]

Fix Version: 3.0 Alpha 1 [ 10331 ]

@firebird-issue-importer
Copy link
Author

firebird-issue-importer commented Nov 5, 2009

Modified by: @dyemanov

Fix Version: 2.5 RC1 [ 10362 ]

Fix Version: 2.5 RC2 [ 10372 ] =>

@firebird-issue-importer
Copy link
Author

firebird-issue-importer commented Feb 24, 2011

Modified by: @pcisar

Link: This issue is related to QA422 [ QA422 ]

@firebird-issue-importer
Copy link
Author

firebird-issue-importer commented Jul 28, 2011

Commented by: @pcisar

QA test added.

@firebird-issue-importer
Copy link
Author

firebird-issue-importer commented Jul 28, 2011

Modified by: @pcisar

status: Resolved [ 5 ] => Closed [ 6 ]

@firebird-issue-importer
Copy link
Author

firebird-issue-importer commented Aug 29, 2015

Modified by: @pavel-zotov

status: Closed [ 6 ] => Closed [ 6 ]

QA Status: Done successfully

@firebird-issue-importer
Copy link
Author

firebird-issue-importer commented Apr 5, 2017

Commented by: @pavel-zotov

All of following: 2.5.8, 3.0.3, 4.0.0 - do NOT finish test script when working in Classic mode.

@firebird-issue-importer
Copy link
Author

firebird-issue-importer commented Apr 5, 2017

Modified by: @pavel-zotov

status: Closed [ 6 ] => Reopened [ 4 ]

Fix Version: 4.0 Alpha 1 [ 10731 ]

Fix Version: 3.0.3 [ 10810 ]

Fix Version: 2.5.8 [ 10809 ]

resolution: Fixed [ 1 ] =>

@firebird-issue-importer
Copy link
Author

firebird-issue-importer commented Apr 5, 2017

Commented by: @pavel-zotov

Please fix bug in Classic. Current snapshots (2.5, 3.0 & 4.0) hang when executing following script:

set list on;

set term ^;
execute block as
begin
execute statement 'drop sequence g';
when any do begin end
end^
set term ;^
commit;

create sequence g;
commit;

recreate table sql_source( sql_source varchar(350));
commit;

insert into sql_source values(
'execute block as
begin
rdb$set_context( ''USER_SESSION'',''CTX4ATTACH'', gen_id(g,1) ); -- for watching in the trace log
execute statement ( select sql_source from sql_source )
on external ''localhost:'' || rdb$get_context(''SYSTEM'',''DB_NAME'')
as user ''SYSDBA'' password ''masterkey'';
end'
);
commit;

set term ^;
execute block as
begin
rdb$set_context( 'USER_SESSION', 'CTX4ATTACH', 0 );
execute statement (select sql_source from sql_source);
end
^
set term ;^

select gen_id(g,0) from rdb$database;

Expected console output :

Statement failed, SQLSTATE = 42000
Execute statement error at isc_dsql_execute2 :
335544926 : Execute statement error at isc_dsql_execute2 :
335544926 : Execute statement error at isc_dsql_execute2 :
335544926 : Execute statement error at isc_dsql_execute2 :
335544926 : Execute statement error at isc_dsql_execute2 :
335544926 : Execute statement error at isc_dsql_execute2 :
335544926 : Execute statement error at isc_dsql_execute2 :
335544926 : Execute statement error at isc_dsql_execute2 :
335544926 : Execute statement error at isc_dsql_execute2 :
335544926 : Execute statement error at isc_dsql_execute2 :
335544926 : Execute statement error at isc_dsql_execute2 :
335544926 : Execute statement error at isc_dsql_execute2 :
335544926 : Execute statement error at isc_dsql_execute2 :
335544926 : Execute statement error at isc_dsql_execute2 :
335544926 : Execute statement error at isc_dsql_execute2 :
335544926 : Execute statement error at isc_dsql_execute2 :
335544926 : Execute statement error at isc_dsql_execute2 :
335544926 : Execute statement...
-At block line: 4, col: 5
After line 29 in file c2731.sql

GEN_ID 50

(this is result on Super* archs).

ISQL hangs when running this script on Classic, ProcessExplorer shows 44 items of child processes 'fb_inet_server' (or 'firebird' in 3.0+). No CPU load.
ISQL can be easy interrupted, but FB service sometimes can not be correctly stopped and need to be killed by PE.

Traces and results of "set list on; set count on; select * from mon$statements where mon$attachment_id!=current_connection;" are in attached .7z

Tested on Windowx XP.

PE full dumps for "main" and some "child" processes of FB Classic can be found here:
1) https://yadi.sk/d/-qadmSaA3Gfdru -- for WI-T4.0.0.584 (its pdb: https://yadi.sk/d/WSiAnLC43GfeWj )
2) https://yadi.sk/d/2lDF1Jpg3Gfds7 -- for WI-V2.5.8.27056 (its pdb: https://yadi.sk/d/gN34TNSu3GfeTz )

@firebird-issue-importer
Copy link
Author

firebird-issue-importer commented Apr 5, 2017

Modified by: @pavel-zotov

Attachment: core-2731-FB_Classic_25_30_40-results-of-query-mon_statements-after-break-hanged-isql.7z [ 13087 ]

Attachment: core-2731-fb-Classic_25_30_40-trace-logs-when-running-test-script.7z [ 13088 ]

@firebird-issue-importer
Copy link
Author

firebird-issue-importer commented Apr 5, 2017

Commented by: @hvlad

Just run your case with 4.0.0.584 and 3.0.3.32712 (CS, win64) - all works as expected

@firebird-issue-importer
Copy link
Author

firebird-issue-importer commented Apr 5, 2017

Commented by: @hvlad

2.5.8.27056, Win32 CS also OK

@firebird-issue-importer
Copy link
Author

firebird-issue-importer commented Apr 5, 2017

Commented by: @pavel-zotov

Can anyone please run following batch (exactly on Win32, not x64!) using any FB (2.5, 3.0. 4.0) in Classic mode:

@echo off
set fbc=C:\FB\25Cs\bin
set host=localhost
set port=3259
set dbnm=e25

set n_att=43
if not .%1.==.. set /a n_att=%1

set delay=5
if not .%2.==.. set /a delay=%2
set /a dly=%delay%-1

echo Establishing %n_att% attachments. Please wait. . .
for /l %%i in (1, 1, %n_att%) do (
start /min %fbc%\isql %host%/%port%:%dbnm% -z
)

@echo Take delay %delay% seconds - let all ISQL to be loaded and make their attachments. . .
ping -n %dly% 127.0.0.1 >nul

@echo on
echo set list on; select count(*) from mon$attachments where mon$attachment_id!=current_connection; | %fbc%\isql %host%/%port%:%dbnm% -z -q
pskill isql 2>nul

Input arg:
#⁠1 = number of attachments to be established, default = 43
#⁠2 = delay in seconds before aux. ISQL will be connected and ask mon$attachments in order to get number of them, default = 4 seconds.

What is the limit of attachments in your env. ?
I can not establish more than 43 attachments on 2.5.8.27056.

@firebird-issue-importer
Copy link
Author

firebird-issue-importer commented Apr 5, 2017

Modified by: @pavel-zotov

status: Reopened [ 4 ] => Closed [ 6 ]

resolution: Fixed [ 1 ]

@firebird-issue-importer
Copy link
Author

firebird-issue-importer commented Apr 5, 2017

Commented by: @pavel-zotov

The problem relates to ability establish more than 43 attachents on Win32, this is not subject of Firebird per se.
After change FB service parameter (set checkbox "enable to interact with desktop" to "ON") it was encountered that one may to increase this limit, up to ~85...87.
So, this ticket can be considered as "Resolved' because all issues are about Win32 features.

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