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

Dirty RDB$PAGES after an error after phase 3 of create_relation [CORE5677] #5943

Closed
firebird-automations opened this issue Dec 6, 2017 · 7 comments

Comments

@firebird-automations
Copy link
Collaborator

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

        129 

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

@firebird-automations
Copy link
Collaborator Author

Modified by: @romansimakov

assignee: Roman Simakov [ roman-simakov ]

@firebird-automations
Copy link
Collaborator Author

Modified by: @romansimakov

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

resolution: Fixed [ 1 ]

Fix Version: 3.0.3 [ 10810 ]

Fix Version: 4.0 Beta 1 [ 10750 ]

@firebird-automations
Copy link
Collaborator Author

Commented by: @romansimakov

Scenario for test case is better and more simple in CORE2284

@firebird-automations
Copy link
Collaborator Author

Modified by: @pavel-zotov

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

QA Status: No test => Covered by another test(s)

Test Details: See test for CORE2284

@firebird-automations
Copy link
Collaborator Author

Modified by: @pavel-zotov

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

@firebird-automations
Copy link
Collaborator Author

Commented by: Jesus Angel Garcia Zarco (cointec)

2.5.X will not have a patch for this issue?

@firebird-automations
Copy link
Collaborator Author

Commented by: @dyemanov

v2.5 is less affected. We'll consider a backport later.

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