diff --git a/src/Storages/StorageTinyLog.cpp b/src/Storages/StorageTinyLog.cpp index 6ce41dac614..b63a0c7d255 100644 --- a/src/Storages/StorageTinyLog.cpp +++ b/src/Storages/StorageTinyLog.cpp @@ -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(); } diff --git a/tests/queries/0_stateless/01795_TinyLog_rwlock_ub.reference b/tests/queries/0_stateless/01795_TinyLog_rwlock_ub.reference new file mode 100644 index 00000000000..e69de29bb2d diff --git a/tests/queries/0_stateless/01795_TinyLog_rwlock_ub.sql b/tests/queries/0_stateless/01795_TinyLog_rwlock_ub.sql new file mode 100644 index 00000000000..7afa2b7e164 --- /dev/null +++ b/tests/queries/0_stateless/01795_TinyLog_rwlock_ub.sql @@ -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;