Skip to content

Commit

Permalink
Merge remote-tracking branch 'codership/wsrep-lib/master' into PXC-4050
Browse files Browse the repository at this point in the history
Merge commit 940ba9b with conflicts.

# Conflicts:
#	include/wsrep/server_state.hpp
#	src/server_state.cpp
  • Loading branch information
kamil-holubicki committed Feb 21, 2023
2 parents 8d19246 + 940ba9b commit 9d98232
Show file tree
Hide file tree
Showing 24 changed files with 904 additions and 70 deletions.
12 changes: 10 additions & 2 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -159,19 +159,27 @@ jobs:
else
export CXX="ccache clang++-${{ matrix.config.version }}"
fi
if [ ${{ matrix.config.version }} == "4.8" ]
if [ ${{ matrix.config.CC }} == "gcc" ] && [ ${{ matrix.config.version }} == "4.8" ]
then
STRICT=OFF
DBSIM=OFF
TESTS_EXTRA=OFF
elif [ ${{ matrix.config.CC }} == "gcc" ] && [ ${{ matrix.config.version }} == "5" ]
then
STRICT=ON
DBSIM=ON
TESTS_EXTRA=OFF
else
STRICT=ON
DBSIM=ON
TESTS_EXTRA=ON
fi
cmake $GITHUB_WORKSPACE -DCMAKE_BUILD_TYPE=${{ matrix.config.type }} \
-DWSREP_LIB_MAINTAINER_MODE:BOOL=ON \
-DWSREP_LIB_STRICT_BUILD_FLAGS:BOOL=$STRICT \
-DWSREP_LIB_WITH_DBSIM:BOOL=$DBSIM \
-DWSREP_LIB_WITH_ASAN:BOOL=ON .
-DWSREP_LIB_WITH_ASAN:BOOL=ON \
-DWSREP_LIB_WITH_UNIT_TESTS_EXTRA:BOOL=$TESTS_EXTRA
- name: Build
working-directory: ${{runner.workspace}}/build
Expand Down
47 changes: 34 additions & 13 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,10 @@ check_cxx_compiler_flag("-Wsuggest-override" HAVE_SUGGEST_OVERRIDE)
if (HAVE_SUGGEST_OVERRIDE)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wsuggest-override")
endif()
check_cxx_compiler_flag("-Wextra-semi" HAVE_EXTRA_SEMI)
if (HAVE_EXTRA_SEMI)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wextra-semi")
endif()

if (WSREP_LIB_STRICT_BUILD_FLAGS)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Weffc++")
Expand Down Expand Up @@ -119,40 +123,57 @@ endif()
set(MIN_BOOST_VERSION "1.54.0")
if (WSREP_LIB_WITH_UNIT_TESTS)
if (WSREP_LIB_WITH_UNIT_TESTS_EXTRA)
message(STATUS "Compiling extra unit tests")
set(json_HEADER "boost/json/src.hpp")
# Extra tests may require packages from very recent boost which may be
# unavailable on the system. In such case download private boost distro.
check_include_file_cxx(${json_HEADER} system_json_FOUND)
if (NOT system_json_FOUND)
if (NOT WITH_BOOST)
set(WITH_BOOST "${CMAKE_SOURCE_DIR}/../boost")
set(WITH_BOOST "${CMAKE_SOURCE_DIR}/third_party/boost")
endif()
set(DOWNLOAD_BOOST ON)
include (cmake/boost.cmake)
set(MIN_BOOST_VERSION "${BOOST_MAJOR}.${BOOST_MINOR}.${BOOST_PATCH}")
message(STATUS "Boost includes: ${BOOST_INCLUDE_DIR}, ver: ${MIN_BOOST_VERSION}")
find_package(Boost ${MIN_BOOST_VERSION} REQUIRED
COMPONENTS json headers
COMPONENTS json headers unit_test_framework
PATHS ${WITH_BOOST}/lib/cmake
NO_DEFAULT_PATH
)
# Boost 1.76.0 comes very sloppy (and not only in JSON department)
# - need to disable some checks.
set(ADDITIONAL_CXX_FLAGS "-Wno-effc++ -Wno-conversion -Wno-suggest-override -Wno-overloaded-virtual")
set(ADDITIONAL_CXX_INCLUDES ${BOOST_INCLUDE_DIR})
check_include_file_cxx(${json_HEADER} json_FOUND
"-I${ADDITIONAL_CXX_INCLUDES} ${ADDITIONAL_CXX_FLAGS}"
)
# Include as system header to be more permissive about generated
# warnings.
set(CMAKE_REQUIRED_FLAGS "-isystem ${BOOST_INCLUDE_DIR}")
check_include_file_cxx(${json_HEADER} json_FOUND)
if (NOT json_FOUND)
message(FATAL_ERROR "Required header 'boost/json.hpp' not found: ${json_FOUND}")
else()
include_directories(SYSTEM ${ADDITIONAL_CXX_INCLUDES})
include_directories(SYSTEM ${BOOST_INCLUDE_DIR})
endif()
endif()
else()
find_package(Boost ${MIN_BOOST_VERSION}
COMPONENTS unit_test_framework
)

if (NOT Boost_UNIT_TEST_FRAMEWORK_FOUND)
# Check if we have header implementation available from
# extracted source tarball.
if (NOT WITH_BOOST)
message(FATAL_ERROR "System Boost not found, specify Boost installation with WITH_BOOST=<install_dir>")
endif()
CHECK_CXX_SOURCE_COMPILES(
"
#define BOOST_TEST_ALTERNATIVE_INIT_API
#include <boost/test/included/unit_test.hpp>
bool init_unit_test() { return true; }
"
FOUND_BOOST_TEST_INCLUDED_UNIT_TEST_HPP)
if (NOT FOUND_BOOST_TEST_INCLUDED_UNIT_TEST_HPP)
message(FATAL_ERROR "Boost unit test header not found")
endif()
endif()
endif()
find_package(Boost ${MIN_BOOST_VERSION} REQUIRED
unit_test_framework
)
endif()

if (WSREP_LIB_WITH_DBSIM)
Expand Down
2 changes: 1 addition & 1 deletion cmake/boost.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ FUNCTION(GET_FILE_SIZE FILE_NAME OUTPUT_SIZE)
ENDFUNCTION()

SET(BOOST_MAJOR "1")
SET(BOOST_MINOR "76")
SET(BOOST_MINOR "77")
SET(BOOST_PATCH "0")
SET(BOOST_PACKAGE_NAME "boost_${BOOST_MAJOR}_${BOOST_MINOR}_${BOOST_PATCH}")
SET(BOOST_TARBALL "${BOOST_PACKAGE_NAME}.tar.gz")
Expand Down
2 changes: 1 addition & 1 deletion dbsim/db_server.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,6 @@ namespace db
std::vector<std::shared_ptr<db::client>> clients_;
std::vector<boost::thread> client_threads_;
};
};
}

#endif // WSREP_DB_SERVER_HPP
25 changes: 19 additions & 6 deletions dbsim/db_simulator.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,10 @@ void db::simulator::sst(db::server& server,
db::client dummy(*(i->second), wsrep::client_id(-1),
wsrep::client_state::m_local, params());

i->second->server_state().sst_received(dummy.client_service(), 0);
if (i->second->server_state().sst_received(dummy.client_service(), 0))
{
throw wsrep::runtime_error("Call to SST received failed");
}
server.server_state().sst_sent(gtid, 0);
}

Expand Down Expand Up @@ -169,12 +172,19 @@ void db::simulator::start()
wsrep::log_debug() << "main: Starting applier";
server.start_applier();
wsrep::log_debug() << "main: Waiting initializing state";
server.server_state().wait_until_state(wsrep::server_state::s_initializing);
if (server.server_state().wait_until_state(
wsrep::server_state::s_initializing))
{
throw wsrep::runtime_error("Failed to reach initializing state");
}
wsrep::log_debug() << "main: Calling initialized";
server.server_state().initialized();
wsrep::log_debug() << "main: Waiting for synced state";
server.server_state().wait_until_state(
wsrep::server_state::s_synced);
if (server.server_state().wait_until_state(
wsrep::server_state::s_synced))
{
throw wsrep::runtime_error("Failed to reach synced state");
}
wsrep::log_debug() << "main: Server synced";
}

Expand Down Expand Up @@ -220,8 +230,11 @@ void db::simulator::stop()
wsrep::log_info() << sv.name() << " = " << sv.value();
});
server.server_state().disconnect();
server.server_state().wait_until_state(
wsrep::server_state::s_disconnected);
if (server.server_state().wait_until_state(
wsrep::server_state::s_disconnected))
{
throw wsrep::runtime_error("Failed to reach disconnected state");
}
server.stop_applier();
server.server_state().unload_provider();
}
Expand Down
3 changes: 2 additions & 1 deletion dbsim/db_storage_engine.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,8 @@
#include "db_params.hpp"

#include "wsrep/mutex.hpp"
#include "wsrep/client_state.hpp"
#include "wsrep/view.hpp"
#include "wsrep/transaction.hpp"

#include <atomic>
#include <unordered_set>
Expand Down
2 changes: 1 addition & 1 deletion dbsim/db_tls.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,6 @@ namespace db
static void init(int mode);
static std::string stats();
};
};
}

#endif // WSREP_DB_TLS_HPP
5 changes: 2 additions & 3 deletions include/wsrep/client_state.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -31,12 +31,9 @@
#ifndef WSREP_CLIENT_STATE_HPP
#define WSREP_CLIENT_STATE_HPP

#include "server_state.hpp"
#include "server_service.hpp"
#include "provider.hpp"
#include "transaction.hpp"
#include "client_id.hpp"
#include "client_service.hpp"
#include "mutex.hpp"
#include "lock.hpp"
#include "buffer.hpp"
Expand All @@ -46,8 +43,10 @@

namespace wsrep
{
class client_service;
class server_state;
class provider;
class condition_variable;

enum client_error
{
Expand Down
2 changes: 1 addition & 1 deletion include/wsrep/high_priority_service.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -24,11 +24,11 @@
#ifndef WSREP_HIGH_PRIORITY_SERVICE_HPP
#define WSREP_HIGH_PRIORITY_SERVICE_HPP

#include "xid.hpp"
#include "server_state.hpp"

namespace wsrep
{
class xid;
class ws_handle;
class ws_meta;
class const_buffer;
Expand Down
Loading

0 comments on commit 9d98232

Please sign in to comment.