the Server Resets the Connection when the Client-cpp Inserts Data into a Narrow Table
維護者通常 1 天內回覆
還沒有人認領這個 Issue。
評估
研究方向
首先使用 500,000 行和 1,000,000 行執行提供的 C++ 重現程式,然後將用戶端輸出與 ClickHouse 伺服器記錄和網路記錄進行比較。由於未指定專案檔案或測試,因此先找出 insert 和 transport 的進入點,再判斷重設是由伺服器設定還是用戶端行為造成的。完成的標準是找出可重現的原因,並記錄經過驗證的調整。
由索引模型根據 Issue 內容生成。
描述
Project
Our project involves using ClickHouse to efficiently store and query large amounts of data. We want to do this using more flexible narrow tables.
Describe the situation
I encountered a problem while attempting to insert data into a narrow table using the ClickHouse-CPP client. When the number of rows is large (e.g., 1,000,000 rows), I receive a "Connection reset by peer" error. The error manifests with 1,000,000 rows but not with 500,000 rows.
Known information:
- The client successfully transmitted a certain amount of data, after which the server reset the connection
- The data was correctly written to the Block buffer
- No other errors other than system errors were caught (such as the ProtocolError thrown by the client when the outputStream cannot be successfully written)
It can basically be ruled out that it is a client error and I suspect this issue may be related to network transmission or server-side configuration when inserting a large amount of data.
How to reproduce
-
ClickHouse server version: 23.9.2.56
-
Interface: ClickHouse-CPP client
-
Non-default settings: None
-
CREATE TABLEstatement:CREATE TABLE IF NOT EXISTS database.table_name (date Date32, fname FixedString(18), symbol FixedString(8), time DateTime64, value Int32) ENGINE = ReplacingMergeTree() ORDER BY (date, fname, symbol, time); -
Sample demo:
#include <ctime> #include <iostream> #include <clickhouse/client.h> #include <chrono> #include <sstream> #include <random> int main() { const std::string _host = "host"; const std::string _user = "user"; const std::string _passwd = "password"; const std::string _database = "database"; const std::string _table = "table_name"; const std::string table_name = _database + "." + _table; const int push_step = 1e6; // Number of rows per transfer const int ColumnNumber = 99; Client client(ClientOptions().SetHost(_host).SetUser(_user).SetPassword(_passwd).SetCompressionMethod(CompressionMethod::LZ4)); std::stringstream ss; ss << "CREATE TABLE IF NOT EXISTS " << table_name << " (date Date32, fname FixedString(18), symbol FixedString(8), time DateTime64, value Int32" << ") ENGINE = ReplacingMergeTree() order by (date, fname, symbol, time)"; client.Execute(ss.str()); /******************** Prepare Data ********************/ std::random_device rd; std::mt19937 gen(rd()); std::uniform_int_distribution<int> dis(1, 10000); std::shared_ptr<ColumnDate32> date = std::make_shared<ColumnDate32>(); std::shared_ptr<ColumnFixedString> symbol = std::make_shared<ColumnFixedString>(8); std::shared_ptr<ColumnFixedString> fname = std::make_shared<ColumnFixedString>(18); std::shared_ptr<ColumnDateTime64> time = std::make_shared<ColumnDateTime64>(3); std::shared_ptr<ColumnInt32> values = std::make_shared<ColumnInt32>(); date->Reserve(push_step); fname->Reserve(push_step); symbol->Reserve(push_step); time->Reserve(push_step); values->Reserve(push_step); for (auto i = 0; i < push_step; ++i) { time_t cur_time; std::time(&cur_time); date->Append(cur_time); symbol->Append("sh" + std::to_string(i).substr(0, 6)); time->Append(dis(gen)); } for (auto i = 0; i < ColumnNumber; ++i) { for (auto j = 0; j < push_step; ++j) { fname->Append("f" + std::to_string(j)); values->Append(dis(gen)); } } /****************** Transfer Data **********************/ std::cout << "driver release start" << "\n"; Block block; block.AppendColumn("date", date); block.AppendColumn("symbol", symbol); block.AppendColumn("fname", fname); block.AppendColumn("time", time); block.AppendColumn("value", values); client.Insert(table_name, block); std::cout << "driver release done" << "\n"; return 0; }
Additional context
Upon execution, the program outputs "driver release start" and then terminates with the following error message:
terminate called after throwing an instance of 'std::system_error'
what(): fail to send 16 bytes of data: Connection reset by peer
Aborted
Could you advise on how to adjust ClickHouse or the client code to resolve this "Connection reset by peer" error in such a scenario? Thank you for your assistance.
- 主要語言
- C
- 星號
- 388
- 分支
- 220
- 平均合併
- 1 天 25 分鐘
- 30 天內合併 PR
- 16
環境準備
這個專案沒有提供開發容器、Dockerfile 或貢獻指南,環境需要你自己搭建:先看它的 README,通用步驟見我們的新手貢獻指南。
從這裡開始
- 先讀完整個 Issue,再讀專案的貢獻指南。
- 在 Issue 下留言說明你要接手 —— 這能避免兩個人做同樣的事。
- Fork 儲存庫,在一個分支上完成修改。
- 送出 Pull Request,並在描述裡引用這個 Issue 編號。
ClickHouse/clickhouse-cpp 的其他 Issue
-
bug data-types
難度 2/5 1-3 小時 新手友好度 76/100
ClickHouse/clickhouse-cpp#645 ·
維護者通常 1 天內回覆
-
bug queries
難度 2/5 1-3 小時 新手友好度 79/100
ClickHouse/clickhouse-cpp#644 ·
維護者通常 1 天內回覆
-
bug data-types native-format
難度 2/5 1-3 小時 新手友好度 82/100
ClickHouse/clickhouse-cpp#643 ·
維護者通常 1 天內回覆
-
bug connectivity native-protocol
難度 2/5 1-3 小時 新手友好度 78/100
ClickHouse/clickhouse-cpp#638 ·
維護者通常 1 天內回覆
-
Core SQL test harness: ParseSetAssignments does not skip comments inside SET可能已有人在做 @puretechteam 於 12 天前認領。 未關閉bug
難度 2/5 1-3 小時 新手友好度 85/100
ClickHouse/clickhouse-cpp#626 · 1 則留言 ·
維護者通常 1 天內回覆
查看 ClickHouse/clickhouse-cpp 的全部 Issue
相似的 Issue
-
CF_CFDP_S_SendFileData computes the file checksum from the SB buffer after CFE_SB_TransmitBuffer未關閉
難度 2/5 1-3 小時 新手友好度 78/100
-
needs triage
難度 2/5 1-3 小時 新手友好度 72/100
389ds/389-ds-base#8251 ·
維護者通常 1 天內回覆
-
難度 2/5 1-3 小時 新手友好度 70/100
維護者通常 2 天內回覆
-
難度 2/5 1-3 小時 新手友好度 76/100
維護者通常 1 天內回覆
-
難度 2/5 1-3 小時 新手友好度 78/100