2023-06-30 14:08:48 +00:00
#!/usr/bin/env bash
2023-08-11 13:58:26 +00:00
# Tags: no-fasttest, no-parallel, no-s3-storage, no-random-settings
2023-06-30 14:08:48 +00:00
# set -x
CUR_DIR = $( cd " $( dirname " ${ BASH_SOURCE [0] } " ) " && pwd )
# shellcheck source=../shell_config.sh
. " $CUR_DIR " /../shell_config.sh
$CLICKHOUSE_CLIENT -nm --query "" "
DROP TABLE IF EXISTS test;
CREATE TABLE test ( a Int32, b String)
ENGINE = MergeTree( ) ORDER BY tuple( )
2023-08-12 15:27:50 +00:00
SETTINGS disk = disk( type = cache, max_size = '100Ki' , path = ${ CLICKHOUSE_TEST_UNIQUE_NAME } , delayed_cleanup_interval_ms = 10000000, disk = s3_disk) , min_bytes_for_wide_part = 10485760;
2023-06-30 14:08:48 +00:00
INSERT INTO test SELECT 1, 'test' ;
"" "
query_id = $RANDOM
$CLICKHOUSE_CLIENT --query_id " $query_id " --query "SELECT * FROM test FORMAT Null SETTINGS enable_filesystem_cache_log = 1"
${ CLICKHOUSE_CLIENT } -q "system flush logs"
key = $( $CLICKHOUSE_CLIENT -nm --query "" "
SELECT key FROM system.filesystem_cache_log WHERE query_id = '$query_id' ORDER BY size DESC LIMIT 1;
"" " )
offset = $( $CLICKHOUSE_CLIENT -nm --query "" "
SELECT offset FROM system.filesystem_cache_log WHERE query_id = '$query_id' ORDER BY size DESC LIMIT 1;
"" " )
path = $( $CLICKHOUSE_CLIENT -nm --query "" "
SELECT cache_path FROM system.filesystem_cache WHERE key = '$key' AND file_segment_range_begin = $offset ;
"" " )
rm $path
2023-08-12 11:15:05 +00:00
$CLICKHOUSE_CLIENT --query "SELECT * FROM test FORMAT Null SETTINGS enable_filesystem_cache_log = 1" 2>& 1 | grep -F -e "No such file or directory" > /dev/null && echo "ok" || echo "fail"
2023-06-30 14:08:48 +00:00
CLICKHOUSE_CLIENT = $( echo ${ CLICKHOUSE_CLIENT } | sed 's/' " --send_logs_level= ${ CLICKHOUSE_CLIENT_SERVER_LOGS_LEVEL } " '/--send_logs_level=fatal/g' )
$CLICKHOUSE_CLIENT --query "SYSTEM SYNC FILESYSTEM CACHE" 2>& 1 | grep -q " $key " && echo 'ok' || echo 'fail'
$CLICKHOUSE_CLIENT --query "SELECT * FROM test FORMAT Null"
2023-07-31 11:05:41 +00:00
key = $( $CLICKHOUSE_CLIENT -nm --query "" "
SELECT key FROM system.filesystem_cache_log WHERE query_id = '$query_id' ORDER BY size DESC LIMIT 1;
"" " )
offset = $( $CLICKHOUSE_CLIENT -nm --query "" "
SELECT offset FROM system.filesystem_cache_log WHERE query_id = '$query_id' ORDER BY size DESC LIMIT 1;
"" " )
path = $( $CLICKHOUSE_CLIENT -nm --query "" "
SELECT cache_path FROM system.filesystem_cache WHERE key = '$key' AND file_segment_range_begin = $offset ;
"" " )
echo -n 'fff' > $path
2023-08-11 13:58:26 +00:00
#cat $path
2023-07-31 11:05:41 +00:00
$CLICKHOUSE_CLIENT --query "SYSTEM SYNC FILESYSTEM CACHE" 2>& 1 | grep -q " $key " && echo 'ok' || echo 'fail'
$CLICKHOUSE_CLIENT --query "SELECT * FROM test FORMAT Null"
2023-06-30 14:08:48 +00:00
$CLICKHOUSE_CLIENT --query "SYSTEM SYNC FILESYSTEM CACHE"