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

Increase index flags capacity in ODS14 #8340

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open

Conversation

dyemanov
Copy link
Member

@dyemanov dyemanov commented Dec 4, 2024

This PR changes the irt_repeat layout to allow more bits for index flags and native TraNumber storage (and also fixes a few related things). The irt_repeat size increases from 12 bytes to 16 bytes, but I find it acceptable. We can avoid the union and remove the irt_in_progress flag, but the irt_repeat size will grow to 24 bytes which doubles the initial storage, so I'm not sure whether it's worth it (as it limits the maximum number of indices per table).

I tried to partially synchronize with the metacache branch to simplify the merge later, as Alex already needed to have some of these changes in his branch. I'm ready to adjust the patch if needed.

Other PRs for ODS14 will follow, so I'd suggest to review them separately but merge together in a batch, to avoid recreating all existing ODS14 databases often due to ongoing ODS changes.

…4. Avoid private data members in ODS structures. Fix SLONG->ULONG in page numbers in gstat.
@dyemanov dyemanov self-assigned this Dec 4, 2024
{
FB_UINT64 irt_transaction; // transaction in progress
ULONG irt_root; // page number of index root
};
Copy link
Member

Choose a reason for hiding this comment

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

When it was private there was guarantee of consistent usage of irt_root, irt_transaction and flag irt_in_progress.
Why make it public and open way for errors ?

Copy link
Member Author

Choose a reason for hiding this comment

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

Honestly, private data members (and getters/setters) just look unnatural (to me) in ODS structures, IMHO they complicate things. That said, I agree about usage consistency. Now it's also consistent if you check for isEmpty() / inProgress() before using irt_root / irt_transaction and I thought that's enough. I can revert to private members if your disagree.

Copy link
Member

Choose a reason for hiding this comment

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

Honestly, private data members (and getters/setters) just look unnatural (to me) in ODS structures, IMHO they complicate things. That said, I agree about usage consistency. Now it's also consistent if you check for isEmpty() / inProgress() before using irt_root / irt_transaction and I thought that's enough. I can revert to private members if your disagree.

For me, it is good case when consistency is over complexity.

Copy link
Member

Choose a reason for hiding this comment

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

I agree with Vlad - private members look better to me, specially in a cases when setter may change a few data members in sync and result of getter sometimes depends from more than single field.

Probably with wider than before IRT less such tricks are needed - but for example setting some state in flags that requires root page to be set together with assigning root page value still remains.

Copy link
Member Author

Choose a reason for hiding this comment

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

OK, to be changed back.

if (unique)
{
index_desc idx;
{
// No need to evaluate index expression and/or condition
AutoSetRestoreFlag<UCHAR> flags(&root_page.irt_rpt[id].irt_flags,
AutoSetRestoreFlag<USHORT> flags(&root_page->irt_rpt[id].irt_flags,
Copy link
Member

Choose a reason for hiding this comment

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

Is it necessary to specify template arg, could it be auto deducted from ctor arguments by compiler ?

Copy link
Member

Choose a reason for hiding this comment

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

It's C++17 feature (https://en.cppreference.com/w/cpp/language/class_template_argument_deduction)
AFAIK, we were not using it, but we could.

Copy link
Member

Choose a reason for hiding this comment

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

I've found at least one such usage of AutoSetRestore in remote.cpp - see PortsCleanup::closePorts().

Copy link
Member Author

@dyemanov dyemanov Dec 5, 2024

Choose a reason for hiding this comment

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

Auto deduction works for irt_expression, but fails for irt_expression | irt_condition, it should be explicitly casted to USHORT to work and it somewhat defeats the idea.

Nevertheless, I'd suggest (outside this PR) to remove AutoSetRestoreFlag here at all and instead add the needed lookup flags to BTR_description. Because the index root page may be locked as LCK_read but we modify data there (even if temporarily) -- this looks hackery.

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

Successfully merging this pull request may close these issues.

4 participants