ClickHouse / ClickHouse/clickhouse-java

DataTypeConverter usage has potential thread-safety issues

Đang mở
#2,728 1 bình luận 0 reaction 0 người được giao Xem trên GitHub
bug client-api-v2
Ngôn ngữ chính
Java
Star
1.6k
Fork
636
Merge trung bình
2 ngày 23 giờ
Pull request đã merge (30 ngày)
29

Mô tả

## Description

_This is not an explicit bug report in the sense that I haven't experienced a problem (yet?), it is just something I bumped into while browsing the code_.

`DataTypeConverter` has a [javadoc comment stating that it is not thread safe](https://github.com/ClickHouse/clickhouse-java/blob/main/client-v2/src/main/java/com/clickhouse/client/api/internal/DataTypeConverter.java#L25). For what it's worth, I have also confirmed thread safety problems because I ended up using the `DataTypeConverter.INSTANCE` in production (before I realised that it was labelled as non thread safe) which caused some bugs.

After fixing the bugs in my project, I was curious about the fact that a static singleton `DataTypeConverter.INSTANCE` was even declared in the `clickhouse-java` repo (why have a singleton instance if it is not thread safe, in an otherwise thread safe library?). Of course this class is in a package named `internal`, so it's not really my business... :) Still, I did notice that `DataTypeConverter.INSTANCE` is used in [two](https://github.com/ClickHouse/clickhouse-java/blob/8da0b0c9aa7995b9fa839b56861a28047f71076a/client-v2/src/main/java/com/clickhouse/client/api/data_formats/internal/MapBackedRecord.java#L48) [places](https://github.com/ClickHouse/clickhouse-java/blob/8da0b0c9aa7995b9fa839b56861a28047f71076a/client-v2/src/main/java/com/clickhouse/client/api/data_formats/internal/AbstractBinaryFormatReader.java#L90) which makes me wonder if it could be the source of (other / future / not-yet-encountered) problems..

Hướng dẫn đóng góp

Mở hướng dẫn đóng góp

Hướng nghiên cứu

Bắt đầu với javadoc và phần triển khai của client-v2/src/main/java/com/clickhouse/client/api/internal/DataTypeConverter.java, sau đó kiểm tra các nơi sử dụng nó trong MapBackedRecord.java và AbstractBinaryFormatReader.java. Theo dõi trạng thái có thể thay đổi và các test hiện có để xác lập hợp đồng thread-safety dự kiến; công việc được xem là hoàn tất khi có coverage kiểm thử việc sử dụng an toàn INSTANCE dùng chung hoặc ghi lại lý do không thể dùng chung nó.

Do mô hình lập chỉ mục viết ra từ nội dung của issue.

Đánh giá

Công nghệ
java
Lĩnh vực
api, backend
Loại issue
Lỗi
Độ khó
4/5
Thời gian dự kiến
3-5 ngày
Mức độ hoạt động
Ít trao đổi
Độ rõ ràng
Cần làm rõ
Mức phù hợp với người mới
38/100

Nhận issue mới trong hộp thư của bạn

Bản tóm tắt ngắn những issue GitHub phù hợp với người mới.