StackStorm / StackStorm/st2

st2 services ignore MongoDB failures

Open
#4,778 2 comments 2 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

bug HA mongodb
Dominant language
Python
Stars
6.5k
Forks
787
PR merge metrics
No merged PRs in 30d

Description

Problem

When StackStorm services are already running and MongoDB backend suddenly goes down, no services usually detect connection error, report that in logs nor try to re-connect in a pro-active way. They keep running and "alive" as nothing happened.

Reproducing
  1. Start StackStorm, follow the logs
  2. Stop MongoDB
  3. Notice that StackStorm services DGAF about any MongoDB connection issues

Bonus points go to st2api which even normally responds with empty results on HTTP requests.

It turns out that services start to report connection errors only when they're processing something and expecting a response from DB request. This can be tens of minutes, depending on st2 cluster workload.

This lazy behavior leads to a situation when we think service is working OK, while in fact it's just pretending and loosing incoming requests with no DB connection. https://github.com/StackStorm/st2/issues/4777 and #4020 is somewhat related.

Expected behavior

Good behavior if mongo client would verify connection in background loop and report back ASAP if there is an error in logs.

Ideally if it can support heartbeat setting in st2.conf and check pro-actively for DB connection aliveness:

Note also https://api.mongodb.com/python/current/api/pymongo/monitoring.html
HeartbeatLogger and ConnectionPoolLogger

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start by reproducing the failure with StackStorm services running, then stop MongoDB and follow the service logs, especially st2api responses. Read the MongoDB heartbeat and monitoring references linked in the issue and inspect the st2.conf connection settings. Done means services detect and report the outage promptly and define the expected reconnection behavior.

Written by the indexing model from the issue text.

Assessment

Tech stack
mongodb, python
Domain
backend, databases, observability
Issue type
Bug
Difficulty
5/5
Estimated time
Over a week
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
25/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.