DistributedMutex error warnings frequently appearing in logs

This is probably not caused directly by the reverse proxy.

For API-created posts, Discourse uses DistributedMemoizer around PostsController#create to avoid duplicate API post creation. That memoizer uses a Redis-backed DistributedMutex with a very short validity time of 1 second. The warning means that the post creation / serialization work inside that lock took longer than expected.

So:

  • if the API post is still created successfully, this is a warning rather than the root failure;
  • expected max: 1 secs, took an extra 1 secs means the lock was held for roughly 2 seconds;
  • it is more likely related to server performance, Redis/Postgres latency, disk I/O, CPU/RAM pressure, plugins, or slow post-processing than to nginx/1Panel reverse proxy itself;
  • the reason it only appears for API posting is that this memoizer path is used for API requests.

Things worth checking:

  1. Does the API request succeed and create only one post?
  2. How long does the API request take from the client side?
  3. Are CPU, memory, swap, or disk I/O saturated during API posting?
  4. Are Redis and Postgres inside the same container/host, and are they healthy?
  5. Does the warning still happen with a very small plain-text post and no images/uploads?
  6. Are there non-standard plugins installed?

Since this is a 1Panel/container deployment rather than the standard Discourse Docker install, it may also be useful to reproduce on an official supported install if possible before treating it as a Discourse core bug.