-
Notifications
You must be signed in to change notification settings - Fork 206
Always unlink first segment for AO/AOCO temp relation. #1656
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
base: main
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -256,6 +256,7 @@ struct truncate_ao_callback_ctx | |
| void | ||
| mdunlink_ao(RelFileNodeBackend rnode, ForkNumber forkNumber, bool isRedo) | ||
| { | ||
| int ret; | ||
| const char *path = relpath(rnode, forkNumber); | ||
|
|
||
| /* | ||
|
|
@@ -294,6 +295,19 @@ mdunlink_ao(RelFileNodeBackend rnode, ForkNumber forkNumber, bool isRedo) | |
| pfree(segPath); | ||
| } | ||
|
|
||
| /* | ||
| * Delete or truncate the first segment. See mdunlinkfork also. | ||
| */ | ||
| if (RelFileNodeBackendIsTemp(rnode)) | ||
| { | ||
| /* Next unlink the file, unless it was already found to be missing */ | ||
| ret = unlink(path); | ||
| if (ret < 0 && errno != ENOENT) | ||
| ereport(WARNING, | ||
| (errcode_for_file_access(), | ||
| errmsg("could not remove file \"%s\": %m", path))); | ||
| } | ||
|
|
||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Should also unlink the segment files beyond segment 0? How about modifying mdunlink_ao_base_relfile() and mdunlink_ao_perFile() to check RelFileNodeBackendIsTemp(rnode) and unlink immediately (mirroring the heap mdunlinkfork pattern), rather than appending a separate unlink at the end of mdunlink_ao? Something like |
||
| pfree((void *) path); | ||
| } | ||
|
|
||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for catching this!
Minor comments below:
int ret; is declared at function scope.
Better to be scoped inside the if block, or removed entirely since it's only checked against < 0 immediately.