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

PG-799: Implement smgr GUC variable and chaining #23

Open
wants to merge 1 commit into
base: TDE_REL_17_STABLE
Choose a base branch
from

Conversation

dutow
Copy link
Collaborator

@dutow dutow commented Dec 2, 2024

No description provided.

@dutow dutow requested a review from dAdAbird December 2, 2024 08:07
Copy link
Member

@dAdAbird dAdAbird left a comment

Choose a reason for hiding this comment

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

It'd be nice to have some overview/docs on how to use the new interface

Comment on lines +1997 to +1999
// setup a dummy chain with md, for tools
storage_manager_chain.chain[0] = MdSMgrId;
storage_manager_chain.size = 1;
Copy link
Member

Choose a reason for hiding this comment

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

Tools might need to setup a chain as well. Is this something future improvements?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Yes, tools are ignored for now. We'll have to revisit that question later, and probably for WAL too - we need some kind of extension support for tools.

@@ -175,6 +174,18 @@ smgrshutdown(int code, Datum arg)
}
}

#define SMGR_CHAIN_LOOKUP(SMGR_METHOD) while(chain_index < reln->smgr_chain.size && smgrsw[reln->smgr_chain.chain[chain_index]].SMGR_METHOD == NULL) chain_index++
#define SMGR_CHAIN_CHECK_END_ASSERT() Assert(chain_index < reln->smgr_chain.size)
Copy link
Member

Choose a reason for hiding this comment

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

Should we have a check somewhere that the method we ended up isn't NULL? In case of all the chain has NULL for create, for example. As far as I can see there is a special case for shutdown but the rest of the methods should be implemented at least at the end of the chain

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Yes, I'll add a check for "tail" smgrs.

#define SMGR_CHAIN_CHECK_END_ASSERT() Assert(chain_index < reln->smgr_chain.size)

void
smgr_open_internal(SMgrRelation reln, SmgrChainIndex chain_index)
Copy link
Member

Choose a reason for hiding this comment

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

It bothers me a bit that functions to be called from external entities have _internal in the name. Maybe smgr_open_next?

Plus it'd be nice to reference chain_index implicitly w/o passing it as an arg. But I can't come up with how) Maybe at least have some macros so user function don't have to write chain_index + 1 all the time?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

"Plus it'd be nice to reference chain_index implicitly w/o passing it as an arg." - we can use macros, but that won't be pretty, I tried.

Or we can go with global state, but I wanted to avoid that, because if a storage manager ends up calling sql functions, like we did when we stored metadata in the catalog, we'll end up with multiple levels of smgr calls, and a global state would break - unless I also add handling for this, which would again complicate things.

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.

2 participants