Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(server): save dragonfly snapshot in a new format by default #802

Merged
merged 1 commit into from
Feb 15, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion src/server/debugcmd.cc
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ using namespace std;

ABSL_DECLARE_FLAG(string, dir);
ABSL_DECLARE_FLAG(string, dbfilename);
ABSL_DECLARE_FLAG(bool, df_snapshot_format);

namespace dfly {

Expand Down Expand Up @@ -174,7 +175,7 @@ void DebugCmd::Reload(CmdArgList args) {
trans->InitByArgs(0, {});
VLOG(1) << "Performing save";

GenericError ec = sf_.DoSave(false, trans.get());
GenericError ec = sf_.DoSave(absl::GetFlag(FLAGS_df_snapshot_format), trans.get());
if (ec) {
return (*cntx_)->SendError(ec.Format());
}
Expand Down
8 changes: 6 additions & 2 deletions src/server/server_family.cc
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,8 @@ ABSL_FLAG(string, requirepass, "",
"If empty can also be set with DFLY_PASSWORD environment variable.");
ABSL_FLAG(string, save_schedule, "",
"glob spec for the UTC time to save a snapshot which matches HH:MM 24h time");
ABSL_FLAG(bool, df_snapshot_format, true,
"if true, save in dragonfly-specific snapshotting format");
Comment on lines +59 to +60
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

the name is a bit misleading for a bool flag if you interpret df_ as a prefix, not the type of the format


ABSL_DECLARE_FLAG(uint32_t, port);
ABSL_DECLARE_FLAG(bool, cache_mode);
Expand Down Expand Up @@ -567,7 +569,7 @@ void ServerFamily::SnapshotScheduling(const SnapshotSpec& spec) {
boost::intrusive_ptr<Transaction> trans(new Transaction{cid});
trans->InitByArgs(0, {});

GenericError ec = DoSave(false, trans.get());
GenericError ec = DoSave(absl::GetFlag(FLAGS_df_snapshot_format), trans.get());
if (ec) {
LOG(WARNING) << "Failed to perform snapshot " << ec.Format();
}
Expand Down Expand Up @@ -1185,7 +1187,7 @@ void ServerFamily::Memory(CmdArgList args, ConnectionContext* cntx) {

void ServerFamily::Save(CmdArgList args, ConnectionContext* cntx) {
string err_detail;
bool new_version = false;
bool new_version = absl::GetFlag(FLAGS_df_snapshot_format);
if (args.size() > 2) {
return (*cntx)->SendError(kSyntaxErr);
}
Expand All @@ -1195,6 +1197,8 @@ void ServerFamily::Save(CmdArgList args, ConnectionContext* cntx) {
string_view sub_cmd = ArgS(args, 1);
if (sub_cmd == "DF") {
new_version = true;
} else if (sub_cmd == "RDB") {
new_version = false;
} else {
return (*cntx)->SendError(UnknownSubCmd(sub_cmd, "SAVE"), kSyntaxErrType);
}
Expand Down