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

Fix #7664: DROP TABLE executed for a table with big records may lead to "wrong page type" or "end of file" error #7666

Merged
merged 3 commits into from
Jul 7, 2023

Conversation

ilya071294
Copy link
Collaborator

No description provided.

…lead to "wrong page type" or "end of file" error

The reason is that rhd_large flag can be set while rhd_incomplete flag is not set. It happens when a record which has 2 or more fragments is updated to a smaller record which fits on one page.
src/jrd/dpm.epp Outdated

CCH_RELEASE_TAIL(tdbb, &window);
PAG_release_page(tdbb, window.win_page, ZERO_PAGE_NUMBER);
if (dpage->dpg_header.pag_flags & dpg_orphan)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could you explain this condition ?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If a database was created by the server which doesn't have the fix, it's possible to get a secondary data page here. But the code below works only for orphan data pages. It's just a protection from incorrect usage of rpb_large/rhd_large flag.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The code used to release data pages allocated for fragments of big records when relation is dropped.
Fragments are allocated on own separate data pages and is not marked as orphan.
How this new code is going to release fragment's pages ?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sorry, fragment's page is marked as orphan, I missed it.
But it could be better (safer) to check also dpg_full flag and number of records on page, same as in analyze_fragments() at dba.epp

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fragments are allocated on own separate data pages and is not marked as orphan.
How this new code is going to release fragment's pages ?

If a data page is not an orphan then it's included in a pointer page. Such pages will be released in DPM_delete_relation_pages function (note that it checks rhd_large flag for secondary data pages as well). It's not the task of delete_tail function.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

But it could be better (safer) to check also dpg_full flag and number of records on page, same as in analyze_fragments() at dba.epp

I agree. But I just looked at analyze_fragments() and the condition there is a bit confusing for me. If a data page has dpg_full and dpg_count = 1 but doesn't have dpg_orphan, the condition is still true, right?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, analyze_fragments() is not as accurate (or paranoid) as it might be ;)
But you get the idea - lets check for all 3 conditions to be absolutely sure.

@hvlad hvlad self-assigned this Jul 7, 2023
@hvlad hvlad merged commit 6d46a67 into FirebirdSQL:master Jul 7, 2023
23 checks passed
hvlad added a commit that referenced this pull request Jul 7, 2023
Fix #7664: DROP TABLE executed for a table with big records may lead to "wrong page type" or "end of file" error
@ilya071294 ilya071294 deleted the 5_0_drop_table_fix branch July 7, 2023 12:06
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants