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

Truncate AO relation segment files before unlink #668

Closed
wants to merge 2 commits into from

Conversation

whitehawk
Copy link

@whitehawk whitehawk commented Dec 28, 2023

Problem:
Segment files of AO tables are not truncated before unlink.
As result, after relation drop if there are file descriptors of segment files,
not closed by some backend process, disk space is not returned to the OS.

Cause:
In mdunlinkfork, for an AO relation mdunlink_ao is called instead of truncating
all segment files. And mdunlink_ao doesn't perform truncation of segment files.

Fix:
Add truncation of segment files for AO tables into mdunlink_ao_perFile, called
from mdunlink_ao for each segment file.
For that purpose static function do_truncate was renamed and moved to
accessible api in fd.h.

Problem:
In cases where an AO table is created, some data is inserted, and then the
table is dropped, file descriptor of segfile will be opened still. It
stays open until session ends. Thus, disc space is not freed until the end
of the session.

Cause:
There are 2 issues:
1) mdcreate_ao is used to create a segment file during data insertion.
For creation, it calls PathNameOpenFile without closing.
File descriptor returned by PathNameOpenFile in mdcreate_ao is not stored
anywhere except the virtual file level (fd.c), where it will be cleaned
some time later only when the number of opened descriptors reaches threshold.
2) second issue happens when we run out of space. This problem is related to
file descriptors left open because of an abnormal abort of the insert command.
In function BufferedAppendWrite, once free space has ended, ereport is thrown.
Before that, the file is not closed, so after the long jump it remained open.

Fix:
Add FileClose to mdcreate_ao and BufferedAppendWrite (before throwing ereport).
@BenderArenadata
Copy link

Allure report https://allure-ee.adsw.io/launch/61185

@BenderArenadata
Copy link

Failed job Resource group isolation tests on x86_64: https://gitlab.adsw.io/arenadata/github_mirroring/gpdb/-/jobs/932873

@BenderArenadata
Copy link

Failed job Resource group isolation tests on ppc64le: https://gitlab.adsw.io/arenadata/github_mirroring/gpdb/-/jobs/932874

@BenderArenadata
Copy link

Failed job Regression tests with Postgres on ppc64le: https://gitlab.adsw.io/arenadata/github_mirroring/gpdb/-/jobs/932866

@BenderArenadata
Copy link

Failed job Regression tests with Postgres on x86_64: https://gitlab.adsw.io/arenadata/github_mirroring/gpdb/-/jobs/932865

@BenderArenadata
Copy link

Failed job Regression tests with ORCA on x86_64: https://gitlab.adsw.io/arenadata/github_mirroring/gpdb/-/jobs/932867

@BenderArenadata
Copy link

Failed job Regression tests with ORCA on ppc64le: https://gitlab.adsw.io/arenadata/github_mirroring/gpdb/-/jobs/932868

@BenderArenadata
Copy link

Failed job Behave tests on x86_64: https://gitlab.adsw.io/arenadata/github_mirroring/gpdb/-/jobs/932871

Problem:
Segment files of AO tables are not truncated before unlink.
As result, after relation drop if there are file descriptors of segment files,
not closed by some backend process, disk space is not returned to the OS.

Cause:
In mdunlinkfork, for an AO relation mdunlink_ao is called instead of truncating
all segment files. And mdunlink_ao doesn't perform truncation of segment files.

Fix:
Add truncation of segment files for AO tables into mdunlink_ao_perFile, called
from mdunlink_ao for each segment file.
For that purpose static function do_truncate was renamed and moved to
accessible api in fd.h.

+ Reverted previous commit 20aa6e1
@whitehawk whitehawk changed the title Fix orphaned file descriptors Truncate AO relation segment files before unlink Jan 17, 2024
@BenderArenadata
Copy link

Allure report https://allure-ee.adsw.io/launch/61953

@BenderArenadata
Copy link

Failed job Resource group isolation tests on x86_64: https://gitlab.adsw.io/arenadata/github_mirroring/gpdb/-/jobs/973082

@BenderArenadata
Copy link

Failed job Resource group isolation tests on ppc64le: https://gitlab.adsw.io/arenadata/github_mirroring/gpdb/-/jobs/973083

@@ -145,4 +145,6 @@ extern const char *FileGetFilename(File file);
extern void FileSetIsWorkfile(File file);
extern void FileSetIsTempFile(File file, bool isTempFile);

extern int TruncateFileByName(FileName fileName);
Copy link
Member

Choose a reason for hiding this comment

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

Why not simply put public do_truncate to md.h like mdunlink?

@whitehawk whitehawk closed this Jan 19, 2024
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.

3 participants