Skip to content

Commit

Permalink
Fixed panic on concurrent context key map write (#1284)
Browse files Browse the repository at this point in the history
  • Loading branch information
Wang authored Apr 25, 2024
1 parent 4a3adc4 commit ff97cb8
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 6 deletions.
7 changes: 3 additions & 4 deletions conn_http.go
Original file line number Diff line number Diff line change
Expand Up @@ -372,11 +372,10 @@ func (h *httpConnect) writeData(block *proto.Block) error {
return nil
}

func (h *httpConnect) readData(ctx context.Context, reader *chproto.Reader) (*proto.Block, error) {
opts := queryOptions(ctx)
func (h *httpConnect) readData(reader *chproto.Reader, timezone *time.Location) (*proto.Block, error) {
location := h.location
if opts.userLocation != nil {
location = opts.userLocation
if timezone != nil {
location = timezone
}

block := proto.Block{Timezone: location}
Expand Down
4 changes: 2 additions & 2 deletions conn_http_query.go
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ func (h *httpConnect) query(ctx context.Context, release func(*connect, error),
return nil, err
}
chReader := chproto.NewReader(reader)
block, err := h.readData(ctx, chReader)
block, err := h.readData(chReader, options.userLocation)
if err != nil && !errors.Is(err, io.EOF) {
res.Body.Close()
h.compressionPool.Put(rw)
Expand All @@ -91,7 +91,7 @@ func (h *httpConnect) query(ctx context.Context, release func(*connect, error),
)
go func() {
for {
block, err := h.readData(ctx, chReader)
block, err := h.readData(chReader, options.userLocation)
if err != nil {
// ch-go wraps EOF errors
if !errors.Is(err, io.EOF) {
Expand Down

0 comments on commit ff97cb8

Please sign in to comment.