You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@cloudberry.apache.org by av...@apache.org on 2025/11/15 06:17:24 UTC

(cloudberry) branch main updated: Fix calculating size of a database or tablespace

This is an automated email from the ASF dual-hosted git repository.

avamingli pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/cloudberry.git


The following commit(s) were added to refs/heads/main by this push:
     new a64917415eb Fix calculating size of a database or tablespace
a64917415eb is described below

commit a64917415eb2f557657562770b6e6e19d1fe3426
Author: Hao Wu <gf...@gmail.com>
AuthorDate: Fri Nov 14 00:54:50 2025 +0000

    Fix calculating size of a database or tablespace
    
    pg_database_size only counts phyical files in database directory.
    The sub-directory under database directory can't represent the real
    storage size. The same issue happens on calculating the size of
    tablespace as well.
    
    Currently, PAX creates a separate directory to storage all its
    phyical files, like micro-partition files, visibility-map files, etc.
    To include the phyical files occupied by PAX tables, `db_dir_size`
    should calculate its sub-directories recursively.
---
 src/backend/utils/adt/dbsize.c | 9 +++++++++
 1 file changed, 9 insertions(+)

diff --git a/src/backend/utils/adt/dbsize.c b/src/backend/utils/adt/dbsize.c
index e41dc619b89..d163a7f38ea 100644
--- a/src/backend/utils/adt/dbsize.c
+++ b/src/backend/utils/adt/dbsize.c
@@ -153,6 +153,15 @@ db_dir_size(const char *path)
 			continue;
 
 		snprintf(filename, sizeof(filename), "%s/%s", path, direntry->d_name);
+		if (direntry->d_type == DT_DIR)
+		{
+			/**
+			 * Recurse into subdirectory. PAX stores data file in a separate
+			 * directory, so we need to account for that.
+			 */
+			dirsize += db_dir_size(filename);
+			continue;
+		}
 
 		if (stat(filename, &fst) < 0)
 		{


---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@cloudberry.apache.org
For additional commands, e-mail: commits-help@cloudberry.apache.org