prometheus: Random scrape targets get stuck

What did you do?

Running 3 independent prometheus instances on 3 hosts. From prometheus version 2.49.0 we are facing random scrape targets get stuck on one of the servers. Restarting the prometheus service on the stuck server resolve the problem.

Looks like prometheus is getting stuck in some goroutines Lock issue. Include debug log further down in this issue.

What did you expect to see?

No stuck scrape targets

What did you see instead? Under which circumstances?

00:45 (Denmark GMT+1) this morning we have random stuck scrape targets on one of our 3 prometheus servers

One example of stuck scrape targets: Screenshot from 2024-02-21 07-48-39

Prometheus service did hang on subsequently restart:

Feb 21 09:02:50 prometheus-p101 prometheus[256640]: ts=2024-02-21T08:02:50.738Z caller=main.go:874 level=warn msg="Received SIGTERM, exiting gracefully..."
Feb 21 09:02:50 prometheus-p101 prometheus[256640]: ts=2024-02-21T08:02:50.738Z caller=main.go:898 level=info msg="Stopping scrape discovery manager..."
Feb 21 09:02:50 prometheus-p101 prometheus[256640]: ts=2024-02-21T08:02:50.738Z caller=main.go:912 level=info msg="Stopping notify discovery manager..."
Feb 21 09:02:50 prometheus-p101 prometheus[256640]: ts=2024-02-21T08:02:50.738Z caller=manager.go:160 level=info component="rule manager" msg="Stopping rule manager..."
Feb 21 09:02:50 prometheus-p101 prometheus[256640]: ts=2024-02-21T08:02:50.738Z caller=main.go:908 level=info msg="Notify discovery manager stopped"
Feb 21 09:02:50 prometheus-p101 prometheus[256640]: ts=2024-02-21T08:02:50.738Z caller=main.go:894 level=info msg="Scrape discovery manager stopped"
Feb 21 09:02:50 prometheus-p101 systemd[1]: Stopping prometheus.service...
Feb 21 09:04:20 prometheus-p101 systemd[1]: prometheus.service: State 'stop-sigterm' timed out. Killing.
Feb 21 09:04:20 prometheus-p101 systemd[1]: prometheus.service: Killing process 256640 (prometheus) with signal SIGKILL.
Feb 21 09:04:20 prometheus-p101 systemd[1]: prometheus.service: Killing process 256651 (prometheus) with signal SIGKILL.
Feb 21 09:04:20 prometheus-p101 systemd[1]: prometheus.service: Killing process 256653 (n/a) with signal SIGKILL.
Feb 21 09:04:20 prometheus-p101 systemd[1]: prometheus.service: Killing process 256654 (n/a) with signal SIGKILL.
Feb 21 09:04:20 prometheus-p101 systemd[1]: prometheus.service: Killing process 256658 (n/a) with signal SIGKILL.
Feb 21 09:04:20 prometheus-p101 systemd[1]: prometheus.service: Killing process 256659 (prometheus) with signal SIGKILL.
Feb 21 09:04:20 prometheus-p101 systemd[1]: prometheus.service: Killing process 256660 (n/a) with signal SIGKILL.
Feb 21 09:04:20 prometheus-p101 systemd[1]: prometheus.service: Killing process 256661 (n/a) with signal SIGKILL.
Feb 21 09:04:20 prometheus-p101 systemd[1]: prometheus.service: Killing process 257000 (n/a) with signal SIGKILL.
Feb 21 09:04:20 prometheus-p101 systemd[1]: prometheus.service: Killing process 279274 (n/a) with signal SIGKILL.
Feb 21 09:04:20 prometheus-p101 systemd[1]: prometheus.service: Killing process 512787 (n/a) with signal SIGKILL.
Feb 21 09:04:23 prometheus-p101 systemd[1]: prometheus.service: Main process exited, code=killed, status=9/KILL
Feb 21 09:04:23 prometheus-p101 systemd[1]: prometheus.service: Failed with result 'timeout'.
Feb 21 09:04:23 prometheus-p101 systemd[1]: Stopped prometheus.service.
Feb 21 09:04:23 prometheus-p101 systemd[1]: prometheus.service: Consumed 1d 16h 52min 39.470s CPU time, read 693.5K from disk, written 0B to disk, received 222.3G IP traffic, sent 5.5G IP traffic.
Feb 21 09:04:23 prometheus-p101 systemd[1]: Started prometheus.service.


### System information

Linux 6.1.77 x86_64

### Prometheus version

```text
prometheus, version 2.49.0 (branch: unknown, revision: unknown)
  build user:       nix@nixpkgs
  build date:       unknown
  go version:       go1.21.5
  platform:         linux/amd64
  tags:             builtinassets

Prometheus configuration file

No response

Alertmanager version

No response

Alertmanager configuration file

No response

Logs

No response

About this issue

  • Original URL
  • State: open
  • Created 3 years ago
  • Comments: 18 (11 by maintainers)

Most upvoted comments

You say the problem started with 2.49.0; what was the last version where you didn’t see the problem?

Thanks @bboreham for looking into this issue. It was a bit to bold when I did state that the problem did start from ver. 2.49.0. Actually we have also seen it one time on ver 2.44.0, I discover digging deeper . The error occurs quite rarely, we have only seen it 3 times, with certainty:

(Jun 21  prometheus: 2.42.0 -> 2.44.0 for NixOS 23.05)
Nov 17. 22:21 - version 2.44.0
(Dec 15: NixOS 23.05 -> 23.11 = prometheus ver. 2.49.0)
Feb 8. 17:30 - version 2.49.0
Feb 21. 1:05 -  version 2.49.0

Hope this give an overview. We update hosts every 14 days and follow continuously the NixOS stable branch.