mirror of
https://github.com/ClickHouse/ClickHouse.git
synced 2024-11-09 17:14:47 +00:00
Fix temp data deletion on startup, add test
This commit is contained in:
parent
2aa339fb2c
commit
25eee81746
@ -23,10 +23,6 @@ namespace ErrorCodes
|
||||
extern const int LOGICAL_ERROR;
|
||||
}
|
||||
|
||||
TemporaryFileOnDisk::TemporaryFileOnDisk(const DiskPtr & disk_)
|
||||
: TemporaryFileOnDisk(disk_, "")
|
||||
{}
|
||||
|
||||
TemporaryFileOnDisk::TemporaryFileOnDisk(const DiskPtr & disk_, CurrentMetrics::Metric metric_scope)
|
||||
: TemporaryFileOnDisk(disk_)
|
||||
{
|
||||
|
@ -16,9 +16,8 @@ using DiskPtr = std::shared_ptr<IDisk>;
|
||||
class TemporaryFileOnDisk
|
||||
{
|
||||
public:
|
||||
explicit TemporaryFileOnDisk(const DiskPtr & disk_);
|
||||
explicit TemporaryFileOnDisk(const DiskPtr & disk_, CurrentMetrics::Metric metric_scope);
|
||||
explicit TemporaryFileOnDisk(const DiskPtr & disk_, const String & prefix);
|
||||
explicit TemporaryFileOnDisk(const DiskPtr & disk_, const String & prefix = "tmp");
|
||||
|
||||
~TemporaryFileOnDisk();
|
||||
|
||||
|
0
tests/integration/test_temporary_data/__init__.py
Normal file
0
tests/integration/test_temporary_data/__init__.py
Normal file
57
tests/integration/test_temporary_data/test.py
Normal file
57
tests/integration/test_temporary_data/test.py
Normal file
@ -0,0 +1,57 @@
|
||||
# pylint: disable=unused-argument
|
||||
# pylint: disable=redefined-outer-name
|
||||
|
||||
import pytest
|
||||
import time
|
||||
|
||||
from helpers.cluster import ClickHouseCluster
|
||||
|
||||
cluster = ClickHouseCluster(__file__)
|
||||
|
||||
node = cluster.add_instance(
|
||||
"node",
|
||||
stay_alive=True,
|
||||
)
|
||||
|
||||
|
||||
@pytest.fixture(scope="module")
|
||||
def start_cluster():
|
||||
try:
|
||||
cluster.start()
|
||||
yield cluster
|
||||
finally:
|
||||
cluster.shutdown()
|
||||
|
||||
|
||||
def test_tmp_data_no_leftovers(start_cluster):
|
||||
q = node.get_query_request
|
||||
|
||||
settings = {
|
||||
"max_bytes_before_external_group_by": "10K",
|
||||
"max_bytes_before_external_sort": "10K",
|
||||
"join_algorithm": "grace_hash",
|
||||
"max_bytes_in_join": "10K",
|
||||
"grace_hash_join_initial_buckets": "16",
|
||||
}
|
||||
|
||||
# Run some queries in the background to generate temporary data
|
||||
q(
|
||||
"SELECT ignore(*) FROM numbers(10 * 1024 * 1024) ORDER BY sipHash64(number)",
|
||||
settings=settings,
|
||||
)
|
||||
q("SELECT * FROM system.numbers GROUP BY ALL", settings=settings)
|
||||
q(
|
||||
"SELECT * FROM system.numbers as t1 JOIN system.numbers as t2 USING (number)",
|
||||
settings=settings,
|
||||
)
|
||||
|
||||
# Wait a bit to make sure the temporary data is written to disk
|
||||
time.sleep(5)
|
||||
|
||||
# Hard restart the node
|
||||
node.restart_clickhouse(kill=True)
|
||||
path_to_data = "/var/lib/clickhouse/"
|
||||
|
||||
# Check that there are no temporary files left
|
||||
result = node.exec_in_container(["ls", path_to_data + "tmp/"])
|
||||
assert result == ""
|
Loading…
Reference in New Issue
Block a user