diff --git a/dbms/src/Interpreters/ExternalLoader.cpp b/dbms/src/Interpreters/ExternalLoader.cpp index 0320a1b691a..6486b394623 100644 --- a/dbms/src/Interpreters/ExternalLoader.cpp +++ b/dbms/src/Interpreters/ExternalLoader.cpp @@ -848,7 +848,11 @@ private: else error_count = 0; - next_update_time = calculateNextUpdateTime(new_object, error_count); + LoadablePtr object = previous_version; + if (new_object) + object = new_object; + + next_update_time = calculateNextUpdateTime(object, error_count); } catch (...) { @@ -963,7 +967,8 @@ private: TimePoint calculateNextUpdateTime(const LoadablePtr & loaded_object, size_t error_count) const { static constexpr auto never = TimePoint::max(); - if (!error_count) + + if (loaded_object) { if (!loaded_object->supportUpdates()) return never; @@ -973,8 +978,11 @@ private: if (lifetime.min_sec == 0 || lifetime.max_sec == 0) return never; - std::uniform_int_distribution distribution{lifetime.min_sec, lifetime.max_sec}; - return std::chrono::system_clock::now() + std::chrono::seconds{distribution(rnd_engine)}; + if (!error_count) + { + std::uniform_int_distribution distribution{lifetime.min_sec, lifetime.max_sec}; + return std::chrono::system_clock::now() + std::chrono::seconds{distribution(rnd_engine)}; + } } return std::chrono::system_clock::now() + std::chrono::seconds(calculateDurationWithBackoff(rnd_engine, error_count)); diff --git a/dbms/tests/queries/0_stateless/01018_ddl_dictionaries_select.reference b/dbms/tests/queries/0_stateless/01018_ddl_dictionaries_select.reference index 5afa7f27963..a7f56f9ee03 100644 --- a/dbms/tests/queries/0_stateless/01018_ddl_dictionaries_select.reference +++ b/dbms/tests/queries/0_stateless/01018_ddl_dictionaries_select.reference @@ -15,3 +15,5 @@ dict2 Dictionary table_for_dict MergeTree database_for_dict dict1 ComplexKeyCache database_for_dict dict2 Hashed +6 +6 diff --git a/dbms/tests/queries/0_stateless/01018_ddl_dictionaries_select.sql b/dbms/tests/queries/0_stateless/01018_ddl_dictionaries_select.sql index 19f2d1244a0..cb63ce86ada 100644 --- a/dbms/tests/queries/0_stateless/01018_ddl_dictionaries_select.sql +++ b/dbms/tests/queries/0_stateless/01018_ddl_dictionaries_select.sql @@ -95,4 +95,24 @@ SELECT name, engine FROM system.tables WHERE database = 'database_for_dict' ORDE SELECT database, name, type FROM system.dictionaries WHERE database = 'database_for_dict' ORDER BY name; +-- check dictionary will not update +CREATE DICTIONARY database_for_dict.dict3 +( + key_column UInt64 DEFAULT 0, + some_column String EXPRESSION toString(fourth_column), + fourth_column Float64 DEFAULT 42.0 +) +PRIMARY KEY key_column +SOURCE(CLICKHOUSE(HOST 'localhost' PORT 9000 USER 'default' TABLE 'table_for_dict' DB 'database_for_dict')) +LIFETIME(0) +LAYOUT(HASHED()); + +SELECT dictGetString('database_for_dict.dict3', 'some_column', toUInt64(12)); + +DROP TABLE database_for_dict.table_for_dict; + +SYSTEM RELOAD DICTIONARIES; + +SELECT dictGetString('database_for_dict.dict3', 'some_column', toUInt64(12)); + DROP DATABASE IF EXISTS database_for_dict;