Skip to content

Commit 1e92d48

Browse files
Add way to skip missing inputs in DB merge.
1 parent 8eff06f commit 1e92d48

File tree

2 files changed

+23
-6
lines changed

2 files changed

+23
-6
lines changed

fossilize_db.cpp

+18-4
Original file line numberDiff line numberDiff line change
@@ -2243,7 +2243,8 @@ void DatabaseInterface::request_shutdown()
22432243
shutdown_requested.store(true, std::memory_order_relaxed);
22442244
}
22452245

2246-
bool merge_concurrent_databases_last_use(const char *append_archive, const char * const *source_paths, size_t num_source_paths)
2246+
bool merge_concurrent_databases_last_use(const char *append_archive, const char * const *source_paths, size_t num_source_paths,
2247+
bool skip_missing_inputs)
22472248
{
22482249
std::unordered_map<Hash, uint64_t> timestamps[RESOURCE_COUNT];
22492250

@@ -2256,7 +2257,13 @@ bool merge_concurrent_databases_last_use(const char *append_archive, const char
22562257
if (source == 0)
22572258
continue;
22582259
else
2259-
return false;
2260+
{
2261+
if (!skip_missing_inputs)
2262+
return false;
2263+
2264+
LOGW("Archive %s could not be prepared, skipping.\n", path);
2265+
continue;
2266+
}
22602267
}
22612268

22622269
for (unsigned i = 0; i < RESOURCE_COUNT; i++)
@@ -2301,7 +2308,8 @@ bool merge_concurrent_databases_last_use(const char *append_archive, const char
23012308
return true;
23022309
}
23032310

2304-
bool merge_concurrent_databases(const char *append_archive, const char * const *source_paths, size_t num_source_paths)
2311+
bool merge_concurrent_databases(const char *append_archive, const char * const *source_paths, size_t num_source_paths,
2312+
bool skip_missing_inputs)
23052313
{
23062314
auto append_db = std::unique_ptr<DatabaseInterface>(create_stream_archive_database(append_archive, DatabaseMode::Append));
23072315
if (!append_db->prepare())
@@ -2312,7 +2320,13 @@ bool merge_concurrent_databases(const char *append_archive, const char * const *
23122320
const char *path = source_paths[source];
23132321
auto source_db = std::unique_ptr<DatabaseInterface>(create_stream_archive_database(path, DatabaseMode::ReadOnly));
23142322
if (!source_db->prepare())
2315-
return false;
2323+
{
2324+
if (!skip_missing_inputs)
2325+
return false;
2326+
2327+
LOGW("Archive %s could not be prepared, skipping.\n", path);
2328+
continue;
2329+
}
23162330

23172331
for (unsigned i = 0; i < RESOURCE_COUNT; i++)
23182332
{

fossilize_db.hpp

+5-2
Original file line numberDiff line numberDiff line change
@@ -245,12 +245,15 @@ DatabaseInterface *create_concurrent_database_with_encoded_extra_paths(const cha
245245
const char *encoded_read_only_database_paths);
246246

247247
// Merges stream archives found in source_paths into append_database_path.
248-
bool merge_concurrent_databases(const char *append_database_path, const char * const *source_paths, size_t num_source_paths);
248+
bool merge_concurrent_databases(const char *append_database_path,
249+
const char * const *source_paths, size_t num_source_paths,
250+
bool skip_missing_inputs = false);
249251

250252
// Merges stream archives found in source_paths into append_database_path.
251253
// When there are duplicates in append database and any other database, picks the entry with the highest 8 byte timestamp payload.
252254
bool merge_concurrent_databases_last_use(const char *append_database_path,
253-
const char * const *source_paths, size_t num_source_paths);
255+
const char * const *source_paths, size_t num_source_paths,
256+
bool skip_missing_inputs = false);
254257

255258
// For set_bucket_path() behavior on a concurrent database:
256259
// Must be called before prepare().

0 commit comments

Comments
 (0)