Skip to content

Antipattern audit: goroutine leaks, race conditions, unbounded growth, missing recovery #385

Description

@intel352

Audit Results

Comprehensive audit of the workflow engine identified 24 antipatterns across goroutine management, synchronization, resource lifecycle, and error handling. 2 critical, 12 high, 8 medium, 2 low.

Critical (2)

  1. EventProcessor.periodicCleanup() goroutine never stops — module/event_processor.go:84 — Start() spawns goroutine, Stop() is empty, no stop channel or context
  2. CronScheduler data race on running and jobs — module/scheduler.go:56-104 — plain bool/slice accessed from main and background goroutines without synchronization

High — Missing Panic Recovery (3)

  1. foreach step goroutines — module/pipeline_step_foreach.go:219 — no recover() (parallel step already has it)
  2. Scheduler job goroutines — module/scheduler.go:77 — panic in a job crashes the process
  3. workflow_call async goroutine — module/pipeline_step_workflow_call.go:137 — fire-and-forget with no recovery

High — Goroutine Lifecycle (2)

  1. CronScheduler.Stop() blocks forever — module/scheduler.go:103 — unbuffered channel send when goroutine isn't in select
  2. RuntimeManager watcher goroutines untracked — module/runtime_manager.go:194,334 — no WaitGroup, no recovery

High — Unbounded Growth (5)

  1. RateLimitStep.buckets — module/pipeline_step_rate_limit.go:119 — per-IP buckets never evicted
  2. APIGateway gatewayRateLimiter.buckets — module/api_gateway.go:84 — same pattern
  3. WebhookSender.deadLetter — module/webhook_sender.go:111 — never evicted
  4. globalOAuthCache — module/pipeline_step_http_call.go:24 — entries never removed
  5. InMemoryLock.locks — scale/distributed_lock.go:50 — lock entries never removed

Medium (8)

13-17. Missing panic recovery in: handlers/state_machine.go:401, module/api_workflow_handler.go:47, middleware/apikey.go:75, module/kafka_broker.go:246, module/log_collector.go:199
18. CronScheduler unbuffered stop channel (dupes #6)
19. EventProcessor fragile nested lock ordering — module/event_processor.go:140
20. DBQueryCachedStep cache only evicts on re-access
21. StateMachine maxInstances/TTL not actively enforced
22. observability/reporter.go silently drops registration errors

Low (2)

  1. RuntimeManager DB errors discarded
  2. dynamic/resource_limits.go goroutine outlives timeout

Related: #384 (HTTP listener crash — fixed)

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions