Issue Details (XML | Word | Printable)

Key: CORE-4334
Type: Bug Bug
Status: Closed Closed
Resolution: Fixed
Priority: Major Major
Assignee: Dmitry Yemanov
Reporter: Pavel Zotov
Votes: 0
Watchers: 0

If you were logged in you would be able to see more operations.
Firebird Core

Resources (e.g. sort files) owned by trigger may not be released when it's interrupted asynchronously

Created: 05/Feb/14 05:06 PM   Updated: 22/Sep/15 09:40 AM
Component/s: Engine
Affects Version/s: 3.0 Alpha 1, 3.0 Alpha 2
Fix Version/s: 3.0 Beta 1

File Attachments: 1. Zip Archive (2 kB)

QA Status: Cannot be tested

 Description  « Hide
Reproduced on:

firebird.conf changes: TempCacheLimit = 64K

DDL: see attach, file CROSS.DDL.

Please note that this script contains on-commit trigger with some kind of 'heavy' query to MON$-tables:
    -- first check uncommitted data in all other transactions:
    if (
                with c as(
                        c.mon$transaction_id tid
                        --,substring(c.mon$variable_name from 3) vn
                        ,cast( substring(c.mon$variable_name from 3) as varchar(16384)) vn
                        ,min(cast( iif( c.mon$variable_name starting with 'ID_NEW', c.mon$variable_value, null) as int) ) ctx_id_new
                        ,min(cast( iif( c.mon$variable_name starting with 'F1_NEW', c.mon$variable_value, null) as int) ) ctx_f1_new
                        ,min(cast( iif( c.mon$variable_name starting with 'F2_NEW', c.mon$variable_value, null) as int) ) ctx_f2_new
                    from mon$context_variables c
                    group by 1,2 -- <<<<<<<<<<<<<<<<<< THIS WILL CAUSE 'SORT' in PLAN <<<<<<<<<<
                select *
                from c ca join c cb
                    on ca.ctx_id_new<>cb.ctx_id_new
                        and sign(ca.ctx_f1_new - cb.ctx_f2_new) * sign(cb.ctx_f1_new - ca.ctx_f2_new)>0
                 ) -- exists
       exception ex_crossed_dirty;

Also, note that one of field of that query is deliberately casted to long string (16384 chars).

1) open *single* isql session that runs script CROSS.SQL - see in attach.
2) wait about 10-15 seconds and than kill that session, e.g. via PSKILL utility (from Sysinternals package).

Result: FB keeps one or two FB_SORT_*-files open infinite time untill restart.

 All   Comments   Change History   Subversion Commits      Sort Order: Ascending order - Click to sort in descending order
Pavel Zotov added a comment - 05/Feb/14 05:08 PM
Beside fb_sort_* another temp files appears in temp-folder, namely: fb_recbuf and fb_blob. These are removed always OK.
fb_sort-files remains opened ONLY if we kill isql and will be removed if script will finished without interruption.

Dmitry Yemanov added a comment - 05/Feb/14 06:00 PM
I expect it to be fixed now, please verify.

Pavel Zotov added a comment - 06/Feb/14 05:13 AM
Checked (LI-T3.0.0.30876), result: fixed OK, no files remains in temp folder.