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
In case of error after phase 3 of create_relation in dfw the engine have filled RDB$PAGES in system transaction. Changes of RDB$RELATIONS and RDB$DATABASE are doing in user transaction and they rolled back. As result we have a couple of records in RDB$PAGES. Later if some attachment will scan pages it creates an object jrd_rel in att_relations and marks it by flag REL_check_existance and later REL_deleted.
If we will try to create a table in this attachment we can do it. But at least we will have duplicated records in RDB$PAGES for the relation. Then if we will try to create an index for that table MET_lookup_relation_id will check REL_deleted and returns NULL. Index creation will fails.
Reconnect can helps but duplicates of RDB$PAGES is not good in any case.
Here is a scenario to reproduce it by 2 terminals (1: and 2:) on Classic arcitecture:
2: create database '/tmp/d.fdb';
2: set transaction read committed;
1: gdb --args ./isql /tmp/d.fdb
1: r
1: Ctrl+C
1: break check_not_null if (phase==3)
1: c
1: create table tn(i integer);
1: insert into tn values(NULL);
1: commit;
1: set autoddl off;
1: set transaction read committed;
1: create table terr(i integer);
1: alter table tn alter i set not null;
1: commit;
1: will break in breakpoint
2: select * from rdb$pages; // to force write RDB$PAGES via AST
1: c
1: ERROR: Cannot make field I of table TN NOT NULL because there are NULLs present
1+2: Ctrl+D to exit
Now we can connect to the database and check:
SQL> select * from rdb$pages where rdb$relation_id=129;
Submitted by: @romansimakov
In case of error after phase 3 of create_relation in dfw the engine have filled RDB$PAGES in system transaction. Changes of RDB$RELATIONS and RDB$DATABASE are doing in user transaction and they rolled back. As result we have a couple of records in RDB$PAGES. Later if some attachment will scan pages it creates an object jrd_rel in att_relations and marks it by flag REL_check_existance and later REL_deleted.
If we will try to create a table in this attachment we can do it. But at least we will have duplicated records in RDB$PAGES for the relation. Then if we will try to create an index for that table MET_lookup_relation_id will check REL_deleted and returns NULL. Index creation will fails.
Reconnect can helps but duplicates of RDB$PAGES is not good in any case.
Here is a scenario to reproduce it by 2 terminals (1: and 2:) on Classic arcitecture:
2: create database '/tmp/d.fdb';
2: set transaction read committed;
1: gdb --args ./isql /tmp/d.fdb
1: r
1: Ctrl+C
1: break check_not_null if (phase==3)
1: c
1: create table tn(i integer);
1: insert into tn values(NULL);
1: commit;
1: set autoddl off;
1: set transaction read committed;
1: create table terr(i integer);
1: alter table tn alter i set not null;
1: commit;
1: will break in breakpoint
2: select * from rdb$pages; // to force write RDB$PAGES via AST
1: c
1: ERROR: Cannot make field I of table TN NOT NULL because there are NULLs present
1+2: Ctrl+D to exit
Now we can connect to the database and check:
SQL> select * from rdb$pages where rdb$relation_id=129;
RDB$PAGE_NUMBER RDB$RELATION_ID RDB$PAGE_SEQUENCE RDB$PAGE_TYPE
=============== =============== ================= =============
186 129 0 4
187 129 0 6
SQL> select * from rdb$relations where rdb$relation_id=129;
SQL> select rdb$relation_id from rdb$database;
RDB$RELATION_ID
The idea of fix is to cleanup RDB$PAGES and release physically located pages at phase 0 of create_relation. I'll prepare PR soon.
Commits: 9afef19 bfb008f 3f62ad0 caa21df
====== Test Details ======
See test for CORE2284
The text was updated successfully, but these errors were encountered: