Chong-cn opened a new issue, #1844:
URL: https://github.com/apache/cloudberry/issues/1844

   ## Environment
   
   - **Version**: PostgreSQL 14.4 (Apache Cloudberry 
2.1.0-devel+dev.30.g2800e887d8 build 127939) on x86_64-pc-linux-gnu, compiled 
by gcc (GCC) 12.2.1, 64-bit
   
   ## Problem Description
   
   When multiple directory tables share the same external tablespace 
(OSS/HDFS), all uploaded files are stored under a common path:
   
   ```
   <OSS_TABLESPACE_DIR>/<tablespace_oid>/<database_oid>/0_dirtable/
   ```
   
   When `DROP DIRECTORY TABLE ... WITH CONTENT` is executed on **one** 
directory table, the entire `<OSS_TABLESPACE_DIR>` root path is deleted, 
causing **all** directory tables in the same database to lose their data files.
   
   ## Steps to Reproduce
   
   ```sql
   -- Step 1: Create Storage Server
   CREATE STORAGE SERVER s3_server
     OPTIONS(protocol 'S3AV2', endpoint '10.14.6.166:9000',
             https 'false', virtual_host 'false');
   
   -- Step 2: User Mapping
   CREATE STORAGE USER MAPPING FOR PUBLIC
     STORAGE SERVER s3_server
     OPTIONS (accesskey 'minioadmin', secretkey 'minioadmin');
   
   -- Step 3: Tablespace
   CREATE TABLESPACE s3_tbs
     LOCATION '/test/tbs01'
     SERVER s3_server
     HANDLER '$libdir/dfs_tablespace, remote_file_handler';
   
   -- Step 4: Create two directory tables sharing the same tablespace
   CREATE DIRECTORY TABLE public.oss_dir1 TABLESPACE s3_tbs;
   CREATE DIRECTORY TABLE public.oss_dir2 TABLESPACE s3_tbs;
   
   -- Step 5: Upload files to both tables
   \COPY BINARY oss_dir1 FROM '/tmp/data1.csv' 'data1.csv';
   \COPY BINARY oss_dir2 FROM '/tmp/data2.csv' 'data2.csv';
   
   -- Step 6: Drop only oss_dir1 with content
   DROP DIRECTORY TABLE oss_dir1 WITH CONTENT;
   ```
   
   ## Actual Result
   
   After dropping `oss_dir1`, the data files of `oss_dir2` are **also deleted** 
— the entire `<OSS_TABLESPACE_DIR>` root is removed instead of only the files 
belonging to `oss_dir1`.
   
   ## Expected Result
   
   `DROP DIRECTORY TABLE oss_dir1 WITH CONTENT` should only delete the physical 
files associated with `oss_dir1`, leaving the files of other directory tables 
(e.g., `oss_dir2`) intact.
   
   ## Root Cause Analysis
   
   The delete operation appears to remove the tablespace root directory rather 
than scoping the deletion to the specific directory table's subdirectory, 
causing unintended data loss for all co-located tables.
   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to