clickhouse-go: Flush batch cause panic
Issue description
Using Flush() method in clickhouse.Batch causes panic
Error log
panic: runtime error: invalid memory address or nil pointer dereference
[signal SIGSEGV: segmentation violation code=0x1 addr=0x8 pc=0x895d0b]
goroutine 12 [running]:
github.com/ClickHouse/ch-go/proto.(*Buffer).PutUInt8(...)
/go/pkg/mod/github.com/!click!house/ch-go@v0.47.3/proto/buffer.go:97
github.com/ClickHouse/ch-go/proto.(*Buffer).PutByte(...)
/go/pkg/mod/github.com/!click!house/ch-go@v0.47.3/proto/buffer.go:82
github.com/ClickHouse/clickhouse-go/v2.(*connect).sendData(0xc000146270, 0xc00011e1c0?, {0x0, 0x0})
/go/pkg/mod/github.com/!click!house/clickhouse-go/v2@v2.3.0/conn.go:171 +0xcb
github.com/ClickHouse/clickhouse-go/v2.(*batch).Flush(0xc00014e280)
/go/pkg/mod/github.com/!click!house/clickhouse-go/v2@v2.3.0/conn_batch.go:165 +0x79
Configuration
OS: Alpine Linux 3.16
Interface: native
Go version: 1.19
ClickHouse Server version: 22.9.3.18
About this issue
- Original URL
- State: closed
- Created 2 years ago
- Comments: 34
Done v.2.4.3 is out. Let me know if this doesn’t resolve the issue @moming00
Its ok ill do a PR and release shortly. Please test.
This is a different issue to the others reported I think - the fact it occurs on prepareBatch not when a batch is reused after an error. I think this happens if the connection to ClickHouse errors on any single go routine - this is causing a segmentation fault on other routines. trying to figure out how this happens.
Yes it should be safe to use in different threads…this reproduces your issue…
hmm, good catch. I think there is some other trappy behavior here -
Send
twice or after an error onSend
shouldn’t panicSend
shouldn’t panic.Protecting against these will probably help a lot of the reports here.