@@ -98,17 +98,12 @@ void middle_pgsql_t::table_desc::build_index(std::string const &conninfo) const
9898 return ;
9999 }
100100
101- util::timer_t timer;
102-
103101 // Use a temporary connection here because we might run in a separate
104102 // thread context.
105103 pg_conn_t db_connection{conninfo};
106104
107105 log_info (" Building index on table '{}'" , name ());
108106 db_connection.exec (m_create_fw_dep_indexes);
109-
110- log_info (" Done postprocessing on table '{}' in {}" , name (),
111- util::human_readable_duration (timer.stop ()));
112107}
113108
114109namespace {
@@ -644,13 +639,22 @@ void middle_pgsql_t::stop(thread_pool_t &pool)
644639 } else if (!m_options->append ) {
645640 // Building the indexes takes time, so do it asynchronously.
646641 for (auto &table : m_tables) {
647- pool.submit (std::bind (& middle_pgsql_t ::table_desc::build_index,
648- &table,
649- m_options->database_options .conninfo ()));
642+ table. task_set ( pool.submit (
643+ std::bind (& middle_pgsql_t ::table_desc::build_index, &table,
644+ m_options->database_options .conninfo () )));
650645 }
651646 }
652647}
653648
649+ void middle_pgsql_t::wait ()
650+ {
651+ for (auto &table : m_tables) {
652+ auto const run_time = table.task_wait ();
653+ log_info (" Done postprocessing on table '{}' in {}" , table.name (),
654+ util::human_readable_duration (run_time));
655+ }
656+ }
657+
654658static table_sql sql_for_nodes (bool create_table) noexcept
655659{
656660 table_sql sql{};
0 commit comments