Skip to content

[Bug]: When using postgresql as database, high postgresql transaction rollback rate detected #1108

@xincheng-96

Description

@xincheng-96

🐞 Bug Summary

When using external postgresql as database, high postgresql transaction rollback rate detected (possibly due to health check). Even though the mcp-gateway has not been put in use (no mcp server registered, no client trying to connect)
SessionLocal = sessionmaker(autocommit=False, autoflush=False, bind=engine)

🧩 Affected Component

Select the area of the project impacted:

  • mcpgateway - API
  • mcpgateway - UI (admin panel)
  • mcpgateway.wrapper - stdio wrapper
  • Federation or Transports
  • CLI, Makefiles, or shell scripts
  • Container setup (Docker/Podman/Compose)
  • Other (explain below)

🔁 Steps to Reproduce

  1. start the mcp-gateway with postgresql as database
  2. check postgresql logs
    2025-09-22 04:16:03.259 PDT,"mcp_gateway_db_owner","mcp_gateway_db",3635047,"10.137.80.84:45972",68d12f8a.377767,31,"BEGIN",2025-09-22 04:14:18 PDT,53/2396001,0,LOG,00000,"duration: 0.028 ms statement: BEGIN",,,,,,,,,"app - 10.36.67.18:24158","client backend",,6650430479887907887 2025-09-22 04:16:03.260 PDT,"mcp_gateway_db_owner","mcp_gateway_db",3635047,"10.137.80.84:45972",68d12f8a.377767,32,"SELECT",2025-09-22 04:14:18 PDT,53/2396001,0,LOG,00000,"duration: 0.037 ms statement: SELECT 1",,,,,,,,,"app - 10.36.67.18:24158","client backend",,6865378226349601843 2025-09-22 04:16:03.261 PDT,"mcp_gateway_db_owner","mcp_gateway_db",3635047,"10.137.80.84:45972",68d12f8a.377767,33,"ROLLBACK",2025-09-22 04:14:18 PDT,53/0,0,LOG,00000,"duration: 0.029 ms statement: ROLLBACK",,,,,,,,,"app - 10.36.67.18:24158","client backend",,3749380189022910195

🤔 Expected Behavior

no rollback transactions on postgresql during normal execution.
allow configuration of autocommit to true when using postgresql

📓 Logs / Error Output

as above


🧠 Environment Info

You can retrieve most of this from the /version endpoint.

Key Value
Version or commit v0.6.0 and v0.7.0
Runtime python 3.11.11
Platform / OS Ubuntu 16.2-1.pgdg22.04+1
Container kubernetes

🧩 Additional Context (optional)

Autocommit=False hard coded in db.py https://github.com/IBM/mcp-context-forge/blob/v0.7.0/mcpgateway/db.py#L150

Image

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't workingtriageIssues / Features awaiting triage

    Type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions