16
16
17
17
#include " snapshot_sync.hpp"
18
18
19
+ #include < atomic>
19
20
#include < exception>
20
21
#include < latch>
21
22
@@ -193,14 +194,19 @@ void SnapshotSync::build_missing_indexes() {
193
194
return ;
194
195
}
195
196
196
- SILK_INFO << " SnapshotSync: missing indexes detected, rebuild started" ;
197
+ SILK_INFO << " SnapshotSync: " << missing_indexes.size () << " missing indexes to build" ;
198
+ size_t total_tasks = missing_indexes.size ();
199
+ std::atomic_size_t done_tasks;
197
200
198
201
for (const auto & index : missing_indexes) {
199
- workers.push_task ([= ]() {
202
+ workers.push_task ([index, total_tasks, &done_tasks ]() {
200
203
try {
201
- SILK_INFO << " SnapshotSync: build index: " << index->path ().filename () << " start " ;
204
+ SILK_INFO << " SnapshotSync: building index " << index->path ().filename () << " ... " ;
202
205
index->build ();
203
- SILK_INFO << " SnapshotSync: build index: " << index->path ().filename () << " end" ;
206
+ done_tasks++;
207
+ SILK_INFO << " SnapshotSync: built index " << index->path ().filename () << " ;"
208
+ << " progress: " << (done_tasks * 100 / total_tasks) << " % "
209
+ << done_tasks << " of " << total_tasks << " indexes ready" ;
204
210
} catch (const std::exception& ex) {
205
211
SILK_CRIT << " SnapshotSync: build index: " << index->path ().filename () << " failed [" << ex.what () << " ]" ;
206
212
throw ;
@@ -215,6 +221,8 @@ void SnapshotSync::build_missing_indexes() {
215
221
// Wait for any already-started-but-unfinished work in case of stop request
216
222
workers.pause ();
217
223
workers.wait_for_tasks ();
224
+
225
+ SILK_INFO << " SnapshotSync: built missing indexes" ;
218
226
}
219
227
220
228
void SnapshotSync::update_database (db::RWTxn& txn, BlockNum max_block_available) {
0 commit comments