Skip to content

Fix leaving possible leftovers in case of CREATE TABLE fails#94174

Merged
azat merged 6 commits intoClickHouse:masterfrom
azat:failed-create-leftovers
Jan 23, 2026
Merged

Fix leaving possible leftovers in case of CREATE TABLE fails#94174
azat merged 6 commits intoClickHouse:masterfrom
azat:failed-create-leftovers

Conversation

@azat
Copy link
Copy Markdown
Member

@azat azat commented Jan 14, 2026

Changelog category (leave one):

  • Improvement

Changelog entry (a user-readable short description of the changes that goes into CHANGELOG.md):

Fix leaving possible leftovers in case of CREATE TABLE fails

Refs: #93959

@clickhouse-gh
Copy link
Copy Markdown
Contributor

clickhouse-gh bot commented Jan 14, 2026

Workflow [PR], commit [2ecce0a]

Summary:

job_name test_name status info comment
Stateless tests (amd_asan, distributed plan, parallel, 1/2) failure
00625_arrays_in_nested FAIL cidb
Stateless tests (amd_tsan, parallel) failure
00625_arrays_in_nested FAIL cidb
BuzzHouse (amd_debug) failure
Logical error: 'Inconsistent AST formatting: the query: (STID: 1941-1bfa) FAIL cidb, issue

@clickhouse-gh clickhouse-gh bot added the pr-improvement Pull request with some product improvements label Jan 14, 2026
@azat azat force-pushed the failed-create-leftovers branch 2 times, most recently from 0b3fb65 to af5afe6 Compare January 14, 2026 14:48
@azat azat force-pushed the failed-create-leftovers branch from af5afe6 to 5b42c2d Compare January 14, 2026 15:47
@azat azat requested a review from evillique January 20, 2026 11:02
@evillique
Copy link
Copy Markdown
Member

@azat Not sure, but test_storage_s3_queue/test_5.py::test_failed_startup looks related, did you look into it?

@evillique
Copy link
Copy Markdown
Member

Ci failures are clearly related:

Error:
Logical error: 'Cannot add ZooKeeper operation because query is executed. It's a bug.'.
---

Stack trace:
pthread_kill @ 0x00000000000969fd
gsignal @ 0x0000000000042476
__lgamma_r_finite @ 0x00000000000287f3
src/Common/Exception.cpp:57: DB::abortOnFailedAssertion(String const&, std::basic_string_view<char, std::char_traits<char>>, void* const*, unsigned long, unsigned long) @ 0x00000000163fa7fc
src/Common/Exception.cpp:90: DB::handle_error_code(String const&, std::basic_string_view<char, std::char_traits<char>>, int, bool, std::vector<void*, std::allocator<void*>> const&) @ 0x00000000163fbc0d
src/Common/Exception.cpp:143: DB::Exception::Exception(DB::Exception::MessageMasked&&, int, bool) @ 0x00000000163fbef9
src/Common/Exception.h:172: DB::Exception::Exception(String&&, int, String, bool) @ 0x000000000d9e65d4
src/Common/Exception.h:58: DB::Exception::Exception(PreformattedMessage&&, int) @ 0x000000000d9e60d1
src/Common/Exception.h:190: DB::Exception::Exception<>(int, FormatStringHelperImpl<>) @ 0x0000000016404779
src/Interpreters/DDLTask.h:250: DB::ZooKeeperMetadataTransaction::addOp(std::shared_ptr<Coordination::Request>&&) @ 0x000000001b988608
src/Databases/DatabaseReplicated.cpp:2091: DB::DatabaseReplicated::dropTable(std::shared_ptr<DB::Context const>, String const&, bool) @ 0x000000001b9812ed
src/Interpreters/InterpreterCreateQuery.cpp:2062: DB::InterpreterCreateQuery::doCreateTable(DB::ASTCreateQuery&, DB::InterpreterCreateQuery::TableProperties const&, std::unique_ptr<DB::DDLGuard, std::default_delete<DB::DDLGuard>>&, DB::LoadingStrictnessLevel) @ 0x000000001c80975a
src/Interpreters/InterpreterCreateQuery.cpp:1728: DB::InterpreterCreateQuery::createTable(DB::ASTCreateQuery&) @ 0x000000001c7ff6f0
src/Interpreters/InterpreterCreateQuery.cpp:2421: DB::InterpreterCreateQuery::execute() @ 0x000000001c80d832
src/Interpreters/executeQuery.cpp:1738: DB::executeQueryImpl(char const*, char const*, std::shared_ptr<DB::Context>, DB::QueryFlags, DB::QueryProcessingStage::Enum, std::unique_ptr<DB::ReadBuffer, std::default_delete<DB::ReadBuffer>>&, std::shared_ptr<DB::IAST>&, std::shared_ptr<DB::ImplicitTransactionControlExecutor>, std::function<void ()>, DB::QueryResultDetails&) @ 0x000000001cbd37e8
src/Interpreters/executeQuery.cpp:2122: DB::executeQuery(std::unique_ptr<DB::ReadBuffer, std::default_delete<DB::ReadBuffer>>, DB::WriteBuffer&, std::shared_ptr<DB::Context>, std::function<void (DB::QueryResultDetails const&)>, DB::QueryFlags, std::optional<DB::FormatSettings> const&, std::function<void (DB::IOutputFormat&, String const&, std::shared_ptr<DB::Context const> const&, std::optional<DB::FormatSettings> const&)>, std::function<void ()>, std::function<void ()>) @ 0x000000001cbd9386
src/Interpreters/executeQuery.cpp:1987: DB::executeQuery(DB::ReadBuffer&, DB::WriteBuffer&, std::shared_ptr<DB::Context>, std::function<void (DB::QueryResultDetails const&)>, DB::QueryFlags, std::optional<DB::FormatSettings> const&, std::function<void (DB::IOutputFormat&, String const&, std::shared_ptr<DB::Context const> const&, std::optional<DB::FormatSettings> const&)>, std::function<void ()>, std::function<void ()>) @ 0x000000001cbd8ceb
src/Interpreters/DDLWorker.cpp:516: DB::DDLWorker::tryExecuteQuery(DB::DDLTaskBase&, std::shared_ptr<zkutil::ZooKeeper> const&, bool) @ 0x000000001c69819d
src/Interpreters/DDLWorker.cpp:684: DB::DDLWorker::processTask(DB::DDLTaskBase&, std::shared_ptr<zkutil::ZooKeeper> const&, bool) @ 0x000000001c695fb1
src/Databases/DatabaseReplicatedWorker.cpp:466: DB::DatabaseReplicatedDDLWorker::tryEnqueueAndExecuteEntry(DB::DDLLogEntry&, std::shared_ptr<DB::Context const>, bool) @ 0x000000001b99e360
src/Databases/DatabaseReplicated.cpp:1376: DB::DatabaseReplicated::tryEnqueueReplicatedDDL(std::shared_ptr<DB::IAST> const&, std::shared_ptr<DB::Context const>, DB::QueryFlags) @ 0x000000001b96acc9
src/Interpreters/InterpreterCreateQuery.cpp:1702: DB::InterpreterCreateQuery::createTable(DB::ASTCreateQuery&) @ 0x000000001c7ff2b6
src/Interpreters/InterpreterCreateQuery.cpp:2421: DB::InterpreterCreateQuery::execute() @ 0x000000001c80d832
src/Interpreters/executeQuery.cpp:1738: DB::executeQueryImpl(char const*, char const*, std::shared_ptr<DB::Context>, DB::QueryFlags, DB::QueryProcessingStage::Enum, std::unique_ptr<DB::ReadBuffer, std::default_delete<DB::ReadBuffer>>&, std::shared_ptr<DB::IAST>&, std::shared_ptr<DB::ImplicitTransactionControlExecutor>, std::function<void ()>, DB::QueryResultDetails&) @ 0x000000001cbd37e8
src/Interpreters/executeQuery.cpp:1962: DB::executeQuery(String const&, std::shared_ptr<DB::Context>, DB::QueryFlags, DB::QueryProcessingStage::Enum) @ 0x000000001cbcd214
src/Server/TCPHandler.cpp:774: DB::TCPHandler::runImpl() @ 0x0000000020435049
src/Server/TCPHandler.cpp:2867: DB::TCPHandler::run() @ 0x000000002044ffe4
base/poco/Net/src/TCPServerConnection.cpp:40: Poco::Net::TCPServerConnection::start() @ 0x000000002693948e
base/poco/Net/src/TCPServerDispatcher.cpp:115: Poco::Net::TCPServerDispatcher::run() @ 0x0000000026939afb
base/poco/Foundation/src/ThreadPool.cpp:205: Poco::PooledThread::run() @ 0x00000000268d9fff
base/poco/Foundation/src/Thread_POSIX.cpp:341: Poco::ThreadImpl::runnableEntry(void*) @ 0x00000000268d768f
? @ 0x0000000000094ac3
? @ 0x00000000001268c0

So I think it is ok to remove the

 try
    {
        res->startup();
    }
    catch (...)
    {
        if (create.attach)
            database->detachTable(getContext(), create.getTable());
        else
            database->dropTable(getContext(), create.getTable());

        throw;
    }

until the next time

We cannot execute do DROP from CREATE after database->createTable(),
since this will lead to "Cannot add ZooKeeper operation because query is
executed" in case of Replicated database.

This reverts commit 4b4df9c.
@azat
Copy link
Copy Markdown
Member Author

azat commented Jan 22, 2026

Yep, thanks for taking a look, I've reverted the last patch.

@azat azat enabled auto-merge January 22, 2026 22:03
@azat azat added this pull request to the merge queue Jan 23, 2026
Merged via the queue into ClickHouse:master with commit e6cde77 Jan 23, 2026
128 of 132 checks passed
@azat azat deleted the failed-create-leftovers branch January 23, 2026 00:13
@robot-ch-test-poll1 robot-ch-test-poll1 added the pr-synced-to-cloud The PR is synced to the cloud repo label Jan 23, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

pr-improvement Pull request with some product improvements pr-synced-to-cloud The PR is synced to the cloud repo

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants