Apply cooldown backoff on pthread_create failure

When pthread_create fails (e.g., EAGAIN from OS resource limits),
the monitor and fast-path pressure grow would retry on the next cycle
with no delay, potentially flooding syslog with identical warnings
every 100ms.

Fix: stamp _last_scale_time_usecs on creation failure so the existing
cooldown mechanism (200ms default) suppresses immediate retries.  This
reuses the scaling cooldown infrastructure rather than adding a
separate backoff timer.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
Antonio S. Musumeci 2026-04-10 13:34:34 -04:00
parent 1dd979f955
commit 02703ef239

View file

@ -802,6 +802,14 @@ ThreadPool::_add_thread_scaling_locked(const std::string &name_)
_name.c_str(),
rv,
strerror(rv));
// Treat creation failure as a scaling event so the cooldown
// timer suppresses immediate retries from the monitor and
// fast-path pressure grow, avoiding syslog spam under
// sustained resource pressure.
if(_autoscale_enabled)
_last_scale_time_usecs.store(_now_usecs(),std::memory_order_relaxed);
return -rv;
}