Skip to content

Commit 9533907

Browse files
authored
Merge pull request ClickHouse#79236 from ClickHouse/ncb/startupscript-warning-msg
better warning message for skipped startup scripts
2 parents d5b2057 + b15f0ac commit 9533907

File tree

1 file changed

+23
-8
lines changed

1 file changed

+23
-8
lines changed

programs/server/Server.cpp

Lines changed: 23 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -828,6 +828,8 @@ void loadStartupScripts(const Poco::Util::AbstractConfiguration & config, Contex
828828
config.keys("startup_scripts", keys);
829829

830830
SetResultDetailsFunc callback;
831+
std::vector<String> skipped_startup_scripts;
832+
831833
for (const auto & key : keys)
832834
{
833835
std::string full_prefix = "startup_scripts." + key;
@@ -854,17 +856,20 @@ void loadStartupScripts(const Poco::Util::AbstractConfiguration & config, Contex
854856
executeQuery(condition_read_buffer, condition_write_buffer, true, startup_context, callback, QueryFlags{ .internal = true }, std::nullopt, {});
855857

856858
auto result = condition_write_buffer.str();
857-
858859
if (result != "1\n" && result != "true\n")
859860
{
860861
if (result != "0\n" && result != "false\n")
861-
context->addOrUpdateWarningMessage(
862-
Context::WarningType::SKIPPING_CONDITION_QUERY,
863-
PreformattedMessage::create(
864-
"The condition query returned `{}`, which can't be interpreted as a boolean (`0`, "
865-
"`false`, `1`, `true`). Will skip this query.",
866-
result));
867-
862+
{
863+
if (result.empty())
864+
LOG_DEBUG(log, "Skipping startup script as condition query returned empty value.");
865+
else
866+
LOG_DEBUG(
867+
log,
868+
"Skipping startup script as condition query returned value `{}` "
869+
"which can't be interpreted as a boolean (`0`, `false`, `1`, `true`).",
870+
result);
871+
skipped_startup_scripts.emplace_back(full_prefix);
872+
}
868873
continue;
869874
}
870875

@@ -880,6 +885,16 @@ void loadStartupScripts(const Poco::Util::AbstractConfiguration & config, Contex
880885
executeQuery(read_buffer, write_buffer, true, startup_context, callback, QueryFlags{ .internal = true }, std::nullopt, {});
881886
}
882887

888+
if (!skipped_startup_scripts.empty())
889+
{
890+
context->addOrUpdateWarningMessage(
891+
Context::WarningType::SKIPPING_CONDITION_QUERY,
892+
PreformattedMessage::create(
893+
"Skipped the following startup script(s): {} as the condition query for those returned values, "
894+
"which can't be interpreted as a boolean (`0`, `false`, `1`, `true`).",
895+
fmt::join(skipped_startup_scripts, ", ")));
896+
}
897+
883898
CurrentMetrics::set(CurrentMetrics::StartupScriptsExecutionState, StartupScriptsExecutionState::Success);
884899
}
885900
catch (...)

0 commit comments

Comments
 (0)