talmacschen-arch opened a new issue, #96:
URL: https://github.com/apache/cloudberry-backup/issues/96

   ### Apache Cloudberry and cloudberry-backup version
   
   cloudberry  2.0.x & 2.1.x
   cloudberry-backup main                                                       
                                                                                
                                     
   
   ### What happened
   
   ### Summary                                               
                                                                                
                                                                                
                
     `gpbackman` makes two reasonable defaults harder than they need to be:     
                                                                                
                
                                                                                
                                                                                
                
     1. The `--history-db` flag has no fallback to the standard                 
                                                                                
                
        `$COORDINATOR_DATA_DIRECTORY` / `$MASTER_DATA_DIRECTORY` env vars
        that the Cloudberry/Greenplum environment scripts already set.          
                                                                                
                
     2. When the resolved path does not exist, SQLite silently creates an
        empty database, and the next query fails with the misleading            
                                                                                
                
        `no such table: backups`. An empty `gpbackup_history.db` is also        
                                                                                
                
        left behind in `cwd`, polluting unrelated working directories.          
                                                                                
                
                                                                                
                                                                                
                
     ### Reproduce on `main`                                                    
                                                                                
                
                                                                                
                                                                                
                
     ```console                                                                 
                                                                                
                
     $ which gpbackman                                         
     /usr/local/cloudberry/bin/gpbackman
   
     $ cd /tmp                       # any directory without a history DB
     $ gpbackman backup-info                                                    
                                                                                
                
     [ERROR]:-Unable to read data from history db. Error: no such table: backups
                                                                                
                                                                                
                
     $ ls /tmp/gpbackup_history.db                             
     -rw-r--r-- 1 gpadmin gpadmin 0 Apr 29 12:40 /tmp/gpbackup_history.db       
                                                                                
                
                                   ^^^ silently created, polluting cwd          
                                                                                
                
                                                                                
                                                                                
                
     Expected behaviour                                                         
                                                                                
                
                                                                                
                                                                                
                
     - When --history-db is omitted, gpbackman should look up                   
                                                                                
                
     $COORDINATOR_DATA_DIRECTORY/gpbackup_history.db (and then
     $MASTER_DATA_DIRECTORY/gpbackup_history.db for older installs)             
                                                                                
                
     before falling back to cwd. This matches how operators already             
                                                                                
                
     source the cluster environment.                                            
                                                                                
                
     - When the resolved file does not exist, gpbackman should fail loud        
                                                                                
                
     with a clear, actionable error and not create an empty SQLite              
                                                                                
                
     database on disk.                                                          
                                                                                
                
                                                               
     Why this matters                                                           
                                                                                
                
                                                               
     - Operators routinely run gpbackman from ~ after sourcing                  
                                                                                
                
     greenplum_path.sh / equivalent. Today they must always type the
     full coordinator path, which is fragile across cluster layouts.            
                                                                                
                
     - The "silent create + cryptic later error" UX has bitten me during        
                                                                                
                
     exploration; the failure mode is non-local and easy to misdiagnose         
                                                                                
                
     as a corrupt history database.                                             
                                                                                
                
                                                                                
                                                                                
                
    
   
   ### What you think should happen instead
   
    Proposed approach                                                           
                                                                                
               
                                                                                
                                                                                
                
     - Resolve --history-db empty → $COORDINATOR_DATA_DIRECTORY →               
                                                                                
                
     $MASTER_DATA_DIRECTORY → bare filename in cwd (last resort,
     preserves existing behaviour).                                             
                                                                                
                
     - In OpenHistoryDB, pre-check with os.Stat and open SQLite via the
     file:<path>?mode=rw URI (read+write but never create).                     
                                                                                
                
     - Friendly error message that names the missing path and points at the
     flag and env vars.                                                         
                                                                                
                
                                                                                
                                                                                
                
     PR                                                                         
                                                                                
                
                                                                                
                                                                                
                
     I have a patch ready that implements the above with unit tests and         
                                                                                
                
     docs updates: #.
   
   ### How to reproduce
   
   _No response_
   
   ### Operating System
   
   rockylinux 9.x / RHEL 9.X
   
   ### Anything else
   
   _No response_
   
   ### Are you willing to submit PR?
   
   - [x] Yes, I am willing to submit a PR!
   
   ### Code of Conduct
   
   - [x] I agree to follow this project's [Code of 
Conduct](https://github.com/apache/cloudberry/blob/main/CODE_OF_CONDUCT.md).
   


-- 
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