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

chore: clean up save #1709

Merged
merged 2 commits into from
Aug 21, 2023
Merged

chore: clean up save #1709

merged 2 commits into from
Aug 21, 2023

Conversation

dranikpg
Copy link
Contributor

@dranikpg dranikpg commented Aug 16, 2023

The current DoSave() became a 200+ loc monster that is not only difficult to extend but also to read. I noticed this when I wanted to extend it for search serialization.

Should not include any functional changes

Signed-off-by: Vladislav Oleshko <vlad@dragonflydb.io>
@dranikpg
Copy link
Contributor Author

@kostasrim Please take a brief look, I might proceed with some more changes. Some clarity comments might be missing

Copy link
Collaborator

@romange romange left a comment

Choose a reason for hiding this comment

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

probably the next step would be to move all the snapshot code out of server_family.cc

@dranikpg dranikpg changed the title [WIP] chore: clean up save chore: clean up save Aug 17, 2023
@dranikpg
Copy link
Contributor Author

probably the next step would be to move all the snapshot code out of server_family.cc

You mean in this PR?

Comment on lines 619 to 620
if (!is_cloud_)
full_path_ += ".tmp";
Copy link
Contributor Author

Choose a reason for hiding this comment

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

I changed it to add the .tmp suffix only if its not saved on cloud. Previously it was added in any case, yet snapshots are not renamed for the cloud env. I assume this was a bug

@@ -522,6 +516,247 @@ bool IsReplicatingNoOne(string_view host, string_view port) {
return absl::EqualsIgnoreCase(host, "no") && absl::EqualsIgnoreCase(port, "one");
}

struct SaveStagesInputs {
Copy link
Collaborator

Choose a reason for hiding this comment

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

according to the stylieguide, consider make it a class and declare variables as protected (they have underscores).

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I moved this out to a separate struct only to use aggregate initialization, its not possible with private/protected members. Alternatively I can just move the fields back and make a separate gigantic contructor that accepts them all

Copy link
Collaborator

Choose a reason for hiding this comment

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

Ok, how about the option of making the fields public (without underscores) and make this struct a data member instead of an inheritance?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

will open a separate fix on this 😬

@romange
Copy link
Collaborator

romange commented Aug 18, 2023

probably the next step would be to move all the snapshot code out of server_family.cc

You mean in this PR?

no :)

@romange
Copy link
Collaborator

romange commented Aug 18, 2023

lgtm

Copy link
Contributor

@kostasrim kostasrim left a comment

Choose a reason for hiding this comment

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

Really nice, much much simpler

src/server/server_family.cc Outdated Show resolved Hide resolved
src/server/server_family.cc Show resolved Hide resolved
src/server/server_family.cc Show resolved Hide resolved
Signed-off-by: Vladislav Oleshko <vlad@dragonflydb.io>
Copy link
Contributor

@royjacobson royjacobson left a comment

Choose a reason for hiding this comment

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

LGTM

@dranikpg dranikpg merged commit afb3928 into dragonflydb:main Aug 21, 2023
7 checks passed
@dranikpg dranikpg deleted the refactor-save branch August 25, 2023 06:28
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants