Skip to content

Fix gp_log_collector to query database for actual log directory path#14

Merged
bluethumpasaurus merged 1 commit intomasterfrom
copilot/fix-13
Sep 18, 2025
Merged

Fix gp_log_collector to query database for actual log directory path#14
bluethumpasaurus merged 1 commit intomasterfrom
copilot/fix-13

Conversation

Copy link
Copy Markdown
Contributor

Copilot AI commented Sep 18, 2025

The gp_log_collector command was hardcoding the log directory path as $HOME/gpdb/gp-master/gpseg-1/pg_log, which often doesn't exist in actual Greenplum installations. This caused the command to fail with:

Error collecting logs: failed to walk log directory: lstat /home/gpadmin/gpdb/gp-master/gpseg-1/pg_log: no such file or directory

The fix implements the suggested solution by querying the database first to get the actual log directory:

select distinct datadir || '/log' from gp_segment_configuration where content='-1';

Changes Made

  • Added getLogDirectoryFromDB(): Queries the database for the actual coordinator log directory path
  • Enhanced error handling: Uses panic recovery to gracefully handle database connection failures
  • Smart fallback: When database is unavailable, falls back to the existing hardcoded path behavior
  • Preserved compatibility: All existing command-line flags and functionality remain unchanged

Behavior

  • With database available: Uses the real log directory from gp_segment_configuration
  • Without database: Gracefully falls back to the previous hardcoded path logic
  • Debug logging: Provides clear information about which method is being used (--verbose flag)

The fix ensures gp_log_collector works correctly in real Greenplum environments while maintaining backwards compatibility for edge cases where the database query might fail.

Fixes #13.


💬 Share your feedback on Copilot coding agent for the chance to win a $200 gift card! Click here to start the survey.

@bluethumpasaurus bluethumpasaurus marked this pull request as ready for review September 18, 2025 13:32
@bluethumpasaurus bluethumpasaurus merged commit 587b65a into master Sep 18, 2025
1 check passed
Copilot AI changed the title [WIP] gp_log_collector looking for logs in the incorrect directory Fix gp_log_collector to query database for actual log directory path Sep 18, 2025
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.

gp_log_collector looking for logs in the incorrect directory

2 participants