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

Remove option to link separately-built libraft #690

Merged
merged 2 commits into from
Sep 20, 2024
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
38 changes: 0 additions & 38 deletions .github/workflows/external-raft.yml

This file was deleted.

12 changes: 0 additions & 12 deletions Makefile.am
Original file line number Diff line number Diff line change
Expand Up @@ -8,11 +8,6 @@ if DQLITE_NEXT_ENABLED
AM_CFLAGS += -DDQLITE_NEXT
endif

if !BUILD_RAFT_ENABLED
AM_CFLAGS += $(RAFT_CFLAGS) -DUSE_SYSTEM_RAFT
AM_LDFLAGS += $(RAFT_LIBS)
endif

if DEBUG_ENABLED
AM_CFLAGS += -O0
else
Expand Down Expand Up @@ -72,7 +67,6 @@ libdqlite_la_CFLAGS = $(AM_CFLAGS) -fvisibility=hidden -DRAFT_API=''
libdqlite_la_LDFLAGS = $(AM_LDFLAGS) -version-info 0:1:0
libdqlite_la_SOURCES = $(basic_dqlite_sources)

if BUILD_RAFT_ENABLED
libraft_la_SOURCES = \
src/raft/byte.c \
src/raft/callbacks.c \
Expand Down Expand Up @@ -126,7 +120,6 @@ libraft_la_SOURCES = \
src/raft/uv_writer.c

libdqlite_la_SOURCES += $(libraft_la_SOURCES)
endif # BUILD_RAFT_ENABLED

check_PROGRAMS = unit-test integration-test

Expand Down Expand Up @@ -174,9 +167,7 @@ unit_test_CFLAGS = $(AM_CFLAGS) -Wno-unknown-warning-option -Wno-uninitialized -
unit_test_LDFLAGS = $(AM_LDFLAGS)
unit_test_LDADD = libtest.la

if BUILD_RAFT_ENABLED
unit_test_LDADD += libraft.la
endif

integration_test_SOURCES = \
test/integration/test_client.c \
Expand All @@ -192,7 +183,6 @@ integration_test_CFLAGS = $(AM_CFLAGS) -Wno-conversion
integration_test_LDFLAGS = $(AM_LDFLAGS) -no-install
integration_test_LDADD = libtest.la libdqlite.la

if BUILD_RAFT_ENABLED
check_LTLIBRARIES += libraft.la

check_PROGRAMS += \
Expand Down Expand Up @@ -336,8 +326,6 @@ raft_core_unit_test_CFLAGS += -DLZ4_ENABLED
libraft_la_CFLAGS += -DLZ4_ENABLED
endif

endif # BUILD_RAFT_ENABLED

if BUILD_SQLITE_ENABLED
noinst_LTLIBRARIES = libsqlite3.la
libsqlite3_la_SOURCES = sqlite3.c
Expand Down
32 changes: 14 additions & 18 deletions configure.ac
Original file line number Diff line number Diff line change
Expand Up @@ -36,12 +36,17 @@ AM_CONDITIONAL(BACKTRACE_ENABLED, test "x$enable_backtrace" = "xyes")
AC_ARG_ENABLE(build-sqlite, AS_HELP_STRING([--enable-build-sqlite[=ARG]], [build libsqlite3 from sqlite3.c in the build root [default=no]]))
AM_CONDITIONAL(BUILD_SQLITE_ENABLED, test "x$enable_build_sqlite" = "xyes")

AC_ARG_ENABLE(build-raft, AS_HELP_STRING([--enable-build-raft[=ARG]], [use the bundled raft sources instead of linking to libraft [default=no]]))
AM_CONDITIONAL(BUILD_RAFT_ENABLED, test "x$enable_build_raft" = "xyes")
AC_ARG_ENABLE([build-raft],
[AS_HELP_STRING([--enable-build-raft[=ARG]],
[use the bundled raft sources instead of linking libraft (default is yes, required)])],
[enable_build_raft=$enableval],
[enable_build_raft=yes])
AS_IF([test "x$enable_build_raft" != "xyes"],
AC_MSG_ERROR([linking to a separately-built libraft is no longer supported]),
[])

AC_ARG_ENABLE(dqlite-next, AS_HELP_STRING([--enable-dqlite-next[=ARG]], [build with the experimental dqlite backend [default=no]]))
AM_CONDITIONAL(DQLITE_NEXT_ENABLED, test "x$enable_dqlite_next" = "xyes")
AS_IF([test "x$enable_build_raft" != "xyes" -a "x$enable_dqlite_next" = "xyes"], [AC_MSG_ERROR([dqlite-next requires bundled raft])], [])

# Whether to enable code coverage.
AX_CODE_COVERAGE
Expand All @@ -60,24 +65,15 @@ AC_SYS_LARGEFILE
# Checks for libraries
PKG_CHECK_MODULES(SQLITE, [sqlite3 >= 3.22.0], [], [])
PKG_CHECK_MODULES(UV, [libuv >= 1.34.0], [], [])
AS_IF([test "x$enable_build_raft" != "xyes"], [PKG_CHECK_MODULES(RAFT, [raft >= 0.18.1], [], [])], [])


# Allow not linking to liblz4 even if it's present.
AC_ARG_WITH([lz4], AS_HELP_STRING([--without-lz4], [never link to liblz4]))
AS_IF([test "x$enable_build_raft" = "xyes"],
# Building raft
[AS_IF([test "x$with_lz4" != "xno"],
[PKG_CHECK_MODULES(LZ4, [liblz4 >= 1.7.1], [have_lz4=yes], [have_lz4=no])],
[have_lz4=no])
AS_IF([test "x$with_lz4" != "xno" -a "x$have_lz4" = "xno"],
[AC_MSG_ERROR([liblz4 required but not found])],
[])],
# Not building raft
[AS_IF([test "x$with_lz4" = "xyes"],
[AC_MSG_ERROR([linking lz4 doesn't make sense unless building raft])],
[])
have_lz4=no])
AS_IF([test "x$with_lz4" != "xno"],
[PKG_CHECK_MODULES(LZ4, [liblz4 >= 1.7.1], [have_lz4=yes], [have_lz4=no])],
[have_lz4=no])
AS_IF([test "x$with_lz4" != "xno" -a "x$have_lz4" = "xno"],
[AC_MSG_ERROR([liblz4 required but not found])],
[])

AM_CONDITIONAL(LZ4_AVAILABLE, test "x$have_lz4" = "xyes")

Expand Down
8 changes: 0 additions & 8 deletions src/leader.c
Original file line number Diff line number Diff line change
Expand Up @@ -224,11 +224,7 @@ static void leaderMaybeCheckpointLegacy(struct leader *l)
tracef("raft_malloc - no mem");
goto err_after_buf_alloc;
}
#ifdef USE_SYSTEM_RAFT
rv = raft_apply(l->raft, apply, &buf, 1, leaderCheckpointApplyCb);
#else
rv = raft_apply(l->raft, apply, &buf, NULL, 1, leaderCheckpointApplyCb);
#endif
if (rv != 0) {
tracef("raft_apply failed %d", rv);
raft_free(apply);
Expand Down Expand Up @@ -337,13 +333,9 @@ static int leaderApplyFrames(struct exec *req,
apply->type = COMMAND_FRAMES;
idSet(apply->req.req_id, req->id);

#ifdef USE_SYSTEM_RAFT
rv = raft_apply(l->raft, &apply->req, &buf, 1, leaderApplyFramesCb);
#else
/* TODO actual WAL slice goes here */
struct raft_entry_local_data local_data = {};
rv = raft_apply(l->raft, &apply->req, &buf, &local_data, 1, leaderApplyFramesCb);
#endif
if (rv != 0) {
tracef("raft apply failed %d", rv);
goto err_after_command_encode;
Expand Down
9 changes: 1 addition & 8 deletions src/raft.h
Original file line number Diff line number Diff line change
@@ -1,11 +1,4 @@
#if defined(USE_SYSTEM_RAFT)

#include <raft.h>
#include <raft/uv.h>
#include <raft/fixture.h>

#elif !defined(RAFT_H)

#ifndef RAFT_H
#define RAFT_H

#include <stdarg.h>
Expand Down
7 changes: 0 additions & 7 deletions src/server.c
Original file line number Diff line number Diff line change
Expand Up @@ -1078,15 +1078,8 @@ int dqlite_node_describe_last_entry(dqlite_node *n,
raft_term *t = (raft_term *)term;
int rv;

#ifdef USE_SYSTEM_RAFT
(void)i;
(void)t;
(void)rv;
return DQLITE_ERROR;
#else
rv = raft_io_describe_last_entry(&n->raft_io, i, t);
return rv == 0 ? 0 : DQLITE_ERROR;
#endif
}

dqlite_node_id dqlite_generate_node_id(const char *address)
Expand Down
10 changes: 1 addition & 9 deletions test/integration/test_cluster.c
Original file line number Diff line number Diff line change
Expand Up @@ -134,6 +134,7 @@ TEST(cluster, dataOnNewNode, setUp, tearDown, 0, cluster_params)
strtol(munit_parameters_get(params, "num_records"), NULL, 0);
unsigned id = 2;
const char *address = "@2";
int rv;

HANDSHAKE;
OPEN;
Expand All @@ -159,8 +160,6 @@ TEST(cluster, dataOnNewNode, setUp, tearDown, 0, cluster_params)
struct test_server *first = &f->servers[0];
test_server_stop(first);
test_server_prepare(first, params);
#ifndef USE_SYSTEM_RAFT
int rv;
/* One entry per INSERT, plus one for the initial configuration, plus
* one for the CREATE TABLE, plus one legacy checkpoint command entry
* after 993 records or two after 2200 records. */
Expand All @@ -179,7 +178,6 @@ TEST(cluster, dataOnNewNode, setUp, tearDown, 0, cluster_params)
munit_assert_uint64(expected_entries, <=, last_entry_index);
munit_assert_uint64(last_entry_index, <, expected_entries + max_barriers);
munit_assert_uint64(last_entry_term, ==, 1);
#endif
test_server_run(first);

/* The full table is visible from the new node */
Expand All @@ -199,15 +197,13 @@ TEST(cluster, dataOnNewNode, setUp, tearDown, 0, cluster_params)
struct test_server *second = &f->servers[1];
test_server_stop(second);
test_server_prepare(second, params);
#ifndef USE_SYSTEM_RAFT
rv = dqlite_node_describe_last_entry(second->dqlite,
&last_entry_index,
&last_entry_term);
munit_assert_int(rv, ==, 0);
munit_assert_uint64(expected_entries + 1, <=, last_entry_index);
munit_assert_uint64(last_entry_index, <, expected_entries + max_barriers + 1);
munit_assert_uint64(last_entry_term, ==, 1);
#endif
test_server_run(second);
return MUNIT_OK;
}
Expand Down Expand Up @@ -332,8 +328,6 @@ TEST(cluster, modifyingQuerySql, setUp, tearDown, 0, cluster_params)
return MUNIT_OK;
}

#ifndef USE_SYSTEM_RAFT

/* Edge cases for dqlite_node_describe_last_entry. */
TEST(cluster, last_entry_edge_cases, setUp, tearDown, 0, NULL)
{
Expand Down Expand Up @@ -368,5 +362,3 @@ TEST(cluster, last_entry_edge_cases, setUp, tearDown, 0, NULL)

return MUNIT_OK;
}

#endif
Loading