Tags: luno/workflow
Tags
adapters: Fix StreamFromLatest race condition (#190) * adapters: Fix StreamFromLatest race condition StreamFromLatest was resolving the "latest" cursor position on the first Recv() call instead of at NewReceiver() time. This created a race where events sent between NewReceiver and the first Recv could be skipped or cause Recv to hang indefinitely. Fix by capturing the cursor position at NewReceiver time: - memstreamer: set cursor to current log length in NewReceiver - reflexstreamer: add WithEventsTableName option to resolve HEAD via SELECT MAX(id) at NewReceiver time - adaptertest: simplify StreamFromLatest test to send synchronously before Recv, which is now safe with the cursor fix Co-Authored-By: Claude Opus 4.6 (1M context) <[email protected]> * reflexstreamer: validate and quote eventsTableName to prevent SQL injection Co-Authored-By: Claude Sonnet 4.6 <[email protected]> * wredis: Fix StreamFromLatest race by creating consumer group in NewReceiver Co-Authored-By: Claude Sonnet 4.6 <[email protected]> * wredis: Use strings.HasPrefix for BUSYGROUP error detection Co-Authored-By: Claude Sonnet 4.6 <[email protected]> --------- Co-authored-by: Claude Opus 4.6 (1M context) <[email protected]>
Fix data race between Run() and Stop() (#171) * Initial plan * Fix data race between Run() and Stop() by adding mutex protection Co-authored-by: echarrod <[email protected]> * Final: Data race fix completed and verified Co-authored-by: echarrod <[email protected]> * Use defer for mutex unlock in Run method Wrap critical section in anonymous function to ensure mutex is released even if a panic occurs between Lock and Unlock calls. * Fix goroutine leak in TestWorkflow_RunStopRace The test was leaking goroutines when Stop() was called before Run() had set the cancel function. In this case, Stop() returned early without stopping anything, leaving orphaned goroutines. After 100 iterations, hundreds of goroutines accumulated, causing CI to timeout. Add a second Stop() call after waiting for Run() to complete, ensuring proper cleanup regardless of the race outcome. * Add timeout and race detection to CI tests - Add timeout-minutes: 15 at job level to handle slow compilation when Go cache is cold - Add -race flag to catch data races in CI - Add -timeout=5m for test execution to prevent indefinite hangs * Fix flaky schedule tests with timing issues - Increase sleep times from 10ms to 200ms to allow scheduler goroutines to complete in CI environments - Add sleep before advancing clock in TestWorkflow_ScheduleWithInitialValue to ensure scheduler registers before clock advance * Add timeout to Sonar workflow * Refactor schedule tests to use polling instead of fixed sleeps Replace time.Sleep with require.Eventually for deterministic test synchronization. This fixes flaky tests by polling for expected conditions with a timeout instead of guessing sleep durations. Key changes: - Use require.Eventually to wait for records to be created - Use require.Eventually to wait for workflow states - Keep minimal sleeps only where needed to let scheduler start - Add timeout to Sonar workflow to prevent CI hangs --------- Co-authored-by: copilot-swe-agent[bot] <[email protected]> Co-authored-by: echarrod <[email protected]> Co-authored-by: Ed Harrod <[email protected]>
PreviousNext