mirror of
https://gh.wpcy.net/https://github.com/discourse/discourse.git
synced 2026-05-09 07:50:14 +08:00
In `Demon::EmailSync#after_fork`, we had the following lines of code: ``` loop do break if Discourse.redis.set(HEARTBEAT_KEY, Time.now.to_i, ex: HEARTBEAT_INTERVAL, nx: true) sleep HEARTBEAT_INTERVAL end ``` What this means is that if the key already exists in Redis, we will sleep for `Demon::EmailSync::HEARTBEAT_INTERVAL` seconds which has been set to 60 seconds. This is highly problematic because the expiry of the Redis key uses the same interval. That means that by the time we break out of the loop, the Redis key could have expired. The key expiring is an indication the process is no longer alive leading to the heartbeat test failing and causing the process to restart for no good reason. The solution to resolve this problem is to just remove those lines as I cannot figure out why those lines would even be necessary. There is no reason why we would need to sleep for a given interval before booting up the process. This commit also updates the Redis key, which is used to store the heartbeat timestamp, to include the process's hostname and pid. We should not be restarting all `Demon::EmailSync` processes across different hosts just because one process on a particular host failed. |
||
|---|---|---|
| .. | ||
| fabricators | ||
| fixtures | ||
| generator | ||
| helpers | ||
| import_export | ||
| initializers | ||
| integration | ||
| integrity | ||
| jobs | ||
| lib | ||
| mailers | ||
| migrations | ||
| models | ||
| multisite | ||
| requests | ||
| script/import_scripts | ||
| serializers | ||
| services | ||
| support | ||
| system | ||
| tasks | ||
| views | ||
| rails_helper.rb | ||
| regenerate_swagger_docs | ||
| swagger_helper.rb | ||