Skip to content

Database Lazy: Cannot create table from metadata file (Terminate called for uncaught exception) #48151

Closed

Description

@Algunenano

Describe the bug
A link to the report

How to reproduce

AFAICS, it's a race condition between dropping/attaching the table and reading from system.tables.

system.tables calls ::tryGetCreateTableQuery() and in some situations, with lazy engine, this might throw:

  • ::tryGetCreateTableQuery
  • DatabaseOnDisk::getCreateTableQueryImpl
  • DatabaseLazy::tryGetTable
  • DatabaseLazy::loadTable
  • loadTable throws

I see 3 problems:

  • I don't expect tryGetCreateTableQuery to ever throw
  • I don't expect tryGetTable to ever throw either
  • Nobody caught the unexpected exception

Error message and/or stacktrace

 [ 1650 ] {} <Fatal> BaseDaemon: (version 23.3.1.1, build id: A5DD3B3E818E147E8EAAF455B08B4649247E4D65) (from thread 23578) Terminate called for uncaught exception:
 [ 1650 ] {} <Fatal> BaseDaemon: Code: 60. DB::Exception: Table `test_lazy_01014_concurrent_test_27`.`slog` doesn\'t exist.: Cannot create table from metadata file /var/lib/clickhouse/metadata/test_lazy_01014_concurrent_test_27/slog.sql. (UNKNOWN_TABLE), Stack trace (when copying this message, always
 [ 1650 ] {} <Fatal> BaseDaemon: 
 [ 1650 ] {} <Fatal> BaseDaemon: 0. ./build_docker/../contrib/llvm-project/libcxx/include/exception:0: Poco::Exception::Exception(String const&, int) @ 0x58812509 in /usr/bin/clickhouse
 [ 1650 ] {} <Fatal> BaseDaemon: 1. ./build_docker/../src/Common/Exception.cpp:0: DB::Exception::Exception(DB::Exception::MessageMasked&&, int, bool) @ 0x295414f2 in /usr/bin/clickhouse
 [ 1650 ] {} <Fatal> BaseDaemon: 2. DB::Exception::Exception<String, String>(int, FormatStringHelperImpl<std::type_identity<String>::type, std::type_identity<String>::type>, String&&, String&&) @ 0xc89fc64 in /usr/bin/clickhouse
 [ 1650 ] {} <Fatal> BaseDaemon: 3. ./build_docker/../src/Databases/DatabaseLazy.cpp:0: DB::DatabaseLazy::loadTable(String const&) const @ 0x46683342 in /usr/bin/clickhouse
 [ 1650 ] {} <Fatal> BaseDaemon: 4. ./build_docker/../src/Databases/DatabaseLazy.cpp:0: DB::DatabaseLazy::tryGetTable(String const&) const @ 0x4667f085 in /usr/bin/clickhouse
 [ 1650 ] {} <Fatal> BaseDaemon: 5. ./build_docker/../src/Databases/DatabaseLazy.h:0: DB::DatabaseLazy::tryGetTable(String const&, std::shared_ptr<DB::Context const>) const @ 0x4668f577 in /usr/bin/clickhouse
 [ 1650 ] {} <Fatal> BaseDaemon: 6. ./build_docker/../src/Databases/DatabaseOnDisk.cpp:459: DB::DatabaseOnDisk::getCreateTableQueryImpl(String const&, std::shared_ptr<DB::Context const>, bool) const @ 0x43192d7e in /usr/bin/clickhouse
 [ 1650 ] {} <Fatal> BaseDaemon: 7. ./build_docker/../src/Databases/IDatabase.h:0: DB::TablesBlockSource::generate() @ 0x40b76c5d in /usr/bin/clickhouse
 [ 1650 ] {} <Fatal> BaseDaemon: 8. ./build_docker/../src/Processors/Chunk.h:90: DB::ISource::tryGenerate() @ 0x4bc1968d in /usr/bin/clickhouse
 [ 1650 ] {} <Fatal> BaseDaemon: 9. ./build_docker/../contrib/llvm-project/libcxx/include/optional:344: DB::ISource::work() @ 0x4bc18e09 in /usr/bin/clickhouse
 [ 1650 ] {} <Fatal> BaseDaemon: 10. ./build_docker/../src/Processors/Executors/ExecutionThreadContext.cpp:0: DB::ExecutionThreadContext::executeTask() @ 0x4bc8846e in /usr/bin/clickhouse
 [ 1650 ] {} <Fatal> BaseDaemon: 11. ./build_docker/../src/Processors/Executors/PipelineExecutor.cpp:239: DB::PipelineExecutor::executeStepImpl(unsigned long, std::atomic<bool>*) @ 0x4bc4dfdd in /usr/bin/clickhouse
 [ 1650 ] {} <Fatal> BaseDaemon: 12. ./build_docker/../src/Processors/Executors/PipelineExecutor.cpp:381: DB::PipelineExecutor::executeImpl(unsigned long) @ 0x4bc4c068 in /usr/bin/clickhouse
 [ 1650 ] {} <Fatal> BaseDaemon: 13. ./build_docker/../src/Processors/Executors/PipelineExecutor.cpp:0: DB::PipelineExecutor::execute(unsigned long) @ 0x4bc4b9f4 in /usr/bin/clickhouse
 [ 1650 ] {} <Fatal> BaseDaemon: 14. ./build_docker/../src/Processors/Executors/PullingAsyncPipelineExecutor.cpp:0: void std::__function::__policy_invoker<void ()>::__call_impl<std::__function::__default_alloc_func<ThreadFromGlobalPoolImpl<true>::ThreadFromGlobalPoolImpl<DB::PullingAsyncPipelineExec
 [ 1650 ] {} <Fatal> BaseDaemon: 15. ./build_docker/../base/base/wide_integer_impl.h:789: ThreadPoolImpl<std::thread>::worker(std::__list_iterator<std::thread, void*>) @ 0x298c6e29 in /usr/bin/clickhouse
 [ 1650 ] {} <Fatal> BaseDaemon: 16. ./build_docker/../src/Common/ThreadPool.cpp:0: void* std::__thread_proxy[abi:v15000]<std::tuple<std::unique_ptr<std::__thread_struct, std::default_delete<std::__thread_struct>>, void ThreadPoolImpl<std::thread>::scheduleImpl<void>(std::function<void ()>, long, st
 [ 1650 ] {} <Fatal> BaseDaemon: 17. ? @ 0x7fbcd8a4c609 in ?
 [ 1650 ] {} <Fatal> BaseDaemon: 18. __clone @ 0x7fbcd8971133 in ?
 [ 1650 ] {} <Fatal> BaseDaemon:  (version 23.3.1.1)
 [ 41331 ] {} <Fatal> BaseDaemon: ########################################

Activity

  1. added
    testing
    on Mar 29, 2023
  2. rschu1ze commented on Jan 28, 2025

    @rschu1ze
    Member

    Unclear how to repro, closing.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    testing

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions