Skip to content

Commit

Permalink
Merge pull request #567 from cnnrznn/master
Browse files Browse the repository at this point in the history
Expose option to disable/enable raft snapshot compression.
  • Loading branch information
cole-miller authored Feb 12, 2024
2 parents 5e3128f + b2bcb10 commit 85615e4
Show file tree
Hide file tree
Showing 6 changed files with 26 additions and 0 deletions.
6 changes: 6 additions & 0 deletions include/dqlite.h
Original file line number Diff line number Diff line change
Expand Up @@ -444,6 +444,12 @@ DQLITE_API int dqlite_node_set_target_standbys(dqlite_node *n, int standbys);
*/
DQLITE_API int dqlite_node_set_auto_recovery(dqlite_node *n, bool enabled);

/**
* Enable or disable raft snapshot compression.
*/
DQLITE_API int dqlite_node_set_snapshot_compression(dqlite_node *n,
bool enabled);

/**
* Enable automatic role management on the server side for this node.
*
Expand Down
5 changes: 5 additions & 0 deletions src/server.c
Original file line number Diff line number Diff line change
Expand Up @@ -745,6 +745,11 @@ int dqlite_node_enable_role_management(dqlite_node *n)
return 0;
}

int dqlite_node_set_snapshot_compression(dqlite_node *n, bool enabled)
{
return raft_uv_set_snapshot_compression(&n->raft_io, enabled);
}

int dqlite_node_set_auto_recovery(dqlite_node *n, bool enabled)
{
raft_uv_set_auto_recovery(&n->raft_io, enabled);
Expand Down
2 changes: 2 additions & 0 deletions test/integration/test_fsm.c
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,7 @@ static char *bools[] = {"0", "1", NULL};
static char *snapshot_threshold[] = {"8192", NULL};
static MunitParameterEnum snapshot_params[] = {
{SNAPSHOT_THRESHOLD_PARAM, snapshot_threshold},
{SNAPSHOT_COMPRESSION_PARAM, bools},
{"disk_mode", bools},
{NULL, NULL},
};
Expand Down Expand Up @@ -597,6 +598,7 @@ static char *num_records[] = {
static MunitParameterEnum restore_params[] = {
{"num_records", num_records},
{SNAPSHOT_THRESHOLD_PARAM, snapshot_threshold},
{SNAPSHOT_COMPRESSION_PARAM, bools},
{"disk_mode", bools},
{NULL, NULL},
};
Expand Down
2 changes: 2 additions & 0 deletions test/integration/test_node.c
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
#include "../lib/fs.h"
#include "../lib/heap.h"
#include "../lib/runner.h"
#include "../lib/server.h"
#include "../lib/sqlite.h"

#include "../../include/dqlite.h"
Expand All @@ -17,6 +18,7 @@ static char *bools[] = {"0", "1", NULL};

static MunitParameterEnum node_params[] = {
{"disk_mode", bools},
{SNAPSHOT_COMPRESSION_PARAM, bools},
{NULL, NULL},
};

Expand Down
10 changes: 10 additions & 0 deletions test/lib/server.c
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,16 @@ void test_server_start(struct test_server *s, const MunitParameter params[])
munit_assert_int(rv, ==, 0);
}

const char *snapshot_compression_param =
munit_parameters_get(params, SNAPSHOT_COMPRESSION_PARAM);
if (snapshot_compression_param != NULL) {
bool snapshot_compression =
(bool)atoi(snapshot_compression_param);
rv = dqlite_node_set_snapshot_compression(s->dqlite,
snapshot_compression);
munit_assert_int(rv, ==, 0);
}

const char *disk_mode_param = munit_parameters_get(params, "disk_mode");
if (disk_mode_param != NULL) {
bool disk_mode = (bool)atoi(disk_mode_param);
Expand Down
1 change: 1 addition & 0 deletions test/lib/server.h
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
#include "munit.h"

#define SNAPSHOT_THRESHOLD_PARAM "snapshot-threshold"
#define SNAPSHOT_COMPRESSION_PARAM "snapshot_compression"

struct test_server
{
Expand Down

0 comments on commit 85615e4

Please sign in to comment.