Skip to content

Commit 58aa6db

Browse files
Merge pull request ClickHouse#88383 from ClickHouse/local-start-from-server-directory
Allow clickhouse-local to start from the clickhouse-server directory.
2 parents ee8f793 + f62a3f1 commit 58aa6db

4 files changed

Lines changed: 46 additions & 2 deletions

File tree

programs/local/LocalServer.cpp

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -312,7 +312,13 @@ static DatabasePtr createClickHouseLocalDatabaseOverlay(const String & name_, Co
312312

313313
fs::path existing_path_symlink = fs::weakly_canonical(context->getPath()) / "metadata" / "default";
314314
if (FS::isSymlinkNoThrow(existing_path_symlink))
315-
default_database_uuid = parse<UUID>(FS::readSymlink(existing_path_symlink).filename());
315+
{
316+
auto symlink_path = FS::readSymlink(existing_path_symlink);
317+
/// If symlink ends with '/':
318+
if (!symlink_path.has_filename() && symlink_path.has_parent_path())
319+
symlink_path = symlink_path.parent_path();
320+
default_database_uuid = parse<UUID>(symlink_path.filename());
321+
}
316322
else
317323
default_database_uuid = UUIDHelpers::generateV4();
318324

src/QueryPipeline/RemoteQueryExecutor.h

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,6 @@ class RemoteQueryExecutorReadContext;
3131

3232
class ParallelReplicasReadingCoordinator;
3333

34-
/// This is the same type as StorageS3Source::IteratorWrapper
3534
using TaskIterator = std::function<ClusterFunctionReadTaskResponsePtr(size_t)>;
3635

3736
/// This class allows one to launch queries on remote replicas of one shard and get results
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
Starting clickhouse-server
2+
Waiting for clickhouse-server to start
3+
1
4+
1
Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
#!/usr/bin/env bash
2+
# Tags: no-parallel
3+
4+
CLICKHOUSE_PORT_TCP=50111
5+
CLICKHOUSE_DATABASE=default
6+
7+
CURDIR=$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)
8+
# shellcheck source=../shell_config.sh
9+
. "$CURDIR"/../shell_config.sh
10+
11+
echo "Starting clickhouse-server"
12+
13+
$CLICKHOUSE_BINARY server -- --tcp_port "$CLICKHOUSE_PORT_TCP" --path "${CLICKHOUSE_TMP}/" > "${CLICKHOUSE_TMP}/server.log" 2>&1 &
14+
PID=$!
15+
16+
echo "Waiting for clickhouse-server to start"
17+
18+
for i in {1..30}; do
19+
sleep 1
20+
$CLICKHOUSE_CLIENT --query "SELECT 1" 2>/dev/null && break
21+
if [[ $i == 30 ]]; then
22+
cat "${CLICKHOUSE_TMP}/server.log"
23+
exit 1
24+
fi
25+
done
26+
27+
# Make sure the directory for the default database is created:
28+
$CLICKHOUSE_CLIENT --query "CREATE TABLE test (x UInt8) ORDER BY ()"
29+
30+
kill $PID
31+
wait
32+
33+
$CLICKHOUSE_LOCAL --path "${CLICKHOUSE_TMP}/" --query "
34+
SELECT uuid = '$(basename $(readlink ${CLICKHOUSE_TMP}/metadata/default))' FROM system.databases WHERE name = 'default'
35+
" || cat "${CLICKHOUSE_TMP}/server.log"

0 commit comments

Comments
 (0)