RestCatalog: concurrent HTTP requests can crash in libcurl
メンテナーはふだん 2 日以内に返信
評価
- 難易度
- 4/5
- 見積もり時間
- 3〜5日
- 初心者へのやさしさ
- 20/100
- issue の種類
- バグ
- 明瞭さ
- 明確に書かれている
- 活発さ
- 停滞
- 技術スタック
- cpp
- 領域
- backend, networking
調査の方向性
Start with src/iceberg/catalog/rest/http_client.cc around line 201, where HttpClient uses the shared cpr::ConnectionPool, and review issue #530 for the earlier mutex guarded session. Reproduce the concurrent requests against the REST fixture used by rest_catalog_integration_test, then inspect the client and pool behavior with the libcurl versions named in the issue. Done means concurrent requests no longer trigger the reported crash; pull request #1090 is already open.
索引モデルが issue の本文から書いたものです。
説明
HttpClient sends every request through one cpr::ConnectionPool (http_client.cc#L201). That pool wraps a libcurl share handle that shares the connection cache, and libcurl doesn't support using a shared connection cache from several threads at once. When two requests overlap, the process can crash.
A RestCatalog sends all its requests through one HttpClient, so requests can overlap even when the application only calls the catalog from one thread:
- Metrics reports are posted from the executor passed to
RestCatalog::Make(rest_metrics_reporter.cc#L73-L74). - OAuth2 tokens are refreshed on the
auth_executorpassed toRestCatalog::Make(auth_session_internal.h#L284). - Vended S3 credentials are refreshed through LoadCredentials when the AWS SDK signs a request. The refresh runs on whichever thread is doing the S3 I/O (arrow_s3_file_io.cc#L701-L708, rest_catalog.cc#L91).
Applications that share one catalog between threads run into it directly.
The shared pool was introduced in apache/iceberg-cpp#530, which replaced a mutex-guarded cpr::Session.
Reproduction
Run this against the REST fixture that rest_catalog_integration_test uses:
HttpClient client;
auto session = auth::AuthSession::MakeDefault({});
std::vector<std::thread> threads;
for (int i = 0; i < 32; ++i) {
threads.emplace_back([&] {
for (int j = 0; j < 200; ++j) {
(void)client.Get("http://localhost:8181/v1/config", {}, {},
*DefaultErrorHandler::Instance(), *session);
}
});
}
for (auto& thread : threads) thread.join();
With libcurl 8.22.0, this aborted in 6 of 6 runs with heap corruption (free(): corrupted unsorted chunks or double free or corruption). Sharing one RestCatalog between 32 threads that each call LoadTable also crashes, with both 8.22.0 and 8.5.0. Neither reproduces with 8.18.0, the version CI uses, so CI doesn't catch it.
- 主要言語
- C++
- スター
- 227
- フォーク
- 142
- 平均マージ
- 3日 21分
- マージ済み PR(30日)
- 70
環境構築
このプロジェクトには開発コンテナ、Dockerfile、コントリビューションガイドがありません。まず README を読み、一般的な手順ははじめてのコントリビューションガイドを参照してください。
はじめの一歩
- issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
- 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
- リポジトリをフォークし、ブランチを切って変更します。
- issue 番号を参照したプルリクエストを送ります。
apache/iceberg-cpp のほかの issue
-
難易度 2/5 1〜3時間 初心者へのやさしさ 77/100
apache/iceberg-cpp#1103 ·
メンテナーはふだん 2 日以内に返信
-
help wanted
難易度 4/5 3〜5日 初心者へのやさしさ 48/100
apache/iceberg-cpp#1101 ·
メンテナーはふだん 2 日以内に返信
-
難易度 5/5 1週間以上 初心者へのやさしさ 25/100
apache/iceberg-cpp#1099 ·
メンテナーはふだん 2 日以内に返信
-
Complete OAuth2 token refresh and expiration support (Java-compatible)対応中かも @lishuxu が 2 日前に担当しました。 オープン
apache/iceberg-cpp#1095 · コメント 2 件 · 担当者 1 名 ·
メンテナーはふだん 2 日以内に返信
-
Make RestCatalog safe to share across threads対応中かも @smaheshwar-pltr が 3 日前に担当しました。 オープン
難易度 4/5 3〜5日 初心者へのやさしさ 25/100
apache/iceberg-cpp#1091 ·
メンテナーはふだん 2 日以内に返信
apache/iceberg-cpp の issue をすべて見る
似ている issue
-
ai_p2
難易度 2/5 1〜3時間 初心者へのやさしさ 82/100
ClickHouse/ClickHouse#130006 ·
メンテナーはふだん 1 日以内に返信
-
DepotMaintain: EN longer string moves the hint popup buttons out of reach // WpfGUI English Languageオープンclient: WpfGui module: depot question
難易度 2/5 1〜3時間 初心者へのやさしさ 64/100
MaaAssistantArknights/MaaAssistantArknights#19169 · コメント 2 件 ·
メンテナーはふだん 1 日以内に返信
-
area: certificates bug outdated-version
難易度 1/5 1時間未満 初心者へのやさしさ 65/100
RafaelNGP/xbox-cloud-gaming-ps5#381 · コメント 1 件 ·
メンテナーはふだん 1 日以内に返信
-
難易度 2/5 1〜3時間 初心者へのやさしさ 85/100
メンテナーはふだん 1 日以内に返信
-
難易度 2/5 1〜3時間 初心者へのやさしさ 74/100
ROCm/AMDMIGraphX#5490 ·
メンテナーはふだん 3 日以内に返信