Skip to content

fix: pg_isready healthcheck by user POSTGRES_USER - #189

Merged
amirasaran merged 1 commit into
watercrawl:mainfrom
tomo-v:fix/pg_isready-user
Dec 10, 2025
Merged

amirasaran merged 1 commit into
watercrawl:mainfrom
tomo-v:fix/pg_isready-user

Conversation

@tomo-v

@tomo-v tomo-v commented Dec 2, 2025 •

Copy link
Copy Markdown
Contributor

User description

Description

change docker-compose.yml healthcheck to use pg_isready by user POSTGRES_USER

Related Issue

Fixes #188

Type of Change

  • Bug fix (non-breaking change which fixes an issue)

UI Changes

Testing

  • Test by docker compose logs

Checklist

  • My code follows the project's style guidelines
  • I have performed a self-review of my code
  • I have commented my code, particularly in hard-to-understand areas
  • I have made corresponding changes to the documentation
  • My changes generate no new warnings
  • I have added tests that prove my fix is effective or that my feature works
  • New and existing unit tests pass locally with my changes
  • Any dependent changes have been merged and published

PR Type

Bug fix


Description

  • Fix pg_isready healthcheck to use POSTGRES_USER environment variable

  • Ensures healthcheck runs with correct database user credentials


Diagram Walkthrough

flowchart LR
  A["pg_isready without user"] -- "add -U flag" --> B["pg_isready -U POSTGRES_USER"]
  B -- "uses env variable" --> C["Correct user authentication"]
Loading

File Walkthrough

Relevant files
Bug fix
docker-compose.yml
Add POSTGRES_USER to pg_isready healthcheck                           

docker/docker-compose.yml

  • Updated PostgreSQL healthcheck command to include -U ${POSTGRES_USER}
    flag
  • Ensures pg_isready command authenticates with the configured database
    user
  • Fixes healthcheck failures when POSTGRES_USER differs from default
    'postgres'
+1/-1     

@dosubot dosubot Bot added the size:XS This PR changes 0-9 lines, ignoring generated files. label Dec 2, 2025
@qodo-code-review

Copy link
Copy Markdown
Contributor

PR Compliance Guide 🔍

Below is a summary of compliance checks for this PR:

Security Compliance
🟢
No security concerns identified No security vulnerabilities detected by AI analysis. Human verification advised for critical code.
Ticket Compliance
🟡
🎫 #188
🟢 Adjust PostgreSQL healthcheck to use pg_isready with the configured POSTGRES_USER.
🔴 Prevent recurring "FATAL: role 'root' does not exist" errors in Docker logs.
⚪ Solution should work via docker-compose healthcheck without introducing new warnings.
Codebase Duplication Compliance
⚪
Codebase context is not defined

Follow the guide to enable codebase context checks.

Custom Compliance
🟢
Generic: Meaningful Naming and Self-Documenting Code

Objective: Ensure all identifiers clearly express their purpose and intent, making code
self-documenting

Status: Passed

Learn more about managing compliance generic rules or creating your own custom rules

Generic: Secure Error Handling

Objective: To prevent the leakage of sensitive system information through error messages while
providing sufficient detail for internal debugging.

Status: Passed

Learn more about managing compliance generic rules or creating your own custom rules

Generic: Secure Logging Practices

Objective: To ensure logs are useful for debugging and auditing without exposing sensitive
information like PII, PHI, or cardholder data.

Status: Passed

Learn more about managing compliance generic rules or creating your own custom rules

Generic: Security-First Input Validation and Data Handling

Objective: Ensure all data inputs are validated, sanitized, and handled securely to prevent
vulnerabilities

Status: Passed

Learn more about managing compliance generic rules or creating your own custom rules

⚪
Generic: Comprehensive Audit Trails

Objective: To create a detailed and reliable record of critical system actions for security analysis
and compliance.

Status:
No audit logs: The added healthcheck command does not implement or affect audit logging of critical
actions, and there is no evidence in this diff that such logging exists for related
operations.

Referred Code
test: [ "CMD-SHELL", "pg_isready -U ${POSTGRES_USER}" ]
interval: 10s

Learn more about managing compliance generic rules or creating your own custom rules

Generic: Robust Error Handling and Edge Case Management

Objective: Ensure comprehensive error handling that provides meaningful context and graceful
degradation

Status:
Healthcheck errors: The healthcheck command lacks explicit handling for failures or edge cases (e.g.,
specifying host/port or waiting for env expansion issues), and the diff provides no
context on retry/backoff beyond defaults.

Referred Code
test: [ "CMD-SHELL", "pg_isready -U ${POSTGRES_USER}" ]
interval: 10s
timeout: 5s
retries: 5

Learn more about managing compliance generic rules or creating your own custom rules

Compliance status legend 🟢 - Fully Compliant
🟡 - Partial Compliant
🔴 - Not Compliant
⚪ - Requires Further Human Verification
🏷️ - Compliance label

@dosubot dosubot Bot added the 🛠️ bug:backend API, Django, Celery issues label Dec 2, 2025
@qodo-code-review

Copy link
Copy Markdown
Contributor

PR Code Suggestions ✨

Explore these optional code suggestions:

CategorySuggestion                                                                                                                                    Impact
Possible issue
Specify database name in healthcheck

Update the PostgreSQL healthcheck command to also specify the database name
using the -d ${POSTGRES_DB} flag to prevent failures when the user and database
names differ.

docker/docker-compose.yml [201]

-test: [ "CMD-SHELL", "pg_isready -U ${POSTGRES_USER}" ]
+test: [ "CMD-SHELL", "pg_isready -U ${POSTGRES_USER} -d ${POSTGRES_DB}" ]
  • Apply / Chat
Suggestion importance[1-10]: 7

__

Why: The suggestion correctly identifies a potential failure in the healthcheck when POSTGRES_USER and POSTGRES_DB have different values, and provides a robust fix.

Medium
  • More

@alireza1992 alireza1992 left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

LGTM

@amirasaran
amirasaran merged commit 8069ef5 into watercrawl:main Dec 10, 2025
2 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

🛠️ bug:backend API, Django, Celery issues Review effort 1/5 size:XS This PR changes 0-9 lines, ignoring generated files.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[BUG] docker log repots [FATAL: role "root" does not exist] every 10 seconds

2 participants