#24009·harbor

Unreachable audit log forward endpoint blocks configuration writes for minutes

Author: Vad1moCreated Sep 25, 2026Updated Sep 28, 2026
Labelsarea/audit-log

An unreachable audit log forward endpoint wedges configuration writes for many minutes. Every syslog connect waits out the kernel's TCP connect timeout (about 2 minutes on Linux). A configuration update makes two such connects while its request transaction holds the properties row locks, and every audit event connects again because LoggerManager never remembers the endpoint it dialled. We found this while chaos testing https://github.com/goharbor/harbor/pull/23996 on a dev cluster.

What we saw

  • Harbor core ran 3 replicas, with a pool of 20 connections each.
  • audit_log_forward_endpoint was set to an address that drops packets (10.255.255.1:1), while config writes and push/pull load kept running.
  • Configuration requests then hung well past their clients' 10 second timeout.
  • After 10 minutes, one transaction was still idle in transaction, holding the row locks for audit_log_forward_endpoint and banner_message. Its last statement was the settings save.
  • 31 further configuration transactions queued behind it on those row locks. Each of them held a database connection out of the 60 the three pods had in total.
  • Nothing recovered by itself. We had to terminate the stuck sessions with pg_terminate_backend and clear the endpoint in SQL.
  • Every pod logged failed to create audit log, error dial tcp 10.255.255.1:1: connect: connection timed out for write requests, each about 2 minutes after the event.

Cause

In src/pkg/audit/forward.go:

  • LoggerManager.Init and CheckEndpointActive call syslog.Dial("tcp", endpoint, ...), which has no timeout, so an unreachable address blocks each call for the kernel's full SYN retry time.
  • DefaultLogger calls Init whenever a.endpoint differs from the configured endpoint, but nothing ever assigns a.endpoint. With any endpoint set, every audit event dials again.
  • LoggerManager is shared by all goroutines and has no lock, so these Init calls race.

In src/controller/config/controller.go, UpdateUserConfigs saves the settings first, then calls updateLogEndpoint. That runs CheckEndpointActive and LogMgr.Init, both inside the request transaction, so the row locks from the save are held for both dials.

Steps to reproduce

  1. Run Harbor core with an external Postgres and some write load.
  2. As admin, PUT /api/v2.0/configurations {"audit_log_forward_endpoint":"10.255.255.1:1"}, an address that drops packets rather than refusing them.
  3. Keep sending configuration updates (for example banner_message) and push images.
  4. Watch pg_stat_activity: configuration transactions pile up in Lock/tuple behind one transaction that stays idle in transaction.

Suggested fix

  • Dial with a timeout (net.Dialer{Timeout: ...} and a syslog writer on top of that connection).
  • Set a.endpoint in Init, and guard LoggerManager with a mutex.
  • Check the endpoint before saving the settings, outside the transaction.
  • Forward audit events through a bounded buffer instead of on the request goroutine.

Benefits

  • A slow or unreachable SIEM can no longer stall configuration changes or tie up database connections.
  • Audit forwarding stops reconnecting on every event, which also removes a data race.
  • Admins get a quick error for a bad endpoint instead of a request that hangs for minutes.

Versions: main (src/pkg/audit/forward.go, src/controller/config/controller.go).