New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Fix: possible race condition on EXCHANGE TABLES
query
#61135
base: master
Are you sure you want to change the base?
Changes from 10 commits
558d764
f8b4ef0
2de26fa
2f051c7
067a8c8
2825656
064eca6
c66d8e1
792a298
b24629d
5955cc5
e121665
190823f
4eeff80
c67a898
0eae42a
242dc60
57627ec
856cb21
1bd25d0
c84b702
f0d55ea
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -12,6 +12,7 @@ class IStorage; | |
|
||
using ConstStoragePtr = std::shared_ptr<const IStorage>; | ||
using StoragePtr = std::shared_ptr<IStorage>; | ||
using StorageWeakPtr = std::weak_ptr<IStorage>; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. It's not allowed to use There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Instead of saving StoragePtr, we can save StorageID with resolved UUID There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. it's exactly the point to not keep shared_ptr here - since on HTTP requests session can be preserved it would block database from DROP - making it weak_ptr doesn't block it and we don't need to keep it cached beyond session so it should be safe There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. there's a race condition |
||
using Tables = std::map<String, StoragePtr>; | ||
|
||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
#!/usr/bin/env bash | ||
|
||
set -e | ||
|
||
CURDIR=$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd) | ||
# shellcheck source=../shell_config.sh | ||
. "$CURDIR"/../shell_config.sh | ||
|
||
${CLICKHOUSE_CLIENT} --multiquery <<EOF | ||
DROP TABLE IF EXISTS tbl_03007_1; | ||
DROP TABLE IF EXISTS tbl_03007_2; | ||
CREATE TABLE tbl_03007_1 (n Float64) ENGINE=Memory; | ||
CREATE TABLE tbl_03007_2 (n Int256) ENGINE=Memory; | ||
EOF | ||
|
||
for _ in {1..50}; do | ||
(! ${CLICKHOUSE_CLIENT} --query "SELECT n * 0.123 FROM (SELECT * FROM tbl_03007_1)" 2>&1 | grep LOGICAL_ERROR) & | ||
${CLICKHOUSE_CLIENT} --query "EXCHANGE TABLES tbl_03007_1 AND tbl_03007_2" & | ||
done | ||
|
||
wait | ||
|
||
${CLICKHOUSE_CLIENT} --multiquery <<EOF | ||
DROP TABLE IF EXISTS tbl_03007_1; | ||
DROP TABLE IF EXISTS tbl_03007_2; | ||
EOF |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Consider a better name