| 615 | } |
| 616 | |
| 617 | LoadTaskPtrs loadMetadataSystem(ContextMutablePtr context, bool async_load_system_database) |
| 618 | { |
| 619 | auto component_guard = Coordination::setCurrentComponent("loadMetadataSystem"); |
| 620 | loadSystemDatabaseImpl(context, DatabaseCatalog::SYSTEM_DATABASE, |
| 621 | context->getApplicationType() == Context::ApplicationType::SERVER ? "Atomic" : "Memory"); |
| 622 | loadSystemDatabaseImpl(context, DatabaseCatalog::INFORMATION_SCHEMA, "Memory"); |
| 623 | loadSystemDatabaseImpl(context, DatabaseCatalog::INFORMATION_SCHEMA_UPPERCASE, "Memory"); |
| 624 | |
| 625 | TablesLoader::Databases databases = |
| 626 | { |
| 627 | {DatabaseCatalog::SYSTEM_DATABASE, DatabaseCatalog::instance().getSystemDatabase()}, |
| 628 | {DatabaseCatalog::INFORMATION_SCHEMA, DatabaseCatalog::instance().getDatabase(DatabaseCatalog::INFORMATION_SCHEMA)}, |
| 629 | {DatabaseCatalog::INFORMATION_SCHEMA_UPPERCASE, DatabaseCatalog::instance().getDatabase(DatabaseCatalog::INFORMATION_SCHEMA_UPPERCASE)}, |
| 630 | }; |
| 631 | TablesLoader loader{context, databases, LoadingStrictnessLevel::FORCE_RESTORE}; |
| 632 | |
| 633 | auto load_tasks = loader.loadTablesAsync(); |
| 634 | auto startup_tasks = loader.startupTablesAsync(); |
| 635 | |
| 636 | if (async_load_system_database) |
| 637 | { |
| 638 | scheduleLoad(load_tasks); |
| 639 | scheduleLoad(startup_tasks); |
| 640 | |
| 641 | // Do NOT wait, just return tasks for continuation or later wait. |
| 642 | return joinTasks(load_tasks, startup_tasks); |
| 643 | } |
| 644 | else |
| 645 | { |
| 646 | waitLoad(TablesLoaderForegroundPoolId, load_tasks); |
| 647 | |
| 648 | /// This has to be done before the initialization of system logs `initializeSystemLogs()`, |
| 649 | /// otherwise there is a race condition between the system database initialization |
| 650 | /// and creation of new tables in the database. |
| 651 | waitLoad(TablesLoaderForegroundPoolId, startup_tasks); |
| 652 | return {}; |
| 653 | } |
| 654 | } |
| 655 | |
| 656 | } |
no test coverage detected