You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Invocations of rdb$profiler.start_session / rdb$profiler.finish_session can cause valuable delay between script cancellation and appropriate server process completion
#8183
Open
pavel-zotov opened this issue
Jul 15, 2024
· 0 comments
Suppose we have to run loop with lot iterations and do following within each iteration:
start profiler with some options
do some stuff
stop profiler
This can be illustrated by following simplified script (with infinite loop instead of some large limit):
execute block returns(x int) as
declare use_profiler smallint = 1; -- [ ! ]
declare dummy bigint;
declare i smallint = 0;
begin
while (i < 1) do
begin
if ( use_profiler = 1 ) then
select rdb$profiler.start_session('prof_ssn_' || :i) from rdb$database into :dummy;
select rdb$linger from rdb$database into dummy;
-- rdb$set_context('USER_TRANSACTION', 'DEBUG_FOR_WATCH_IN_TRACE', current_time); -- #1
-- suspend; -- #2
if ( use_profiler = 1 ) then
execute procedure rdb$profiler.finish_session(true);
-- i = i + 1; -- #3
end
end
Now let change firebird.conf by adding: StatementTimeout = 300
Restart service, run script (using ISQL) shown above and let it work at least 25 ... 30 seconds.
Then let's cancel script by pressing Ctrl-Break.
File firebird.log at this moment will show time when we did cancellation:
So far so good.
But server process (firebird.exe) will NOT stop its work for valuable time, continuing to load one of CPU cores for ~100%.
And this will last for StatementTimeout - <N> seconds, where <N> is about 18...20. During that time DB file remains opened.
/*
Value of <N> can be evaluated quite precisely if we will wait until firebird process will finished and then get exact time of DB last_modified file attribute, e.g.: wmic datafile where name='R:\\Temp\\TMP4TEST.FDB' get LastModified /format:list | more
*/
If you change use_profiler to 0 (see line marked as "[ ! ]") then all became fine: firebird process will be eliminated after 1...2 seconds after script cancellation.
Same if we uncomment any of lines marked as "#1", "#2" or "#3" (with use_profiler = 1).
Suppose we have to run loop with lot iterations and do following within each iteration:
This can be illustrated by following simplified script (with infinite loop instead of some large limit):
Now let change firebird.conf by adding:
StatementTimeout = 300
Restart service, run script (using ISQL) shown above and let it work at least 25 ... 30 seconds.
Then let's cancel script by pressing Ctrl-Break.
File firebird.log at this moment will show time when we did cancellation:
So far so good.
But server process (firebird.exe) will NOT stop its work for valuable time, continuing to load one of CPU cores for ~100%.
And this will last for
StatementTimeout - <N>
seconds, where<N>
is about 18...20. During that time DB file remains opened./*
Value of
<N>
can be evaluated quite precisely if we will wait until firebird process will finished and then get exact time of DB last_modified file attribute, e.g.:wmic datafile where name='R:\\Temp\\TMP4TEST.FDB' get LastModified /format:list | more
*/
If you change use_profiler to 0 (see line marked as "[ ! ]") then all became fine: firebird process will be eliminated after 1...2 seconds after script cancellation.
Same if we uncomment any of lines marked as "#1", "#2" or "#3" (with use_profiler = 1).
PS.
6.0.0.395, config:
The text was updated successfully, but these errors were encountered: