Merge pull request #7983 from ClickHouse/fix_dictionary_lifetime

Fix bug with minimal dictionary lifetime equals zero
This commit is contained in:
alexey-milovidov 2019-12-03 02:32:38 +03:00 committed by GitHub
commit 3355492f02
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 65 additions and 1 deletions

View File

@ -975,7 +975,7 @@ private:
/// do not update loadable objects with zero as lifetime
const auto & lifetime = loaded_object->getLifetime();
if (lifetime.min_sec == 0 || lifetime.max_sec == 0)
if (lifetime.min_sec == 0 && lifetime.max_sec == 0)
return never;
if (!error_count)

View File

@ -0,0 +1,4 @@
1.1
77.77
1.1
2.2

View File

@ -0,0 +1,60 @@
#!/usr/bin/env bash
CURDIR=$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)
. $CURDIR/../shell_config.sh
$CLICKHOUSE_CLIENT --query "DROP DATABASE IF EXISTS database_for_dict"
$CLICKHOUSE_CLIENT --query "CREATE DATABASE database_for_dict Engine = Ordinary"
$CLICKHOUSE_CLIENT --query "
CREATE TABLE database_for_dict.table_for_dict
(
key_column UInt64,
value Float64
)
ENGINE = MergeTree()
ORDER BY key_column"
$CLICKHOUSE_CLIENT --query "INSERT INTO database_for_dict.table_for_dict VALUES (1, 1.1)"
$CLICKHOUSE_CLIENT --query "
CREATE DICTIONARY database_for_dict.dict_with_zero_min_lifetime
(
key_column UInt64,
value Float64 DEFAULT 77.77
)
PRIMARY KEY key_column
SOURCE(CLICKHOUSE(HOST 'localhost' PORT 9000 USER 'default' TABLE 'table_for_dict' DB 'database_for_dict'))
LIFETIME(1)
LAYOUT(FLAT())"
$CLICKHOUSE_CLIENT --query "SELECT dictGetFloat64('database_for_dict.dict_with_zero_min_lifetime', 'value', toUInt64(1))"
$CLICKHOUSE_CLIENT --query "SELECT dictGetFloat64('database_for_dict.dict_with_zero_min_lifetime', 'value', toUInt64(2))"
$CLICKHOUSE_CLIENT --query "INSERT INTO database_for_dict.table_for_dict VALUES (2, 2.2)"
function check()
{
query_result=`$CLICKHOUSE_CLIENT --query "SELECT dictGetFloat64('database_for_dict.dict_with_zero_min_lifetime', 'value', toUInt64(2))"`
while [ $query_result != "2.2" ]
do
query_result=`$CLICKHOUSE_CLIENT --query "SELECT dictGetFloat64('database_for_dict.dict_with_zero_min_lifetime', 'value', toUInt64(2))"`
done
}
export -f check;
timeout 10 bash -c check
$CLICKHOUSE_CLIENT --query "SELECT dictGetFloat64('database_for_dict.dict_with_zero_min_lifetime', 'value', toUInt64(1))"
$CLICKHOUSE_CLIENT --query "SELECT dictGetFloat64('database_for_dict.dict_with_zero_min_lifetime', 'value', toUInt64(2))"
$CLICKHOUSE_CLIENT --query "DROP DATABASE IF EXISTS database_for_dict"