mirror of
https://github.com/ClickHouse/ClickHouse.git
synced 2024-12-04 21:42:39 +00:00
Fix data race in init sqlite db
This commit is contained in:
parent
9d44c7a737
commit
f412c76eba
@ -14,6 +14,7 @@ namespace ErrorCodes
|
|||||||
extern const int PATH_ACCESS_DENIED;
|
extern const int PATH_ACCESS_DENIED;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static std::mutex init_sqlite_db_mutex;
|
||||||
|
|
||||||
void processSQLiteError(const String & message, bool throw_on_error)
|
void processSQLiteError(const String & message, bool throw_on_error)
|
||||||
{
|
{
|
||||||
@ -52,7 +53,11 @@ SQLitePtr openSQLiteDB(const String & path, ContextPtr context, bool throw_on_er
|
|||||||
LOG_DEBUG(&Poco::Logger::get("SQLite"), "SQLite database path {} does not exist, will create an empty SQLite database", database_path);
|
LOG_DEBUG(&Poco::Logger::get("SQLite"), "SQLite database path {} does not exist, will create an empty SQLite database", database_path);
|
||||||
|
|
||||||
sqlite3 * tmp_sqlite_db = nullptr;
|
sqlite3 * tmp_sqlite_db = nullptr;
|
||||||
int status = sqlite3_open(database_path.c_str(), &tmp_sqlite_db);
|
int status;
|
||||||
|
{
|
||||||
|
std::lock_guard lock(init_sqlite_db_mutex);
|
||||||
|
status = sqlite3_open(database_path.c_str(), &tmp_sqlite_db);
|
||||||
|
}
|
||||||
|
|
||||||
if (status != SQLITE_OK)
|
if (status != SQLITE_OK)
|
||||||
{
|
{
|
||||||
|
Loading…
Reference in New Issue
Block a user