Skip to content

BUILD/MINOR: Switch order on inside c.Start(), so restart will work and run Start() synchronously and split SyncData() into its own goroutine#793

Open
cxfcxf wants to merge 2 commits into
haproxytech:masterfrom
cxfcxf:fix-race-condition-start-master
Open

BUILD/MINOR: Switch order on inside c.Start(), so restart will work and run Start() synchronously and split SyncData() into its own goroutine#793
cxfcxf wants to merge 2 commits into
haproxytech:masterfrom
cxfcxf:fix-race-condition-start-master

Conversation

@cxfcxf

@cxfcxf cxfcxf commented Mar 10, 2026

Copy link
Copy Markdown
Contributor

Problem

When running the controller in external mode (e.g. under systemd), systemctl restart hangs ~50% of the time. The controller gets stuck and never processes Kubernetes events.

Root Cause

On restart, the old HAProxy may still be alive briefly. Start() previously ran APICommitTransaction calls before Service("start"), which stripped the daemon directive from the on-disk config. When the old HAProxy finally exited and a new one launched, it ran in the foreground, blocking forever.

Fix

  • Move Service("start") to the top of Start(), before any API transactions can rewrite the config. This restores the ordering from the 3.0.x series.
  • Extract SyncData() out of Start() into its own goroutine and run Start() synchronously before launching the event producer. This ensures full initialization completes before any events or signals can arrive.

@cxfcxf cxfcxf force-pushed the fix-race-condition-start-master branch 2 times, most recently from a7dedaf to 882280a Compare March 10, 2026 22:02
@cxfcxf cxfcxf force-pushed the fix-race-condition-start-master branch from 882280a to 63a4b84 Compare March 11, 2026 21:33
@cxfcxf cxfcxf changed the title BUG/MEDIUM: controller: fix race condition between HAProxy init and informer events BUILD/MINOR: Switch order on inside c.Start(), so restart will work Mar 11, 2026
@cxfcxf cxfcxf force-pushed the fix-race-condition-start-master branch from 4901e11 to f7e2a68 Compare March 12, 2026 00:09
@cxfcxf cxfcxf changed the title BUILD/MINOR: Switch order on inside c.Start(), so restart will work BUILD/MINOR: Switch order on inside c.Start(), so restart will work and run Start() synchronously and split SyncData() into its own goroutine Mar 12, 2026
@cxfcxf cxfcxf force-pushed the fix-race-condition-start-master branch from f7e2a68 to 29430c5 Compare March 12, 2026 00:37
@stale

stale Bot commented Apr 11, 2026

Copy link
Copy Markdown

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.

@stale stale Bot added the stale label Apr 11, 2026
@oktalz oktalz removed the stale label Apr 15, 2026
@stale

stale Bot commented May 15, 2026

Copy link
Copy Markdown

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.

@stale stale Bot added the stale label May 15, 2026
@stale stale Bot closed this Jun 15, 2026
@oktalz oktalz reopened this Jun 15, 2026
@stale stale Bot removed the stale label Jun 15, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants