Packaged temp tables. Crash on 'ALTER PACKAGE <P>' if <P> has indexed attachment-level temporary table with some data

34 views
Skip to first unread message

Pavel Zotov

unread,
Jul 5, 2026, 3:30:39 AM (2 days ago) Jul 5
to firebird-devel

Following script causes crash of 6.0.0.2060-637102f:

set bail on;
set wng off;
set list on;
set autoddl off;
set autoterm on;
set keep_tran on;
shell if exist r:\temp\tmp4test.fdb del r:\temp\tmp4test.fdb;

create database 'localhost:r:\temp\tmp4test.fdb' user 'sysdba' password 'masterkey';
commit;

create or alter package pg_temp_tab as
begin
    procedure sp_fill;
end
;

recreate package body pg_temp_tab as
begin
    temporary table pg_priv_table(id int, f01 boolean) on commit
        preserve -------------------------------------------- [ 1 ]
        -- delete
        rows
        index t_boo_priv_idx(id) ---------------------------- [ 2 ]
    ;
    procedure sp_fill as
    begin
        insert into pg_priv_table(id, f01) values(1, false);
    end
end
;

execute procedure pg_temp_tab.sp_fill; --------------------- [ 3 ]

SELECT CURRENT_TRANSACTION AS TX_BEFORE_COMMIT FROM RDB$DATABASE;

commit; ---------------------------------------------------- [ 4 ]

SELECT CURRENT_TRANSACTION AS TX_AFTER_COMMIT FROM RDB$DATABASE;

alter package pg_temp_tab as
begin
    -- nope --
end
;


NB: all statements marked as "[ 1 ]" ... "[ 4 ]" are mandatory to reproduce problem.

Dump, stack-trace, FB snapshot + its config + log,  user  trace log are here.

PS.
firebird.log contains rows:
===========
PZ Sun Jul  5 10:14:13 2026
DropIndexNode::clearId() failed
deadlock
update conflicts with concurrent update
concurrent transaction number is

PZ Sun Jul  5 10:14:13 2026
Database: R:\TEMP\TMP4TEST.FDB
internal Firebird consistency check (invalid block type encountered (147), file: cch.cpp line: 2048)
....
PZ Sun Jul  5 10:14:39 2026
REMOTE INTERFACE/gds__detach: Unsuccessful detach from database.
Uncommitted work may have been lost.
Error writing data to the connection.

===========


Tail of script output is:
...
execute procedure pg_temp_tab.sp_fill; --------------------- [ 3 ]
SELECT CURRENT_TRANSACTION AS TX_BEFORE_COMMIT FROM RDB$DATABASE;
TX_BEFORE_COMMIT                7
commit; ---------------------------------------------------- [ 4 ]
SELECT CURRENT_TRANSACTION AS TX_AFTER_COMMIT FROM RDB$DATABASE;
TX_AFTER_COMMIT                

alter package pg_temp_tab as
begin
    -- nope --
end
;
Statement failed, SQLSTATE = 08006
Error reading data from the connection.
===========

Mark Rotteveel

unread,
Jul 5, 2026, 3:35:04 AM (2 days ago) Jul 5
to firebir...@googlegroups.com
If it causes a crash, shouldn't it be created as an issue in the tracker?

Mark
> here <https://drive.google.com/drive/folders/1HSEistA-N8w-
> eSs_fweLbt9zF9dBgvIZ?usp=sharing>.
>
> PS.
> firebird.log contains rows:
> ===========
> PZSun Jul  5 10:14:13 2026
> DropIndexNode::clearId() failed
> deadlock
> update conflicts with concurrent update
> concurrent transaction number is8
>
> PZSun Jul  5 10:14:13 2026
> Database: R:\TEMP\TMP4TEST.FDB
> internal Firebird consistency check (invalid block type encountered
> (147), file: cch.cpp line: 2048)
> ....
> PZSun Jul  5 10:14:39 2026
> REMOTE INTERFACE/gds__detach: Unsuccessful detach from database.
> Uncommitted work may have been lost.
> Error writing data to the connection.
> ===========
>
>
> Tail of script output is:
> ...
> execute procedure pg_temp_tab.sp_fill; --------------------- [ 3 ]
> SELECT CURRENT_TRANSACTION AS TX_BEFORE_COMMIT FROM RDB$DATABASE;
> TX_BEFORE_COMMIT                7
> commit; ---------------------------------------------------- [ 4 ]
> SELECT CURRENT_TRANSACTION AS TX_AFTER_COMMIT FROM RDB$DATABASE;
> TX_AFTER_COMMIT 8
>
> alter package pg_temp_tab as
> begin
>     -- nope --
> end
> ;
> Statement failed, SQLSTATE = 08006
> Error reading data from the connection.
> ===========
>
> --
> Support the ongoing development of Firebird! Consider donating to the
> Firebird Foundation and help ensure its future. Every contribution makes
> a difference. Learn more and donate here:
> https://www.firebirdsql.org/donate <https://www.firebirdsql.org/donate>
> ---
> You received this message because you are subscribed to the Google
> Groups "firebird-devel" group.
> To unsubscribe from this group and stop receiving emails from it, send
> an email to firebird-deve...@googlegroups.com
> <mailto:firebird-deve...@googlegroups.com>.
> To view this discussion visit https://groups.google.com/d/msgid/
> firebird-devel/561e6557-b3cd-4733-b3a3-12bd5fdb3181n%40googlegroups.com
> <https://groups.google.com/d/msgid/firebird-devel/561e6557-b3cd-4733-
> b3a3-12bd5fdb3181n%40googlegroups.com?utm_medium=email&utm_source=footer>.


--
Mark Rotteveel

Pavel Zotov

unread,
Jul 5, 2026, 3:41:41 AM (2 days ago) Jul 5
to firebird-devel


> if it causes a crash, shouldn't it be created as an issue in the tracker?

Alex said several times that for NON-released FB detected issues should be noted here rather than in the tracker.
// as for me, though, it is much convenient to put such messages only in the tracker - just because it has extremely powerful filtering features.








 

Mark Rotteveel

unread,
Jul 5, 2026, 4:00:02 AM (2 days ago) Jul 5
to firebir...@googlegroups.com
I find that a weird way of working, but I'm not a core developer, so
that's not my call.

I agree with you that using the tracker for this is much easier (and
better to track) than using the mailing list.

Mark
--
Mark Rotteveel

Adriano dos Santos Fernandes

unread,
Jul 5, 2026, 1:21:13 PM (2 days ago) Jul 5
to firebir...@googlegroups.com
On 7/5/26 04:30, Pavel Zotov wrote:
>
> Following script causes crash of 6.0.0.2060-637102f:
>

The root of this problem is GTT metadata cache changes, not packaged tables:

---
SQL> set term !;
SQL> set autoddl off!
SQL>
SQL>
SQL> create global temporary table pg_priv_table(id int, f01 boolean) on
commit preserve rows!
SQL> create index t_boo_priv_idx on pg_priv_table (id)!
SQL>
SQL> create procedure sp_fill as
CON> begin
CON> insert into pg_priv_table(id, f01) values(1, false);
CON> end!
SQL> execute procedure sp_fill!
SQL>
SQL> SELECT CURRENT_TRANSACTION AS TX_BEFORE_COMMIT FROM RDB$DATABASE!

TX_BEFORE_COMMIT
=====================
3

SQL>
SQL> commit!
SQL>
SQL> SELECT CURRENT_TRANSACTION AS TX_AFTER_COMMIT FROM RDB$DATABASE!

TX_AFTER_COMMIT
=====================
5

SQL> drop table pg_priv_table!
[Thread 0x7fffef3bd6c0 (LWP 380528) exited]

Thread 1 "isql" received signal SIGABRT, Aborted.
__pthread_kill_implementation (threadid=<optimized out>, signo=6,
no_tid=0) at ./nptl/pthread_kill.c:44
⚠️ warning: 44 ./nptl/pthread_kill.c: No such file or directory
(gdb) bt
#0 __pthread_kill_implementation (threadid=<optimized out>, signo=6,
no_tid=0) at ./nptl/pthread_kill.c:44
#1 __pthread_kill_internal (threadid=<optimized out>, signo=6) at
./nptl/pthread_kill.c:89
#2 __GI___pthread_kill (threadid=<optimized out>, signo=signo@entry=6)
at ./nptl/pthread_kill.c:100
#3 0x00007ffff7645b7e in __GI_raise (sig=sig@entry=6) at
../sysdeps/posix/raise.c:26
#4 0x00007ffff76288ec in __GI_abort () at ./stdlib/abort.c:77
#5 0x00007ffff4b5e654 in ERR_punt () at
/home/asfernandes/fb/dev/firebird-master.git/src/jrd/err.cpp:345
#6 0x00007ffff4b5dfae in ERR_post (v=...) at
/home/asfernandes/fb/dev/firebird-master.git/src/jrd/err.cpp:320
#7 0x00007ffff4b5dea0 in internal_error (status=335544333, number=147,
file=0x7ffff521003a
"/home/asfernandes/fb/dev/firebird-master.git/src/jrd/cch.cpp", line=2048)
at /home/asfernandes/fb/dev/firebird-master.git/src/jrd/err.cpp:454
#8 0x00007ffff4b5dcfa in ERR_bugcheck (number=147, file=0x7ffff521003a
"/home/asfernandes/fb/dev/firebird-master.git/src/jrd/cch.cpp", line=2048)
at /home/asfernandes/fb/dev/firebird-master.git/src/jrd/err.cpp:78
#9 0x00007ffff4b1d562 in CCH_release (tdbb=0x7fffffffa820,
window=0x7fffffff6f98, release_tail=false) at
/home/asfernandes/fb/dev/firebird-master.git/src/jrd/cch.cpp:2048
#10 0x00007ffff49154af in CCH_RELEASE (tdbb=0x7fffffffa820,
window=0x7fffffff6f98) at
/home/asfernandes/fb/dev/firebird-master.git/src/jrd/../jrd/cch_proto.h:99
#11 0x00007ffff4b12442 in BTR_mark_index_for_delete(Jrd::thread_db*,
Jrd::RelationPermanent*, unsigned short, Jrd::win*,
Ods::index_root_page*, unsigned long long)::$_0::operator()() const
(this=0x7fffffff6f18) at
/home/asfernandes/fb/dev/firebird-master.git/src/jrd/btr.cpp:1189
#12 0x00007ffff4b05685 in
Firebird::Cleanup<BTR_mark_index_for_delete(Jrd::thread_db*,
Jrd::RelationPermanent*, unsigned short, Jrd::win*,
Ods::index_root_page*, unsigned long long)::$_0>::~Cleanup
(this=0x7fffffff6f18) at
/home/asfernandes/fb/dev/firebird-master.git/src/include/../common/classes/auto.h:346
#13 0x00007ffff4b05233 in BTR_mark_index_for_delete
(tdbb=0x7fffffffa820, rel=0x7fffeeb781b8, id=0, window=0x7fffffff6f98,
root=0x7ffff38b6000, tran=5)
at /home/asfernandes/fb/dev/firebird-master.git/src/jrd/btr.cpp:1261
#14 0x00007ffff4b838df in IDX_mark_index (tdbb=0x7fffffffa820,
relation=0x7fffeeb781a0, id=0) at
/home/asfernandes/fb/dev/firebird-master.git/src/jrd/idx.cpp:1003
#15 0x00007ffff4d12a5b in Jrd::DropIndexNode::step2
(this=0x7fffee3116d0, tdbb=0x7fffffffa820, transaction=0x7fffee292ad0)
at
/home/asfernandes/fb/dev/firebird-master.git/temp/debug/temp/Debug/dsql/DdlNodes.cpp:37911
#16 0x00007ffff4d0bad6 in Jrd::ModifyIndexNode::modify
(this=0x7fffee3116d0, tdbb=0x7fffffffa820, transaction=0x7fffee292ad0)
at
/home/asfernandes/fb/dev/firebird-master.git/temp/debug/temp/Debug/dsql/DdlNodes.cpp:35297
#17 0x00007ffff4ce05c6 in Jrd::ModifyIndexList::exec
(this=0x7fffffff7700, tdbb=0x7fffffffa820, transaction=0x7fffee292ad0)
at
/home/asfernandes/fb/dev/firebird-master.git/temp/debug/temp/Debug/dsql/DdlNodes.cpp:35376
#18 0x00007ffff4d037b3 in Jrd::DropRelationNode::execute
(this=0x7fffee313870, tdbb=0x7fffffffa820, dsqlScratch=0x7fffeea56b50,
transaction=0x7fffee292ad0)
at
/home/asfernandes/fb/dev/firebird-master.git/temp/debug/temp/Debug/dsql/DdlNodes.cpp:33646
#19 0x00007ffff4d635a6 in Jrd::DdlNode::executeDdl (this=0x7fffee313870,
tdbb=0x7fffffffa820, dsqlScratch=0x7fffeea56b50,
transaction=0x7fffee292ad0, trusted=false)
at
/home/asfernandes/fb/dev/firebird-master.git/src/include/../dsql/../dsql/../dsql/Nodes.h:221
#20 0x00007ffff4d62270 in Jrd::DsqlDdlRequest::execute
(this=0x7fffee311590, tdbb=0x7fffffffa820, traHandle=0x7fffffffa730,
inMetadata=0x0, inMsg=0x0, outMetadata=0x0,
outMsg=0x0, singleton=false) at
/home/asfernandes/fb/dev/firebird-master.git/src/dsql/DsqlRequests.cpp:980
#21 0x00007ffff4e41ecb in DSQL_execute (tdbb=0x7fffffffa820,
tra_handle=0x7fffffffa730, dsqlRequest=0x7fffee311590, in_meta=0x0,
in_msg=0x0, out_meta=0x0, out_msg=0x0)
at /home/asfernandes/fb/dev/firebird-master.git/src/dsql/dsql.cpp:194
---

Alex, can you take a look?


Adriano

Alex Peshkoff

unread,
Jul 6, 2026, 12:06:26 PM (yesterday) Jul 6
to firebir...@googlegroups.com
On 7/5/26 20:21, Adriano dos Santos Fernandes wrote:
> Alex, can you take a look?

Fixed this - there was a set of 3 relatively independent problems.

One of them appears to me to be worth discussing here. We have an
ancient struct win which should be manually released when page held by
it is not needed any more. That's more or less (sooner less) OK when
flow control is linear and regular but as soon as we have exception
raised when window is busy it becomes nightmare and may cause in
production hardly predictable deadlock (page lock was not released) in
engine. What is wrong if we use RAII approach for it?


Pavel Zotov

unread,
3:33 AM (10 hours ago) 3:33 AM
to firebird-devel
Fixed this - there was a set of 3 relatively independent problems.

Confirmed fix ( 22260a0b ), test committed.


 
Reply all
Reply to author
Forward
0 new messages