alexbrainman / odbc

odbc driver written in go
BSD 3-Clause "New" or "Revised" License
361 stars 141 forks source link

QueryContext raises `panic: send on closed channel` #199

Open Shamus03 opened 3 months ago

Shamus03 commented 3 months ago

After the recent commit to add support for QueryContext: https://github.com/alexbrainman/odbc/commit/1293aff3fc513fdd5e9d521b64e35bf56fba8d22#diff-4f427d2b022907c552328e63f137561f6de92396d7a6e8f6c2ea1bcf0db52654R153

We are getting the following error:

Thursday, August 15th 2024 @ 3:41:50 pm panic: send on closed channel
Thursday, August 15th 2024 @ 3:41:50 pm goroutine 4794 [running]:
Thursday, August 15th 2024 @ 3:41:50 pm github.com/alexbrainman/odbc.(*Conn).wrapQuery(0x1?, {0x99c900, 0xc0002a0150}, 0xc00031e320, {0xeb7c20?, 0x6fcc68?, 0xc0004c37d0?}, 0x6f20e5?, 0xc0007aa570?)
Thursday, August 15th 2024 @ 3:41:50 pm /root/go/src/github.com/alexbrainman/odbc/conn.go:153 +0x145
Thursday, August 15th 2024 @ 3:41:50 pm created by github.com/alexbrainman/odbc.(*Conn).QueryContext in goroutine 4792
Thursday, August 15th 2024 @ 3:41:50 pm /root/go/src/github.com/alexbrainman/odbc/conn.go:104 +0x389

It is inside this goroutine: https://github.com/alexbrainman/odbc/commit/1293aff3fc513fdd5e9d521b64e35bf56fba8d22#diff-4f427d2b022907c552328e63f137561f6de92396d7a6e8f6c2ea1bcf0db52654R104

And it seems to kill the connection or permanently damage/deadlock it.

For context: we are using unixodbc to connect to an IBM DB2 database running on an AS400. Hopefully that is helpful.

Working on steps to reproduce, but I haven't been able to nail it yet. We have about 20-30 service instances using this version of the package, and they die with this error slowly over time.

alexbrainman commented 3 months ago

@Shamus03 thanks for reporting the problem.

You can always go to previous version, like

go get github.com/alexbrainman/odbc@1421b829acc

I can even add git tags with version numbers, if it helps you any.

I don't have time to debug your reported panic. But I will accept fixes from anyone including @popeliv .

Alex

Shamus03 commented 3 months ago

Thanks. We have already reverted to a previous version for now.