Skip to content

fix: resolve data race on IsOpen and channel-close race condition - #31

Open
belowzeroff wants to merge 1 commit into
DataIntellectTech:masterfrom
belowzeroff:fix/concurrency-data-race-channel-panic
Open

fix: resolve data race on IsOpen and channel-close race condition#31
belowzeroff wants to merge 1 commit into
DataIntellectTech:masterfrom
belowzeroff:fix/concurrency-data-race-channel-panic

Conversation

@belowzeroff

Copy link
Copy Markdown

Summary

Fixes two concurrency bugs:

  1. Data race on IsOpen — multiple goroutines (syncQueryRunner, kdbHandleListener, Dispose) read/write IsOpen without synchronization. Added sync.Mutex with accessor methods getOpen()/setOpen().

  2. Send on closed rawReadChan panic — when a query times out, syncQueryRunner calls CloseConnection() which closes rawReadChan. Meanwhile kdbHandleListener may still try to send to it, causing a panic. Fixed by:

    • closeConnection no longer closes rawReadChan
    • Dispose now owns rawReadChan lifecycle, closing it after signal 3 stops all goroutines

Verification

  • go build ./... succeeds
  • go vet ./... shows no new warnings

- Add sync.Mutex for thread-safe IsOpen access across goroutines
- closeConnection no longer closes rawReadChan (was causing panic when
  kdbHandleListener tried to send after channel close)
- Dispose now owns rawReadChan lifecycle: closes it after signalling
  all goroutines to stop
@belowzeroff
belowzeroff force-pushed the fix/concurrency-data-race-channel-panic branch from 72029c2 to e980cbe Compare July 23, 2026 10:53
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.

1 participant