mirror of
https://github.com/ClickHouse/ClickHouse.git
synced 2024-12-02 04:22:03 +00:00
Fix hdfs race
This commit is contained in:
parent
c7f0cfc4c2
commit
a4daf2b454
@ -33,11 +33,16 @@ void HDFSObjectStorage::startup()
|
|||||||
|
|
||||||
void HDFSObjectStorage::initializeHDFS() const
|
void HDFSObjectStorage::initializeHDFS() const
|
||||||
{
|
{
|
||||||
if (hdfs_fs)
|
if (initialized)
|
||||||
|
return;
|
||||||
|
|
||||||
|
std::lock_guard lock(init_mutex);
|
||||||
|
if (initialized)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
hdfs_builder = createHDFSBuilder(url, config);
|
hdfs_builder = createHDFSBuilder(url, config);
|
||||||
hdfs_fs = createHDFSFS(hdfs_builder.get());
|
hdfs_fs = createHDFSFS(hdfs_builder.get());
|
||||||
|
initialized = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
ObjectStorageKey HDFSObjectStorage::generateObjectKeyForPath(const std::string & /* path */) const
|
ObjectStorageKey HDFSObjectStorage::generateObjectKeyForPath(const std::string & /* path */) const
|
||||||
|
@ -121,6 +121,10 @@ private:
|
|||||||
|
|
||||||
mutable HDFSBuilderWrapper hdfs_builder;
|
mutable HDFSBuilderWrapper hdfs_builder;
|
||||||
mutable HDFSFSPtr hdfs_fs;
|
mutable HDFSFSPtr hdfs_fs;
|
||||||
|
|
||||||
|
mutable std::mutex init_mutex;
|
||||||
|
mutable std::atomic_bool initialized{false};
|
||||||
|
|
||||||
SettingsPtr settings;
|
SettingsPtr settings;
|
||||||
std::string url;
|
std::string url;
|
||||||
std::string url_without_path;
|
std::string url_without_path;
|
||||||
|
Loading…
Reference in New Issue
Block a user