diff --git a/.github/workflows/external-raft.yml b/.github/workflows/external-raft.yml deleted file mode 100644 index da23836f8..000000000 --- a/.github/workflows/external-raft.yml +++ /dev/null @@ -1,38 +0,0 @@ -name: CI Tests (external libraft) - -on: - - push - - pull_request - -jobs: - build-and-test: - runs-on: ubuntu-latest - - steps: - - uses: actions/checkout@v4 - - - name: Setup dependencies - run: | - sudo apt update - sudo apt install -y libsqlite3-dev liblz4-dev libuv1-dev - - - name: Build raft - run: | - git clone https://github.com/canonical/raft --depth 1 - cd raft - autoreconf -i - ./configure --enable-debug --enable-sanitize - make -j4 - sudo make install - sudo ldconfig - - - name: Build dqlite - run: | - autoreconf -i - ./configure --enable-debug --enable-sanitize - make -j4 - - - name: Test - run: | - export LIBRAFT_TRACE=1 LIBDQLITE_TRACE=1 - make -j4 check || (cat ./test-suite.log && false) diff --git a/Makefile.am b/Makefile.am index 96fbeb963..bb144b53c 100644 --- a/Makefile.am +++ b/Makefile.am @@ -17,11 +17,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 @@ -81,7 +76,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 \ @@ -135,7 +129,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 @@ -183,9 +176,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 \ @@ -201,7 +192,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 += \ @@ -345,8 +335,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 diff --git a/configure.ac b/configure.ac index 10ae2c2eb..6e9bcef9e 100644 --- a/configure.ac +++ b/configure.ac @@ -35,12 +35,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])], []) AC_ARG_WITH(static-deps, AS_HELP_STRING([--with-static-deps[=ARG]], @@ -64,24 +69,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" = "xyes" -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" = "xyes" -a "x$have_lz4" = "xno"], + [AC_MSG_ERROR([liblz4 required but not found])], + []) AM_CONDITIONAL(LZ4_AVAILABLE, test "x$have_lz4" = "xyes") diff --git a/src/leader.c b/src/leader.c index 61ef91639..18c0fb53d 100644 --- a/src/leader.c +++ b/src/leader.c @@ -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); @@ -336,13 +332,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; diff --git a/src/raft.h b/src/raft.h index 76bea3500..f688672e5 100644 --- a/src/raft.h +++ b/src/raft.h @@ -1,11 +1,4 @@ -#if defined(USE_SYSTEM_RAFT) - -#include -#include -#include - -#elif !defined(RAFT_H) - +#ifndef RAFT_H #define RAFT_H #include diff --git a/src/server.c b/src/server.c index d66babfd4..9b3007a66 100644 --- a/src/server.c +++ b/src/server.c @@ -1085,15 +1085,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) diff --git a/test/integration/test_cluster.c b/test/integration/test_cluster.c index 131be5132..ea8f9d6bb 100644 --- a/test/integration/test_cluster.c +++ b/test/integration/test_cluster.c @@ -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; @@ -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. */ @@ -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 */ @@ -199,7 +197,6 @@ 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); @@ -207,7 +204,6 @@ TEST(cluster, dataOnNewNode, setUp, tearDown, 0, cluster_params) 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; } @@ -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) { @@ -368,5 +362,3 @@ TEST(cluster, last_entry_edge_cases, setUp, tearDown, 0, NULL) return MUNIT_OK; } - -#endif