mirror of
https://github.com/dragonflydb/dragonfly.git
synced 2025-05-11 18:35:46 +02:00
feat(server): Exit process if error is report during initial load snapshot (#4907)
Exit process if error is reported when we try to initially load snapshot from cloud storage or local directory. Fixes #4840 Signed-off-by: mkaruza <mario@dragonflydb.io>
This commit is contained in:
parent
89aa54d785
commit
a5819aa9ca
2 changed files with 22 additions and 2 deletions
|
@ -927,9 +927,11 @@ void ServerFamily::LoadFromSnapshot() {
|
||||||
if (std::error_code(load_path_result.error()) == std::errc::no_such_file_or_directory) {
|
if (std::error_code(load_path_result.error()) == std::errc::no_such_file_or_directory) {
|
||||||
LOG(WARNING) << "Load snapshot: No snapshot found";
|
LOG(WARNING) << "Load snapshot: No snapshot found";
|
||||||
} else {
|
} else {
|
||||||
util::fb2::LockGuard lk{loading_stats_mu_};
|
loading_stats_mu_.lock();
|
||||||
loading_stats_.failed_restore_count++;
|
loading_stats_.failed_restore_count++;
|
||||||
LOG(ERROR) << "Failed to load snapshot: " << load_path_result.error().Format();
|
loading_stats_mu_.unlock();
|
||||||
|
LOG(ERROR) << "Failed to load snapshot with error: " << load_path_result.error().Format();
|
||||||
|
exit(1);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -326,6 +326,24 @@ def delete_s3_objects(bucket, prefix):
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
|
# If DRAGONFLY_S3_BUCKET is configured, AWS credentials must also be
|
||||||
|
# configured.
|
||||||
|
@pytest.mark.skipif(
|
||||||
|
"DRAGONFLY_S3_BUCKET" not in os.environ or os.environ["DRAGONFLY_S3_BUCKET"] == "",
|
||||||
|
reason="AWS S3 snapshots bucket is not configured",
|
||||||
|
)
|
||||||
|
async def test_exit_on_s3_snapshot_load_err(df_factory):
|
||||||
|
invalid_s3_dir = "s3://{DRAGONFLY_S3_BUCKET}" + "_invalid_bucket_"
|
||||||
|
df_server = df_factory.create(
|
||||||
|
dir=invalid_s3_dir, dbfilename="db", exit_on_cloud_dir_snapshot_load_err=True
|
||||||
|
)
|
||||||
|
df_server.start()
|
||||||
|
# Let's wait so that process exit
|
||||||
|
await asyncio.sleep(2)
|
||||||
|
with pytest.raises(Exception):
|
||||||
|
df_server._check_status()
|
||||||
|
|
||||||
|
|
||||||
# If DRAGONFLY_S3_BUCKET is configured, AWS credentials must also be
|
# If DRAGONFLY_S3_BUCKET is configured, AWS credentials must also be
|
||||||
# configured.
|
# configured.
|
||||||
@pytest.mark.skipif(
|
@pytest.mark.skipif(
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue