mirror of
https://github.com/ClickHouse/ClickHouse.git
synced 2024-11-10 09:32:06 +00:00
Merge pull request #22583 from azat/log-rwlock-ub-fix
Avoid UB in *Log engines for rwlock unlock due to unlock from another thread
This commit is contained in:
commit
6cefb8e620
@ -357,6 +357,11 @@ void LogBlockOutputStream::writeSuffix()
|
||||
|
||||
streams.clear();
|
||||
done = true;
|
||||
|
||||
/// unlock should be done from the same thread as lock, and dtor may be
|
||||
/// called from different thread, so it should be done here (at least in
|
||||
/// case of no exceptions occurred)
|
||||
lock.unlock();
|
||||
}
|
||||
|
||||
|
||||
|
@ -86,7 +86,7 @@ private:
|
||||
DiskPtr disk;
|
||||
String table_path;
|
||||
|
||||
mutable std::shared_timed_mutex rwlock;
|
||||
std::shared_timed_mutex rwlock;
|
||||
|
||||
Files files;
|
||||
|
||||
|
@ -228,6 +228,11 @@ public:
|
||||
storage.file_checker.save();
|
||||
|
||||
done = true;
|
||||
|
||||
/// unlock should be done from the same thread as lock, and dtor may be
|
||||
/// called from different thread, so it should be done here (at least in
|
||||
/// case of no exceptions occurred)
|
||||
lock.unlock();
|
||||
}
|
||||
|
||||
private:
|
||||
|
@ -68,7 +68,7 @@ private:
|
||||
size_t max_compress_block_size;
|
||||
|
||||
FileChecker file_checker;
|
||||
mutable std::shared_timed_mutex rwlock;
|
||||
std::shared_timed_mutex rwlock;
|
||||
|
||||
Poco::Logger * log;
|
||||
};
|
||||
|
@ -358,6 +358,9 @@ void TinyLogBlockOutputStream::writeSuffix()
|
||||
storage.file_checker.update(file);
|
||||
storage.file_checker.save();
|
||||
|
||||
/// unlock should be done from the same thread as lock, and dtor may be
|
||||
/// called from different thread, so it should be done here (at least in
|
||||
/// case of no exceptions occurred)
|
||||
lock.unlock();
|
||||
}
|
||||
|
||||
|
5
tests/queries/0_stateless/01795_TinyLog_rwlock_ub.sql
Normal file
5
tests/queries/0_stateless/01795_TinyLog_rwlock_ub.sql
Normal file
@ -0,0 +1,5 @@
|
||||
DROP TABLE IF EXISTS underlying_01795;
|
||||
CREATE TABLE underlying_01795 (key UInt64) Engine=TinyLog();
|
||||
INSERT INTO FUNCTION remote('127.1', currentDatabase(), underlying_01795) SELECT toUInt64(number) FROM system.numbers LIMIT 1;
|
||||
SELECT * FROM underlying_01795 FORMAT Null;
|
||||
DROP TABLE underlying_01795;
|
5
tests/queries/0_stateless/01796_Log_rwlock_ub.sql
Normal file
5
tests/queries/0_stateless/01796_Log_rwlock_ub.sql
Normal file
@ -0,0 +1,5 @@
|
||||
DROP TABLE IF EXISTS underlying_01796;
|
||||
CREATE TABLE underlying_01796 (key UInt64) Engine=Log();
|
||||
INSERT INTO FUNCTION remote('127.1', currentDatabase(), underlying_01796) SELECT toUInt64(number) FROM system.numbers LIMIT 1;
|
||||
SELECT * FROM underlying_01796 FORMAT Null;
|
||||
DROP TABLE underlying_01796;
|
5
tests/queries/0_stateless/01797_StripeLog_rwlock_ub.sql
Normal file
5
tests/queries/0_stateless/01797_StripeLog_rwlock_ub.sql
Normal file
@ -0,0 +1,5 @@
|
||||
DROP TABLE IF EXISTS underlying_01797;
|
||||
CREATE TABLE underlying_01797 (key UInt64) Engine=StripeLog();
|
||||
INSERT INTO FUNCTION remote('127.1', currentDatabase(), underlying_01797) SELECT toUInt64(number) FROM system.numbers LIMIT 1;
|
||||
SELECT * FROM underlying_01797 FORMAT Null;
|
||||
DROP TABLE underlying_01797;
|
Loading…
Reference in New Issue
Block a user