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

Java: Add SAVE command. #1309

Draft
wants to merge 5 commits into
base: main
Choose a base branch
from

Conversation

Yury-Fridlyand
Copy link
Collaborator

@Yury-Fridlyand Yury-Fridlyand commented Apr 18, 2024

Issue #, if available:
N/A

Description of changes:
https://redis.io/docs/latest/commands/save/

Note: No IT for that command, because:

  1. It may fail randomly with Background save already in progress error
  2. It may affect other tests

By submitting this pull request, I confirm that you can use, modify, copy, and redistribute this contribution, under the terms of your choice.

* Add `SAVE` commands.

Signed-off-by: Yury-Fridlyand <yury.fridlyand@improving.com>

* Update IT.

Signed-off-by: Yury-Fridlyand <yury.fridlyand@improving.com>

* PR comments.

Signed-off-by: Yury-Fridlyand <yury.fridlyand@improving.com>

---------

Signed-off-by: Yury-Fridlyand <yury.fridlyand@improving.com>
Signed-off-by: Yury-Fridlyand <yury.fridlyand@improving.com>
Signed-off-by: Yury-Fridlyand <yury.fridlyand@improving.com>
@@ -283,6 +283,37 @@ public interface ServerManagementClusterCommands {
*/
CompletableFuture<ClusterValue<String[]>> time(Route route);

/**
* Synchronously saves the database(s) to disk.<br>
Copy link
Contributor

Choose a reason for hiding this comment

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

Nit:
Performs a synchronous save of the dataset producing a point in time snapshot of all the data inside the Redis instance, in the form of an RDB file.
Just copy valkey/redis? Could be confusing to see the keyword snapshot in the return but not talked about in the description.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Copied from there:

127.0.0.1:6379> command docs save
1# "save" =>
   1# "summary" => "Synchronously saves the database(s) to disk."
   2# "since" => "1.0.0"
   3# "group" => "server"
   4# "complexity" => "O(N) where N is the total number of keys in all databases"

* @param <T> Command return type.
*/
@SneakyThrows
public static <T> Pair<T, String> tryCommandWithExpectedError(
Copy link
Contributor

Choose a reason for hiding this comment

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

Do we want to ask the AWS team what they think the testing we are doing for save?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Sure. @barshaul @shohamazon,
I use that function, because the command may return the error. I don't interpret this as a failure, so just ignore the error.
There is also 2 sec sleep between command calls to reduce the chance of the error. Unfortunately, can't eliminate it completely, even using a loop.

@SneakyThrows
public void save() {
String error = "Background save already in progress";
// use another client, because it could be blocked
Copy link
Contributor

Choose a reason for hiding this comment

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

Are you closing the clients if you are not using default?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

try block closes the temporary client

Signed-off-by: Yury-Fridlyand <yury.fridlyand@improving.com>
@Yury-Fridlyand Yury-Fridlyand marked this pull request as draft April 24, 2024 17:49
@Yury-Fridlyand
Copy link
Collaborator Author

Suspended - no desicion on how should we test that and whether GLIDE client needs that command

Signed-off-by: Yury-Fridlyand <yury.fridlyand@improving.com>
@Yury-Fridlyand Yury-Fridlyand marked this pull request as ready for review April 30, 2024 01:35
@Yury-Fridlyand Yury-Fridlyand marked this pull request as draft May 1, 2024 17:27
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
java issues and fixes related to the java client
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants