mirror of
https://github.com/hanzoai/datastore.git
synced 2026-09-26 13:55:07 +00:00
557 lines
30 KiB
Bash
Executable File
557 lines
30 KiB
Bash
Executable File
#!/bin/bash
|
|
|
|
# script allows to install configs for clickhouse server and clients required
|
|
# for testing (stateless and stateful tests)
|
|
|
|
set -x -e
|
|
|
|
DEST_SERVER_PATH="${1:-/etc/clickhouse-server}"
|
|
DEST_CLIENT_PATH="${2:-/etc/clickhouse-client}"
|
|
SRC_PATH="$( cd "$(dirname "$0")" >/dev/null 2>&1 ; pwd -P )"
|
|
if [ $# -ge 2 ]; then
|
|
shift 2
|
|
fi
|
|
|
|
FAST_TEST=0
|
|
EXPORT_S3_STORAGE_POLICIES=1
|
|
USE_AZURE_STORAGE_FOR_MERGE_TREE=${USE_AZURE_STORAGE_FOR_MERGE_TREE:0}
|
|
USE_ASYNC_INSERT=${USE_ASYNC_INSERT:0}
|
|
BUGFIX_VALIDATE_CHECK=0
|
|
PREVIOUS_RELEASE_CONFIG=0
|
|
NO_AZURE=0
|
|
KEEPER_INJECT_AUTH=1
|
|
WASM_ENGINE=""
|
|
REMOTE_DATABASE_DISK=0
|
|
LLVM_COVERAGE=0
|
|
|
|
while [[ "$#" -gt 0 ]]; do
|
|
case $1 in
|
|
--fast-test) FAST_TEST=1 && EXPORT_S3_STORAGE_POLICIES=0 ;;
|
|
--analyzer) USE_OLD_ANALYZER=1 ;;
|
|
--s3-storage) EXPORT_S3_STORAGE_POLICIES=1 && USE_S3_STORAGE_FOR_MERGE_TREE=1 && RANDOMIZE_OBJECT_KEY_TYPE=1 ;;
|
|
--parallel-rep) USE_PARALLEL_REPLICAS=1 ;;
|
|
--db-replicated) USE_DATABASE_REPLICATED=1 ;;
|
|
--distributed-plan) USE_DISTRIBUTED_PLAN=1 ;;
|
|
--distributed-cache) USE_DISTRIBUTED_CACHE=1 ;;
|
|
|
|
--wide-parts) USE_POLYMORPHIC_PARTS=1 ;;
|
|
--db-ordinary) USE_DATABASE_ORDINARY=1 ;;
|
|
|
|
--azure) USE_AZURE_STORAGE_FOR_MERGE_TREE=1 ;;
|
|
--no-azure) NO_AZURE=1 ;;
|
|
|
|
--async-insert) USE_ASYNC_INSERT=1 ;;
|
|
--bugfix-validation) BUGFIX_VALIDATE_CHECK=1 ;;
|
|
--previous-release) PREVIOUS_RELEASE_CONFIG=1 ;;
|
|
|
|
--no-keeper-inject-auth) KEEPER_INJECT_AUTH=0 ;;
|
|
--wasm-engine) WASM_ENGINE=$2 && shift ;;
|
|
--remote-database-disk) REMOTE_DATABASE_DISK=1 ;;
|
|
--no-remote-database-disk) REMOTE_DATABASE_DISK=0 ;;
|
|
|
|
--encrypted-storage) USE_ENCRYPTED_STORAGE=1 ;;
|
|
--llvm-coverage) LLVM_COVERAGE=1 ;;
|
|
*) echo "Unknown option: $1" ; exit 1 ;;
|
|
esac
|
|
shift
|
|
done
|
|
|
|
function check_clickhouse_version()
|
|
{
|
|
local required_version=$1 && shift
|
|
# ClickHouse local version 25.4.1.1.
|
|
# ClickHouse local version 25.4.1.1 (official build).
|
|
current_version=$(clickhouse --version | awk '{print $4}')
|
|
|
|
if [ "$(printf '%s\n' "$required_version" "$current_version" | sort -V | head -n1)" = "$required_version" ]; then
|
|
echo "ClickHouse version $current_version is OK (>= $required_version)"
|
|
else
|
|
echo "ClickHouse version $current_version is too old. Required >= $required_version"
|
|
return 1
|
|
fi
|
|
}
|
|
|
|
function is_fast_build()
|
|
{
|
|
return $(clickhouse local --query "SELECT value NOT LIKE '%-fsanitize=%' AND value LIKE '%-DNDEBUG%' FROM system.build_options WHERE name = 'CXX_FLAGS'")
|
|
}
|
|
|
|
echo "Going to install test configs from $SRC_PATH into $DEST_SERVER_PATH"
|
|
|
|
mkdir -p $DEST_SERVER_PATH/users.d/
|
|
mkdir -p $DEST_CLIENT_PATH
|
|
|
|
# When adding a new config or changing the existing one,
|
|
# you should check clickhouse version so that you won't
|
|
# break validations using previous ClickHouse version (like bugfix validation).
|
|
|
|
# Patching configs which are symbolic links can affect source files,
|
|
# need to delete links created by previous script versions
|
|
# Also this is generally good (least astonishment principle) not to retain any old configs
|
|
rm -rf "$DEST_SERVER_PATH"/config.d
|
|
mkdir -p $DEST_SERVER_PATH/config.d/
|
|
|
|
ln -sf $SRC_PATH/config.d/tmp.xml $DEST_SERVER_PATH/config.d/
|
|
ln -sf $SRC_PATH/config.d/core_dump.yaml $DEST_SERVER_PATH/config.d/
|
|
ln -sf $SRC_PATH/config.d/zookeeper_write.xml $DEST_SERVER_PATH/config.d/
|
|
ln -sf $SRC_PATH/config.d/max_num_to_warn.xml $DEST_SERVER_PATH/config.d/
|
|
ln -sf $SRC_PATH/config.d/listen.xml $DEST_SERVER_PATH/config.d/
|
|
ln -sf $SRC_PATH/config.d/text_log.xml $DEST_SERVER_PATH/config.d/
|
|
ln -sf $SRC_PATH/config.d/blob_storage_log.xml $DEST_SERVER_PATH/config.d/
|
|
ln -sf $SRC_PATH/config.d/predicate_statistics_log.xml $DEST_SERVER_PATH/config.d/
|
|
ln -sf $SRC_PATH/config.d/custom_settings_prefixes.xml $DEST_SERVER_PATH/config.d/
|
|
ln -sf $SRC_PATH/config.d/database_catalog_drop_table_concurrency.xml $DEST_SERVER_PATH/config.d/
|
|
ln -sf $SRC_PATH/config.d/enable_access_control_improvements.xml $DEST_SERVER_PATH/config.d/
|
|
ln -sf $SRC_PATH/config.d/macros.xml $DEST_SERVER_PATH/config.d/
|
|
ln -sf $SRC_PATH/config.d/secure_ports.xml $DEST_SERVER_PATH/config.d/
|
|
ln -sf $SRC_PATH/config.d/clusters.xml $DEST_SERVER_PATH/config.d/
|
|
ln -sf $SRC_PATH/config.d/graphite.xml $DEST_SERVER_PATH/config.d/
|
|
ln -sf $SRC_PATH/config.d/graphite_alternative.xml $DEST_SERVER_PATH/config.d/
|
|
ln -sf $SRC_PATH/config.d/grpc_protocol.xml $DEST_SERVER_PATH/config.d/
|
|
ln -sf $SRC_PATH/config.d/database_atomic.xml $DEST_SERVER_PATH/config.d/
|
|
ln -sf $SRC_PATH/config.d/max_concurrent_queries.xml $DEST_SERVER_PATH/config.d/
|
|
ln -sf $SRC_PATH/config.d/merge_tree_settings.xml $DEST_SERVER_PATH/config.d/
|
|
ln -sf $SRC_PATH/config.d/backoff_policy.xml $DEST_SERVER_PATH/config.d/
|
|
if check_clickhouse_version 25.4; then
|
|
ln -sf $SRC_PATH/config.d/backoff_policy_25_4.xml $DEST_SERVER_PATH/config.d/
|
|
fi
|
|
ln -sf $SRC_PATH/config.d/merge_tree_old_dirs_cleanup.xml $DEST_SERVER_PATH/config.d/
|
|
ln -sf $SRC_PATH/config.d/test_cluster_with_incorrect_pw.xml $DEST_SERVER_PATH/config.d/
|
|
|
|
if check_clickhouse_version 25.10; then
|
|
ln -sf $SRC_PATH/config.d/keeper_max_request_size.xml $DEST_SERVER_PATH/config.d/
|
|
fi
|
|
ln -sf $SRC_PATH/config.d/logging_no_rotate.xml $DEST_SERVER_PATH/config.d/
|
|
ln -sf $SRC_PATH/config.d/merge_tree.xml $DEST_SERVER_PATH/config.d/
|
|
ln -sf $SRC_PATH/config.d/lost_forever_check.xml $DEST_SERVER_PATH/config.d/
|
|
ln -sf $SRC_PATH/config.d/tcp_with_proxy.xml $DEST_SERVER_PATH/config.d/
|
|
ln -sf $SRC_PATH/config.d/prometheus.xml $DEST_SERVER_PATH/config.d/
|
|
ln -sf $SRC_PATH/config.d/top_level_domains_lists.xml $DEST_SERVER_PATH/config.d/
|
|
ln -sf $SRC_PATH/config.d/top_level_domains_path.xml $DEST_SERVER_PATH/config.d/
|
|
|
|
ln -sf $SRC_PATH/config.d/transactions_info_log.xml $DEST_SERVER_PATH/config.d/
|
|
ln -sf $SRC_PATH/config.d/transactions.xml $DEST_SERVER_PATH/config.d/
|
|
|
|
ln -sf $SRC_PATH/config.d/encryption.xml $DEST_SERVER_PATH/config.d/
|
|
ln -sf $SRC_PATH/config.d/zookeeper_log.xml $DEST_SERVER_PATH/config.d/
|
|
|
|
# Lower all caches size to 128MB
|
|
ln -sf $SRC_PATH/config.d/small_caches.xml $DEST_SERVER_PATH/config.d/
|
|
|
|
# Randomize which logger is used (until sync logger is removed, if that ever happens)
|
|
value=$((RANDOM % 2))
|
|
echo "Async logging: $value"
|
|
sed "s|<async>[01]</async>|<async>$value</async>|" $SRC_PATH/config.d/logger_trace.xml >$DEST_SERVER_PATH/config.d/logger_trace.xml
|
|
|
|
# Randomize the default compression codec (used for columns without an explicit CODEC)
|
|
# across LZ4, ZSTD(1) and ZSTD(3) to exercise all of them across CI runs. It is set through
|
|
# the `default_compression_codec` MergeTree setting in the <merge_tree> config section, NOT
|
|
# the top-level <compression> codec selector: clickhouse-client/local read <compression> as
|
|
# a connection-level boolean (ConnectionParameters), so a codec selector there makes them
|
|
# fail with "Cannot convert to boolean" (e.g. the system-table scraping step). It applies to
|
|
# .sql and .sh tests alike; a test that needs a specific codec pins it with
|
|
# `SETTINGS default_compression_codec = '...'`, which overrides this server default.
|
|
default_compression_codec_options=("LZ4" "ZSTD(1)" "ZSTD(3)")
|
|
default_compression_codec="${default_compression_codec_options[$((RANDOM % ${#default_compression_codec_options[@]}))]}"
|
|
echo "Default compression codec: $default_compression_codec"
|
|
{
|
|
echo "<clickhouse>"
|
|
echo " <merge_tree>"
|
|
echo " <default_compression_codec>${default_compression_codec}</default_compression_codec>"
|
|
echo " </merge_tree>"
|
|
echo "</clickhouse>"
|
|
} > $DEST_SERVER_PATH/config.d/default_compression_codec.xml
|
|
|
|
# Randomize the per-step overcommit eviction budget so the multi-step retry path
|
|
# in `OvercommitFileCachePriority::collectCandidatesForEviction` gets exercised
|
|
# across runs. Picked from values spanning single-step and many-step regimes.
|
|
#
|
|
# The outer retry loop has a fixed `max_tries = 1000` cap, so the smallest step
|
|
# must keep `step * max_tries` above the largest expected single-reservation
|
|
# deficit. With `max_file_segment_size = 5Mi` in the cache config, that means
|
|
# step >= ~5243 bytes; we use 8Ki as a safe lower bound that still forces ~640
|
|
# outer iterations per 5 MiB reservation.
|
|
overcommit_evict_step_values=(8192 65536 1048576 10485760)
|
|
OVERCOMMIT_EVICT_STEP=${overcommit_evict_step_values[$((RANDOM % ${#overcommit_evict_step_values[@]}))]}
|
|
echo "Overcommit eviction evict step: $OVERCOMMIT_EVICT_STEP"
|
|
export OVERCOMMIT_EVICT_STEP
|
|
ln -sf $SRC_PATH/config.d/named_collection.xml $DEST_SERVER_PATH/config.d/
|
|
cp $SRC_PATH/config.d/ssl_certs.xml $DEST_SERVER_PATH/config.d/
|
|
ln -sf $SRC_PATH/config.d/filesystem_cache_log.xml $DEST_SERVER_PATH/config.d/
|
|
ln -sf $SRC_PATH/config.d/filesystem_read_prefetches_log.yaml $DEST_SERVER_PATH/config.d/
|
|
ln -sf $SRC_PATH/config.d/session_log.xml $DEST_SERVER_PATH/config.d/
|
|
ln -sf $SRC_PATH/config.d/background_schedule_pool_log.yaml $DEST_SERVER_PATH/config.d/
|
|
ln -sf $SRC_PATH/config.d/system_unfreeze.xml $DEST_SERVER_PATH/config.d/
|
|
ln -sf $SRC_PATH/config.d/nlp.xml $DEST_SERVER_PATH/config.d/
|
|
ln -sf $SRC_PATH/config.d/forbidden_headers.xml $DEST_SERVER_PATH/config.d/
|
|
ln -sf $SRC_PATH/config.d/enable_keeper_map.xml $DEST_SERVER_PATH/config.d/
|
|
ln -sf $SRC_PATH/config.d/custom_disks_base_path.xml $DEST_SERVER_PATH/config.d/
|
|
ln -sf $SRC_PATH/config.d/display_name.xml $DEST_SERVER_PATH/config.d/
|
|
ln -sf $SRC_PATH/config.d/compressed_marks_and_index.xml $DEST_SERVER_PATH/config.d/
|
|
ln -sf $SRC_PATH/config.d/disable_s3_env_credentials.xml $DEST_SERVER_PATH/config.d/
|
|
ln -sf $SRC_PATH/config.d/enable_wait_for_shutdown_replicated_tables.xml $DEST_SERVER_PATH/config.d/
|
|
cp $SRC_PATH/config.d/storage_conf_backups.xml $DEST_SERVER_PATH/config.d/
|
|
cp $SRC_PATH/config.d/backups.xml $DEST_SERVER_PATH/config.d/
|
|
cp $SRC_PATH/config.d/filesystem_caches_path.xml $DEST_SERVER_PATH/config.d/
|
|
ln -sf $SRC_PATH/config.d/validate_tcp_client_information.xml $DEST_SERVER_PATH/config.d/
|
|
# distributed_query.xml sets distributed_query.streaming_exchange_port, which the server rejects on
|
|
# platforms without the streaming exchange (only Linux and macOS support it); install it there only.
|
|
case "$(uname -s)" in
|
|
Linux|Darwin)
|
|
ln -sf $SRC_PATH/config.d/distributed_query.xml $DEST_SERVER_PATH/config.d/
|
|
;;
|
|
esac
|
|
|
|
ln -sf $SRC_PATH/config.d/zero_copy_destructive_operations.xml $DEST_SERVER_PATH/config.d/
|
|
ln -sf $SRC_PATH/config.d/handlers.yaml $DEST_SERVER_PATH/config.d/
|
|
ln -sf $SRC_PATH/config.d/threadpool_writer_pool_size.yaml $DEST_SERVER_PATH/config.d/
|
|
ln -sf $SRC_PATH/config.d/serverwide_trace_collector.xml $DEST_SERVER_PATH/config.d/
|
|
function is_sanitizer_build()
|
|
{
|
|
[ "$(clickhouse local --query "SELECT value LIKE '%-fsanitize=%' FROM system.build_options WHERE name = 'CXX_FLAGS'")" = "1" ]
|
|
}
|
|
if is_sanitizer_build; then
|
|
ln -sf $SRC_PATH/config.d/trace_log_no_symbolize.xml $DEST_SERVER_PATH/config.d/
|
|
fi
|
|
ln -sf $SRC_PATH/config.d/memory_profiler.yaml $DEST_SERVER_PATH/config.d/
|
|
ln -sf $SRC_PATH/config.d/rocksdb.xml $DEST_SERVER_PATH/config.d/
|
|
ln -sf $SRC_PATH/config.d/process_query_plan_packet.xml $DEST_SERVER_PATH/config.d/
|
|
ln -sf $SRC_PATH/config.d/storage_conf_03008.xml $DEST_SERVER_PATH/config.d/
|
|
ln -sf $SRC_PATH/config.d/memory_access.xml $DEST_SERVER_PATH/config.d/
|
|
ln -sf $SRC_PATH/config.d/jemalloc_enable_global_profiler.yaml $DEST_SERVER_PATH/config.d/
|
|
ln -sf $SRC_PATH/config.d/jemalloc_flush_profile.yaml $DEST_SERVER_PATH/config.d/
|
|
ln -sf $SRC_PATH/config.d/wait_remaining_connections.xml $DEST_SERVER_PATH/config.d/
|
|
ln -sf $SRC_PATH/config.d/kafka.xml $DEST_SERVER_PATH/config.d/
|
|
ln -sf $SRC_PATH/config.d/keeper_multiread_batch_size.xml $DEST_SERVER_PATH/config.d/
|
|
ln -sf $SRC_PATH/config.d/zookeeper_enforce_component_name.yaml $DEST_SERVER_PATH/config.d/
|
|
|
|
if [ "$FAST_TEST" != "1" ]; then
|
|
ln -sf $SRC_PATH/config.d/abort_on_logical_error.yaml $DEST_SERVER_PATH/config.d/
|
|
fi
|
|
|
|
# SSH protocol support (not supported with fasttest or OpenSSL FIPS).
|
|
function is_openssl_fips_build()
|
|
{
|
|
[ "$(clickhouse local --query "SELECT value FROM system.build_options where name = 'USE_OPENSSL_FIPS' LIMIT 1")" -eq 1 ]
|
|
}
|
|
if [ "$FAST_TEST" != "1" ] && ! is_openssl_fips_build; then
|
|
ln -sf $SRC_PATH/config.d/ssh.xml $DEST_SERVER_PATH/config.d/
|
|
ln -sf $SRC_PATH/ssh_host_rsa_key $DEST_SERVER_PATH/config.d/
|
|
fi
|
|
|
|
# Not supported with fasttest.
|
|
if [ "$FAST_TEST" != "1" ]; then
|
|
ln -sf "$SRC_PATH/config.d/legacy_geobase.xml" "$DEST_SERVER_PATH/config.d/"
|
|
fi
|
|
|
|
ln -sf $SRC_PATH/users.d/log_queries.xml $DEST_SERVER_PATH/users.d/
|
|
ln -sf $SRC_PATH/users.d/readonly.xml $DEST_SERVER_PATH/users.d/
|
|
ln -sf $SRC_PATH/users.d/ci_logs_sender.yaml $DEST_SERVER_PATH/users.d/
|
|
ln -sf $SRC_PATH/users.d/access_management.xml $DEST_SERVER_PATH/users.d/
|
|
ln -sf $SRC_PATH/users.d/database_atomic_drop_detach_sync.xml $DEST_SERVER_PATH/users.d/
|
|
ln -sf $SRC_PATH/users.d/opentelemetry.xml $DEST_SERVER_PATH/users.d/
|
|
ln -sf $SRC_PATH/users.d/remote_queries.xml $DEST_SERVER_PATH/users.d/
|
|
ln -sf $SRC_PATH/users.d/session_log_test.xml $DEST_SERVER_PATH/users.d/
|
|
ln -sf $SRC_PATH/users.d/memory_profiler.xml $DEST_SERVER_PATH/users.d/
|
|
ln -sf $SRC_PATH/users.d/no_fsync_metadata.xml $DEST_SERVER_PATH/users.d/
|
|
ln -sf $SRC_PATH/users.d/filelog.xml $DEST_SERVER_PATH/users.d/
|
|
ln -sf $SRC_PATH/users.d/enable_blobs_check.xml $DEST_SERVER_PATH/users.d/
|
|
ln -sf $SRC_PATH/users.d/marks.xml $DEST_SERVER_PATH/users.d/
|
|
ln -sf $SRC_PATH/users.d/insert_keeper_retries.xml $DEST_SERVER_PATH/users.d/
|
|
ln -sf $SRC_PATH/users.d/prefetch_settings.xml $DEST_SERVER_PATH/users.d/
|
|
ln -sf $SRC_PATH/users.d/nonconst_timezone.xml $DEST_SERVER_PATH/users.d/
|
|
ln -sf $SRC_PATH/users.d/allow_introspection_functions.yaml $DEST_SERVER_PATH/users.d/
|
|
ln -sf $SRC_PATH/users.d/replicated_ddl_entry.xml $DEST_SERVER_PATH/users.d/
|
|
ln -sf $SRC_PATH/users.d/limits.yaml $DEST_SERVER_PATH/users.d/
|
|
if check_clickhouse_version 26.1; then
|
|
ln -sf $SRC_PATH/users.d/distributed_index_analysis.yaml $DEST_SERVER_PATH/users.d/
|
|
fi
|
|
if [[ $(is_fast_build) == 1 ]]; then
|
|
ln -sf $SRC_PATH/users.d/limits_fast.yaml $DEST_SERVER_PATH/users.d/
|
|
fi
|
|
|
|
if [[ -n "$USE_OLD_ANALYZER" ]] && [[ "$USE_OLD_ANALYZER" -eq 1 ]]; then
|
|
ln -sf $SRC_PATH/users.d/analyzer.xml $DEST_SERVER_PATH/users.d/
|
|
fi
|
|
|
|
if [[ -n "$USE_DISTRIBUTED_PLAN" ]] && [[ "$USE_DISTRIBUTED_PLAN" -eq 1 ]]; then
|
|
ln -sf $SRC_PATH/users.d/distributed_plan.xml $DEST_SERVER_PATH/users.d/
|
|
fi
|
|
|
|
echo $USE_DISTRIBUTED_CACHE
|
|
if [[ -n "$USE_DISTRIBUTED_CACHE" ]] && [[ "$USE_DISTRIBUTED_CACHE" -eq 1 ]]; then
|
|
ln -sf $SRC_PATH/users.d/enable_distributed_cache_for_reads.xml $DEST_SERVER_PATH/users.d/
|
|
ln -sf $SRC_PATH/config.d/enable_distributed_cache_for_tmp_files.xml $DEST_SERVER_PATH/config.d/
|
|
|
|
fi
|
|
|
|
if [[ -n "$LLVM_COVERAGE" ]] && [[ "$LLVM_COVERAGE" -eq 1 ]]; then
|
|
# Pin random-by-default fault injection seeds in the default profile so coverage
|
|
# is deterministic without injecting per-query settings (which break readonly tests).
|
|
ln -sf $SRC_PATH/users.d/coverage_fault_injection_seeds.xml $DEST_SERVER_PATH/users.d/
|
|
fi
|
|
|
|
# FIXME DataPartsExchange may hang for http_send_timeout seconds
|
|
# when nobody is going to read from the other side of socket (due to "Fetching of part was cancelled"),
|
|
# but socket is owned by HTTPSessionPool, so it's not closed.
|
|
ln -sf $SRC_PATH/users.d/timeouts.xml $DEST_SERVER_PATH/users.d/
|
|
|
|
ln -sf $SRC_PATH/ints_dictionary.xml $DEST_SERVER_PATH/
|
|
ln -sf $SRC_PATH/strings_dictionary.xml $DEST_SERVER_PATH/
|
|
ln -sf $SRC_PATH/decimals_dictionary.xml $DEST_SERVER_PATH/
|
|
ln -sf $SRC_PATH/executable_dictionary.xml $DEST_SERVER_PATH/
|
|
ln -sf $SRC_PATH/executable_pool_dictionary.xml $DEST_SERVER_PATH/
|
|
ln -sf $SRC_PATH/test_function.xml $DEST_SERVER_PATH/
|
|
|
|
ln -sf $SRC_PATH/top_level_domains $DEST_SERVER_PATH/
|
|
ln -sf $SRC_PATH/regions_hierarchy.txt $DEST_SERVER_PATH/config.d/
|
|
ln -sf $SRC_PATH/regions_names_en.txt $DEST_SERVER_PATH/config.d/
|
|
ln -sf $SRC_PATH/regions_names_es.txt $DEST_SERVER_PATH/config.d/
|
|
|
|
ln -sf $SRC_PATH/ext-en.txt $DEST_SERVER_PATH/config.d/
|
|
ln -sf $SRC_PATH/ext-ru.txt $DEST_SERVER_PATH/config.d/
|
|
ln -sf $SRC_PATH/lem-en.bin $DEST_SERVER_PATH/config.d/
|
|
|
|
|
|
ln -sf $SRC_PATH/server.key $DEST_SERVER_PATH/
|
|
ln -sf $SRC_PATH/server.crt $DEST_SERVER_PATH/
|
|
ln -sf $SRC_PATH/dhparam.pem $DEST_SERVER_PATH/
|
|
|
|
ln -sf \
|
|
$SRC_PATH/config.d/query_masking_rules.xml $DEST_SERVER_PATH/config.d/
|
|
|
|
# Always install zookeeper.xml as the base config
|
|
ln -sf $SRC_PATH/config.d/zookeeper.xml $DEST_SERVER_PATH/config.d/
|
|
|
|
# Additionally install fault injection settings as an override when enabled
|
|
if [[ -n "$ZOOKEEPER_FAULT_INJECTION" ]] && [[ "$ZOOKEEPER_FAULT_INJECTION" -eq 1 ]]; then
|
|
ln -sf $SRC_PATH/config.d/zookeeper_fault_injection.xml $DEST_SERVER_PATH/config.d/
|
|
else
|
|
rm -f $DEST_SERVER_PATH/config.d/zookeeper_fault_injection.xml ||:
|
|
fi
|
|
|
|
if [[ -n "$THREAD_POOL_FAULT_INJECTION" ]] && [[ "$THREAD_POOL_FAULT_INJECTION" -eq 1 ]]; then
|
|
ln -sf $SRC_PATH/config.d/cannot_allocate_thread_injection.xml $DEST_SERVER_PATH/config.d/
|
|
else
|
|
rm -f $DEST_SERVER_PATH/config.d/cannot_allocate_thread_injection.xml ||:
|
|
fi
|
|
|
|
if [[ -n "$CLICKHOUSE_FAILPOINTS_INJECTION" ]] && [[ "$CLICKHOUSE_FAILPOINTS_INJECTION" -eq 1 ]]; then
|
|
ln -sf $SRC_PATH/config.d/fail_points_active.xml $DEST_SERVER_PATH/config.d/
|
|
else
|
|
rm -f $DEST_SERVER_PATH/config.d/fail_points_active.xml ||:
|
|
fi
|
|
|
|
# We randomize creating the snapshot on exit for Keeper to test out using older snapshots
|
|
value_create_snapshot_on_exit=$((RANDOM % 2))
|
|
echo "Replacing create_snapshot_on_exit with $value_create_snapshot_on_exit"
|
|
|
|
value_latest_logs_cache_size_threshold=$(((RANDOM + 100) * 2048))
|
|
echo "Replacing latest_logs_cache_size_threshold with $value_latest_logs_cache_size_threshold"
|
|
|
|
value_commit_logs_cache_size_threshold=$(((RANDOM + 100) * 2048))
|
|
echo "Replacing commit_logs_cache_size_threshold with $value_commit_logs_cache_size_threshold"
|
|
|
|
value=$((RANDOM % 2))
|
|
echo "Replacing digest_enabled_on_commit with $value"
|
|
|
|
value_nuraft_use_bg_thread_for_snapshot_io=$((RANDOM % 2))
|
|
echo "Replacing nuraft_use_bg_thread_for_snapshot_io with $value_nuraft_use_bg_thread_for_snapshot_io"
|
|
|
|
sed -E "s|<create_snapshot_on_exit>[01]</create_snapshot_on_exit>|<create_snapshot_on_exit>$value_create_snapshot_on_exit</create_snapshot_on_exit>|; \
|
|
s|<latest_logs_cache_size_threshold>[[:digit:]]+</latest_logs_cache_size_threshold>|<latest_logs_cache_size_threshold>$value_latest_logs_cache_size_threshold</latest_logs_cache_size_threshold>|; \
|
|
s|<commit_logs_cache_size_threshold>[[:digit:]]+</commit_logs_cache_size_threshold>|<commit_logs_cache_size_threshold>$value_commit_logs_cache_size_threshold</commit_logs_cache_size_threshold>|; \
|
|
s|<digest_enabled_on_commit>[01]</digest_enabled_on_commit>|<digest_enabled_on_commit>$value</digest_enabled_on_commit>|; \
|
|
s|<nuraft_use_bg_thread_for_snapshot_io>[01]</nuraft_use_bg_thread_for_snapshot_io>|<nuraft_use_bg_thread_for_snapshot_io>$value_nuraft_use_bg_thread_for_snapshot_io</nuraft_use_bg_thread_for_snapshot_io>|" \
|
|
$SRC_PATH/config.d/keeper_port.xml > $DEST_SERVER_PATH/config.d/keeper_port.xml
|
|
|
|
inject_auth=$((RANDOM % 2))
|
|
if [[ $KEEPER_INJECT_AUTH -eq 0 ]]; then
|
|
inject_auth=0
|
|
fi
|
|
|
|
if [[ $inject_auth -eq 1 ]]; then
|
|
echo "Keeper connection will use auth"
|
|
ln -sf $SRC_PATH/config.d/zookeeper_auth.xml $DEST_SERVER_PATH/config.d/
|
|
else
|
|
echo "Keeper connection will not use auth"
|
|
rm -f $DEST_SERVER_PATH/config.d/zookeeper_auth.xml ||:
|
|
fi
|
|
|
|
if [[ -n "$USE_POLYMORPHIC_PARTS" ]] && [[ "$USE_POLYMORPHIC_PARTS" -eq 1 ]]; then
|
|
ln -sf $SRC_PATH/config.d/polymorphic_parts.xml $DEST_SERVER_PATH/config.d/
|
|
fi
|
|
if [[ -n "$USE_DATABASE_ORDINARY" ]] && [[ "$USE_DATABASE_ORDINARY" -eq 1 ]]; then
|
|
ln -sf $SRC_PATH/users.d/database_ordinary.xml $DEST_SERVER_PATH/users.d/
|
|
fi
|
|
|
|
object_key_types_options=("generate-full-key" "generate-template-key")
|
|
object_key_type="${object_key_types_options[0]}"
|
|
|
|
if [[ -n "$RANDOMIZE_OBJECT_KEY_TYPE" ]] && [[ "$RANDOMIZE_OBJECT_KEY_TYPE" -eq 1 ]]; then
|
|
object_key_type="${object_key_types_options[$(($RANDOM % ${#object_key_types_options[@]}))]}"
|
|
fi
|
|
|
|
function setup_storage_policy()
|
|
{
|
|
case $object_key_type in
|
|
"generate-full-key")
|
|
ln -sf $SRC_PATH/config.d/s3_storage_policy_by_default.xml $DEST_SERVER_PATH/config.d/
|
|
;;
|
|
"generate-template-key")
|
|
ln -sf $SRC_PATH/config.d/s3_storage_policy_with_template_object_key.xml $DEST_SERVER_PATH/config.d/s3_storage_policy_by_default.xml
|
|
;;
|
|
esac
|
|
}
|
|
|
|
if [[ "$USE_S3_STORAGE_FOR_MERGE_TREE" == "1" ]]; then
|
|
setup_storage_policy
|
|
|
|
if [[ -n "$USE_ENCRYPTED_STORAGE" ]] && [[ "$USE_ENCRYPTED_STORAGE" -eq 1 ]]; then
|
|
ln -sf $SRC_PATH/config.d/s3_encrypted_storage_policy_for_merge_tree_by_default.xml $DEST_SERVER_PATH/config.d/
|
|
else
|
|
ln -sf $SRC_PATH/config.d/s3_storage_policy_for_merge_tree_by_default.xml $DEST_SERVER_PATH/config.d/
|
|
fi
|
|
elif [[ "$USE_AZURE_STORAGE_FOR_MERGE_TREE" == "1" ]]; then
|
|
if [[ -n "$USE_ENCRYPTED_STORAGE" ]] && [[ "$USE_ENCRYPTED_STORAGE" -eq 1 ]]; then
|
|
ln -sf $SRC_PATH/config.d/azure_encrypted_storage_policy_by_default.xml $DEST_SERVER_PATH/config.d/
|
|
else
|
|
ln -sf $SRC_PATH/config.d/azure_storage_policy_by_default.xml $DEST_SERVER_PATH/config.d/
|
|
fi
|
|
ln -sf $SRC_PATH/config.d/azure_storage_connection_limits.xml $DEST_SERVER_PATH/config.d/
|
|
fi
|
|
|
|
if [[ "$EXPORT_S3_STORAGE_POLICIES" == "1" ]]; then
|
|
if [[ "$NO_AZURE" != "1" ]]; then
|
|
ln -sf $SRC_PATH/config.d/azure_storage_conf.xml $DEST_SERVER_PATH/config.d/
|
|
fi
|
|
|
|
# Randomize the filesystem cache reserve_granularity to get coverage of the reserve-ahead path.
|
|
reserve_granularity_options=("1Mi" "4Mi" "8Mi")
|
|
reserve_granularity="${reserve_granularity_options[$((RANDOM % ${#reserve_granularity_options[@]}))]}"
|
|
echo "Replacing s3_cache reserve_granularity with $reserve_granularity"
|
|
# Scope the substitution to the <s3_cache> block so it does not touch other caches'
|
|
# reserve_granularity (e.g. dynamically_resize_filesystem_cache intentionally sets it to 0).
|
|
reserve_granularity_sed="/<s3_cache>/,/<\/s3_cache>/s|<reserve_granularity>[^<]*</reserve_granularity>|<reserve_granularity>$reserve_granularity</reserve_granularity>|"
|
|
|
|
if check_clickhouse_version 25.5; then
|
|
ln -sf $SRC_PATH/config.d/storage_conf_02944.xml $DEST_SERVER_PATH/config.d/
|
|
else
|
|
sed "s|<allow_dynamic_cache_resize>1</allow_dynamic_cache_resize>||" $SRC_PATH/config.d/storage_conf_02944.xml >$DEST_SERVER_PATH/config.d/storage_conf_02944.xml
|
|
fi
|
|
# storage_conf.xml may carry settings unknown to the previous-release server: strip them by version.
|
|
# allow_dynamic_cache_resize was added in 25.5; keep_free_space_eviction_threads and
|
|
# reserve_granularity in 26.7.
|
|
# --remove-destination: an earlier install may have left this path as a symlink to the
|
|
# source; without it cp would follow the link and fail with "same file" under set -e.
|
|
cp --remove-destination $SRC_PATH/config.d/storage_conf.xml $DEST_SERVER_PATH/config.d/storage_conf.xml
|
|
check_clickhouse_version 25.5 || sed -i "s|<allow_dynamic_cache_resize>1</allow_dynamic_cache_resize>||" $DEST_SERVER_PATH/config.d/storage_conf.xml
|
|
check_clickhouse_version 26.7 || sed -i "s|<keep_free_space_eviction_threads>4</keep_free_space_eviction_threads>||" $DEST_SERVER_PATH/config.d/storage_conf.xml
|
|
# reserve_granularity was added in 26.7: apply the randomized s3_cache value for new-enough
|
|
# servers, strip it entirely (unknown setting) for older ones in the upgrade/bugfix checks.
|
|
if check_clickhouse_version 26.7; then
|
|
sed -i "$reserve_granularity_sed" $DEST_SERVER_PATH/config.d/storage_conf.xml
|
|
else
|
|
sed -i "s|<reserve_granularity>[^<]*</reserve_granularity>||g" $DEST_SERVER_PATH/config.d/storage_conf.xml
|
|
fi
|
|
|
|
# Apply `overcommit_eviction_evict_step` randomization only under
|
|
# distributed cache — that is where the overcommit multi-step retry path
|
|
# actually gets exercised in CI. `sed >tmp && mv` reads through the dest
|
|
# (symlink or file) and atomically replaces it without touching the source.
|
|
if [[ -n "$USE_DISTRIBUTED_CACHE" ]] && [[ "$USE_DISTRIBUTED_CACHE" -eq 1 ]]; then
|
|
sed "s|<overcommit_eviction_evict_step>[0-9]*</overcommit_eviction_evict_step>|<overcommit_eviction_evict_step>$OVERCOMMIT_EVICT_STEP</overcommit_eviction_evict_step>|" \
|
|
$DEST_SERVER_PATH/config.d/storage_conf.xml >$DEST_SERVER_PATH/config.d/storage_conf.xml.tmp
|
|
mv $DEST_SERVER_PATH/config.d/storage_conf.xml.tmp $DEST_SERVER_PATH/config.d/storage_conf.xml
|
|
fi
|
|
ln -sf $SRC_PATH/config.d/storage_conf_02963.xml $DEST_SERVER_PATH/config.d/
|
|
ln -sf $SRC_PATH/config.d/storage_conf_02961.xml $DEST_SERVER_PATH/config.d/
|
|
ln -sf $SRC_PATH/config.d/storage_conf_03517.xml $DEST_SERVER_PATH/config.d/
|
|
ln -sf $SRC_PATH/config.d/storage_conf_03755.xml $DEST_SERVER_PATH/config.d/
|
|
ln -sf $SRC_PATH/config.d/storage_conf_04070.xml $DEST_SERVER_PATH/config.d/
|
|
ln -sf $SRC_PATH/config.d/s3_settings_override.xml $DEST_SERVER_PATH/config.d/
|
|
ln -sf $SRC_PATH/users.d/s3_cache.xml $DEST_SERVER_PATH/users.d/
|
|
ln -sf $SRC_PATH/users.d/s3_cache_new.xml $DEST_SERVER_PATH/users.d/
|
|
fi
|
|
|
|
ln -sf $SRC_PATH/config.d/storage_conf_local.xml $DEST_SERVER_PATH/config.d/
|
|
|
|
if [[ "$USE_PARALLEL_REPLICAS" == "1" ]]; then
|
|
ln -sf $SRC_PATH/users.d/enable_parallel_replicas.xml $DEST_SERVER_PATH/users.d/
|
|
ln -sf $SRC_PATH/config.d/enable_parallel_replicas.xml $DEST_SERVER_PATH/config.d/
|
|
fi
|
|
|
|
if [[ "$USE_ASYNC_INSERT" == "1" ]]; then
|
|
ln -sf $SRC_PATH/users.d/enable_async_inserts.xml $DEST_SERVER_PATH/users.d/
|
|
else
|
|
ln -sf $SRC_PATH/users.d/disable_async_inserts.xml $DEST_SERVER_PATH/users.d/
|
|
fi
|
|
|
|
if [[ "$USE_DATABASE_REPLICATED" == "1" ]]; then
|
|
ln -sf $SRC_PATH/users.d/database_replicated.xml $DEST_SERVER_PATH/users.d/
|
|
ln -sf $SRC_PATH/config.d/database_replicated.xml $DEST_SERVER_PATH/config.d/
|
|
rm $DEST_SERVER_PATH/config.d/zookeeper.xml
|
|
rm $DEST_SERVER_PATH/config.d/keeper_port.xml
|
|
rm $DEST_SERVER_PATH/config.d/keeper_max_request_size.xml
|
|
|
|
# There is a bug in config reloading, so we cannot override macros using --macros.replica r2
|
|
# And we have to copy configs...
|
|
ch_server_1_path=$DEST_SERVER_PATH/../clickhouse-server1
|
|
ch_server_2_path=$DEST_SERVER_PATH/../clickhouse-server2
|
|
mkdir -p $ch_server_1_path
|
|
mkdir -p $ch_server_2_path
|
|
# chown clickhouse $ch_server_1_path
|
|
# chown clickhouse $ch_server_2_path
|
|
# chgrp clickhouse $ch_server_1_path
|
|
# chgrp clickhouse $ch_server_2_path
|
|
cp -r $DEST_SERVER_PATH/* $ch_server_1_path
|
|
cp -r $DEST_SERVER_PATH/* $ch_server_2_path
|
|
|
|
rm $ch_server_1_path/config.d/macros.xml $ch_server_2_path/config.d/macros.xml
|
|
cat $DEST_SERVER_PATH/config.d/macros.xml | sed "s|<replica>r1</replica>|<replica>r2</replica>|" > $ch_server_1_path/config.d/macros.xml
|
|
cat $DEST_SERVER_PATH/config.d/macros.xml | sed "s|<shard>s1</shard>|<shard>s2</shard>|" > $ch_server_2_path/config.d/macros.xml
|
|
|
|
rm $ch_server_1_path/config.d/transactions.xml
|
|
rm $ch_server_2_path/config.d/transactions.xml
|
|
cat $DEST_SERVER_PATH/config.d/transactions.xml | sed "s|/test/clickhouse/txn|/test/clickhouse/txn1|" > $ch_server_1_path/config.d/transactions.xml
|
|
cat $DEST_SERVER_PATH/config.d/transactions.xml | sed "s|/test/clickhouse/txn|/test/clickhouse/txn2|" > $ch_server_2_path/config.d/transactions.xml
|
|
|
|
# ch_server_lib_1=$DEST_SERVER_PATH/../../var/lib/clickhouse1
|
|
# ch_server_lib_2=$DEST_SERVER_PATH/../../var/lib/clickhouse2
|
|
# mkdir -p $ch_server_lib_1 $ch_server_lib_2
|
|
# chown clickhouse $ch_server_lib_1 $ch_server_lib_2
|
|
# chgrp clickhouse $ch_server_lib_1 $ch_server_lib_2
|
|
sed -i "s|<filesystem_caches_path>/var/lib/clickhouse/filesystem_caches/</filesystem_caches_path>|<filesystem_caches_path>/var/lib/clickhouse/filesystem_caches_1/</filesystem_caches_path>|" $ch_server_1_path/config.d/filesystem_caches_path.xml
|
|
sed -i "s|<filesystem_caches_path>/var/lib/clickhouse/filesystem_caches/</filesystem_caches_path>|<filesystem_caches_path>/var/lib/clickhouse/filesystem_caches_2/</filesystem_caches_path>|" $ch_server_2_path/config.d/filesystem_caches_path.xml
|
|
sed -i "s|<custom_cached_disks_base_directory replace=\"replace\">/var/lib/clickhouse/filesystem_caches/</custom_cached_disks_base_directory>|<custom_cached_disks_base_directory replace=\"replace\">/var/lib/clickhouse/filesystem_caches_1/</custom_cached_disks_base_directory>|" $ch_server_1_path/config.d/filesystem_caches_path.xml
|
|
sed -i "s|<custom_cached_disks_base_directory replace=\"replace\">/var/lib/clickhouse/filesystem_caches/</custom_cached_disks_base_directory>|<custom_cached_disks_base_directory replace=\"replace\">/var/lib/clickhouse/filesystem_caches_2/</custom_cached_disks_base_directory>|" $ch_server_2_path/config.d/filesystem_caches_path.xml
|
|
|
|
# Remove SSH config from replicas to avoid port conflicts on tcp_ssh_port.
|
|
rm -f $ch_server_1_path/config.d/ssh.xml $ch_server_1_path/config.d/ssh_host_rsa_key
|
|
rm -f $ch_server_2_path/config.d/ssh.xml $ch_server_2_path/config.d/ssh_host_rsa_key
|
|
fi
|
|
|
|
ln -sf $SRC_PATH/config.d/wasm_udf.xml $DEST_SERVER_PATH/config.d/
|
|
|
|
if [ ! -z "$WASM_ENGINE" ]; then
|
|
# ensure that default entry exists and we correctly replace it
|
|
grep -q -F ">wasmtime<" $DEST_SERVER_PATH/config.d/wasm_udf.xml || exit 1
|
|
sed -i "s|>wasmtime<|>${WASM_ENGINE}<|" $DEST_SERVER_PATH/config.d/wasm_udf.xml
|
|
fi
|
|
|
|
if [[ "$BUGFIX_VALIDATE_CHECK" -eq 1 || "$PREVIOUS_RELEASE_CONFIG" -eq 1 ]]; then
|
|
function remove_keeper_config()
|
|
{
|
|
sed -i "/<$1>$2<\/$1>/d" $DEST_SERVER_PATH/config.d/keeper_port.xml
|
|
}
|
|
|
|
remove_keeper_config "nuraft_use_bg_thread_for_snapshot_io" "[[:digit:]]\+"
|
|
fi
|
|
|
|
if [[ $REMOTE_DATABASE_DISK -eq 1 ]]; then
|
|
ln -sf $SRC_PATH/config.d/remote_database_disk.xml $DEST_SERVER_PATH/config.d/
|
|
echo "Installed remote_database_disk.xml config"
|
|
fi
|
|
|
|
ln -sf $SRC_PATH/client_config.xml $DEST_CLIENT_PATH/config.xml
|