1
0
mirror of https://github.com/codership/wsrep-lib.git synced 2025-07-21 12:22:06 +03:00
Commit Graph

399 Commits

Author SHA1 Message Date
58aa3e821f Updated travis definitions
- Xenial is now default build environment
- Use Trusty for older compilers
2019-08-29 15:58:38 +03:00
20128556d6 Restore original thread local storage after releasing streaming applier.
In convert_streaming_client_to_applier() the new streaming applier
is created and deleted if the server has been disconnected. However,
releasing streaming applier may modify thread local storage. Call
store_globals() to restore thread local storage before returning.
2019-08-29 14:56:21 +03:00
55427188c1 avoid holding server_state lock when creating streaming applier
This fix avoids creating a lock cycle in MariaDB, between
LOCK_global_system_variables, LOCK_wsrep_cluster_config and
LOCK_wsrep_server_state.
2019-08-07 16:39:03 -03:00
0c54cbd3f8 codership/wsrep-lib#106 Relaxed assumptions about threading model
Sanity checks to detect concurrency bugs were assuming a threading
model where each client state would always be processed within
single thread of execution. This however may be too strong assumption
if the application uses some kind of thread pooling.

This patch relaxes those assumptions by removing current_thread_id_
from client_state and relaxing assertions against owning_thread_id_.

This patch also adds a new method
wait_rollback_complete_and_acquire_ownership() into
client_state. This method is idempotent and can be used to gain
control to client_state before before_command() is called.
The method will wait until possible background rollback process is
over and marks the state to s_exec to protect the state against
new background rollbacks.

Other fixes/improvements:
- High priority globals state is restored after discarding streaming.
- Allowed server_state transition donor -> synced.
- Client state method store_globals() was renamed to acquire_ownership()
  to better describe the intent. Method store_globals() was left for
  backwards compatibility and marked deprecated.
2019-08-05 15:12:44 +03:00
0f676bd893 codership/wsrep-lib#104 Error voting support
- populate and pass real error description buffer to provider in case
   of applying error
 - return 0 from server_state::on_apply() if error voting confirmed
   consistency
 - remove fragments and rollback after fragment applying failure
 - always release streaming applier on commit or rollback
2019-07-15 03:48:55 +03:00
fd66bdef0b codership/wsrep-lib#107 Replace exceptions with assertions
Replaced exceptions thrown on debug level sanity checks with
assertions to be more graceful with release builds.
2019-07-12 16:15:13 +03:00
eba8a8f35d Added version header, handle version in top level CMakeLists.txt
Added version header which contains definitions for major, minor
and patch version numbers, as well as for lowest and highest supported
wsrep-API versions. The library versioning follows Semantic Versioning.

Handle CMake policy CMP0048 in top level CMakeLists.txt.
2019-06-10 12:27:09 +03:00
503d4e7ab4 GCC 4.4 build for Travis 2019-06-07 14:16:40 +03:00
edcfcaf8a2 Write wsrep-lib log from unit tests into file
Write wsrep-lib logging facility output from unit tests into file.
The argument --wsrep-log-file can be controlled where the
log from wsrep-lib is written during unit tests. The default is
'wsrep-lib_test.log' in the working directory. In order to
get the log written into stdout, use empty value,
i.e. --wsrep-log-file=''.

Made travis test run a bit more verbose.
2019-06-06 18:38:10 +03:00
4285ff99ea codership/wsrep-lib#100 Support for assign_read_view() wsrep API call
Marshall the call from the `client_state` interface down to provider.
2019-05-08 15:07:45 +03:00
e9dafb7373 Provided methods to clone subset of transaction state for replay. 2019-04-03 18:51:27 +03:00
ae746fb289 fixing reviewer comments
- style fixes
- small improvement to avoid unnecessary search on close_orphaned_sr
2019-03-05 10:53:21 +01:00
5ef5becea6 removing previous_primary_view from public iface and style fixes 2019-03-05 10:34:30 +01:00
71f3fb2d01 close SR transacions on equal consecutive views
Fixes a bug where the fact that an SR master leaves the primary view
gets missed. When two consecutive primary views have the same
membership we now assume that every SR needs to be rolled back, as the
system may have been through a state of only non-primary components.
2019-03-05 09:41:48 +01:00
56f605c607 Added sync points before and after commit order leave 2019-02-28 14:27:35 +02:00
badf53a28d Return error code from high_priority_service::adopt_transaction()
Adopt transaction may need to start a new transaction on DBMS side,
allow returning an error if the transaction start fails.
2019-02-25 12:37:58 +02:00
c61811ed70 codership/wsrep-lib#90 Fixed assertion in before_commit()
Added unit test which makes assertion to fail if the fix is not
present.
2019-02-24 12:05:58 +02:00
9bec7d940c More graceful error handling in abort_or_interrupt()
If abort_or_interrupt() is called in aborting or aborted state,
investigate if the transaction was BF aborted. If yes, raise the
deadlock error if error has not been set yet and assert in debug build.
2019-02-20 09:54:15 +02:00
d52f43c049 Review fix: changed prev_state to state_at_enter
Changed prev_state variable name to state_at_enter in transaction
bf_abort(), and use only that variable to determine transaction
state in the rest of the method.
2019-02-19 23:03:03 +02:00
49deb7da98 Refactored checks for transaction state before certification
Moved the check for transaction state before certification step
into separate method abort_or_interrupted() which will check the state
and adjust state and client_state error status accordingly.

Moved the check for abort_or_interrupted() to happen before
the state is changed to certifying and write set data is appended.
This makes the check atomic and reduces the probability of race
conditions. After this check we rely on provider side transaction
state management and error reporting until the certification step
is over.

Change to public API: Pass client_state mutex wrappend in unique_lock
object to client_service::interrupted() call. This way the DBMS side
has a control to the lock object in case it needs to unlock it
temporarily. The underlying mutex will always be locked when the lock
object is passed via interrupted() call.

Other: Allow server_state change from donor to connected. This may
happen if the joiner crashes during SST and the provider reports
it before the DBMS side SST mechanism detects the error.
2019-02-19 22:26:45 +02:00
ab0e5f5d77 Fixed streaming transaction BF abort
The streaming_rollback() was not called from transaction::bf_abort()
if a streaming transaction was BF aborted in executing state. This
was because the condition to enter streaming_rollback() checked
if the transaction state is executing. However, the transaction
state had already been changed to must_abort before.

As a fix, save the state to local variable when entering
bf_abort() and check against saved state in condition to enter
streaming_rollback().

Added unit test for the correct behavior in the case when streaming
transaction is BF aborted in executing state.

Silenced warning about failing to replicate rollback fragment.
This is pretty normal condition and may happen during shutdown/
configuration changes when SR transactions are rolled back.
2019-02-19 15:11:25 +02:00
0b09871ad5 Reset client state gtid state in client_state::open()
If the application uses caching for client sessions, the
client_state object may be reused. This will cause the opened
client session to have unexpected value for sync_wait_gtid and
last_written_gtid.

In order to work around the problem, reset sync_wait_gtid and
last_written_gtid in client_state::open().
2019-02-18 15:57:16 +02:00
92024c7d50 codership/wsrep-lib#83 Release lock before commit_order_enter()
A high priority transaction T2 which calls commit_order_enter() with
client_state mutex locked may cause a deadlock if an another high
priority transaction T1 ordered before tries to access the transaction
T2 state.

As a fix, make sure that commit_order_enter() is never called with
client_state mutex locked.
2019-02-18 09:02:33 +02:00
8c2daa7e3d Handle BF abort during fragment removal
Fragment removal for SR transaction is done in transaction context
to make it atomic. However, this means that if the BF abort arrives
during fragment removal, the transaction may be rolled back inside
client_service::remove_fragments(), and client_state::after_prepare()
is left in aborted state. This case was not handled in the
post condition checks of after_prepare().

Fixed assertion in after_prepare() and implemented unit test.
2019-02-15 12:09:49 +02:00
9c387ef82f Count fragments certified for a statement.
The counter counts fragments which were succesfully certified since
the object construction or last after_statement() call.
2019-02-15 09:50:37 +02:00
af8383daf0 C++11 checks in CMakeLists.txt, added atomic.hpp
Check if the superproject has already enabled C++11 before enabling
it in CMakeLists.txt.

Added utility file atomic.hpp to select the correct atomics header
to work around issues with ancient GCC 4.4.
2019-02-13 13:05:45 +02:00
be98517cb3 Debug log level implementation
Debug log will now filter output based on debug level that is enabled.
2019-02-13 13:05:45 +02:00
510c7f767f Deal with backwards compatibility in sst_received()
Earlier versions of cluster software may not support storing
the view info into stable storage. In order to work around this
during rolling upgrade, skip sanity checks for recovered view
if the view state_id ID is undefined.
2019-02-13 08:54:10 +02:00
20b52ff1dd Allow direct manipulation of streaming context parameters.
Added a method to change streaming context fragment unit and
size. The method has a side effect of resetting unit counter.
2019-02-11 16:50:08 +02:00
4eb6074e67 codership/wsrep-lib#71 to make output cleaner with additional space 2019-02-08 14:04:04 +04:00
ad5d8ea066 Fixed typo for issue #68 2019-02-07 12:29:39 +02:00
e7d72ae7f6 codership/mariadb-wsrep#27 Galera cache encryption
* Created interface class for encryption support
* Implemented function for setting enc key to provider, callback function for encryption/decryption
2019-02-01 16:57:34 +01:00
e7f2dfdf93 Added .gitignore 2019-01-28 09:52:05 +02:00
1340442800 Helper script to run dbsim stress test with provider loaded 2019-01-25 14:50:44 +02:00
9a32c72b48 Fixed dbsim replaying to conform current implementation
Inherited db::replayer_service from db::high_priority_service
and overrode after_apply() and is_replaying() methods to match
current state of library implementation. Changed
db::client_service::replay() to use db::replayer_service instead
of db::high_priority_service().
2019-01-25 13:44:25 +02:00
fc5f59d27e Implemented dbsim high prio service log_dummy_write_set()
The empty implementation of log_dummy_write_set() in dbsim
high priority service implementation left unreleased commit
order critical section behind whenever remote write set failed
certification. Added calls to do empty commit to release the
critical section.

Other:

Implemented ostream operator<< for wsrep:🧵:id, and added
printout of owning thread into transaction debug output.
2019-01-25 12:18:46 +02:00
f30d9c06ce Enhanced dbsim to store view and position in storage engine
Mimic real DBMS implementation by storing view and position
into storage engine.
2019-01-25 12:18:46 +02:00
632f8c3b14 Fixed race condition in checking init_initialized on prim view
Flag init_initialized_ must be checked before changing the
state to s_initializing in on_primary_view() in order to avoid
race between main thread and applier thread. Otherwise it is
possible that main thread gains control after setting state
to initializing and changes the flag init_initialized_ to true
before the check is done in on_primary_view().
2019-01-25 12:18:46 +02:00
136767ae04 Added WSREP_LIB_STRICT_BUILD_FLAGS and WSREP_LIB_MAINTAINER_MODE to README.md 2019-01-24 18:15:13 +02:00
2e4cebb9e9 Added WSREP_LIB_MAINTAINER_MODE cmake option
In order to avoid excessive build failures because of compiler
warnings, added WSREP_LIB_MAINTAINER_MODE cmake option which
must be enabled explicity in order to enable -Werror build flag.
2019-01-24 17:57:23 +02:00
28e52c8412 Added runtime_error overload with const char* argument
Needed to add new overload to get code compiled with
AppleClang 10.0.
2019-01-23 11:41:34 +02:00
e61be45205 Added osx/xcode10.1 builds into build matrix 2019-01-23 11:41:18 +02:00
8e4777114b Update wsrep-API v26 to include enc signature fixes 2019-01-21 18:50:28 +02:00
6e2c70c226 codership/wsrep-lib#54 Fixed race in server disconnect
Convert streaming client to applier only if the server is not
in disconnected state. In disconnected state the appliers map
is supposed to be empty and will be reconstructed from fragment
storage when the server is connected back to cluster.
2019-01-21 17:00:08 +02:00
a6b38d2428 codership/wsrep-lib#54 Service call to recover streaming appliers
Introduced server_service recover_streaming_appliers() interface
call which will be called in total order whenever streaming appliers
must be recovered. The call comes with two overloads, one which
can be called from client context (e.g. after SST has been received)
and the other from high priority context (e.g. view event handling).

The client context overload should be eventually be deprecated once
there is a mechanism to make provider signal that it has joined to
the cluster and will start applying events.
2019-01-21 17:00:08 +02:00
144d8c13c1 Relaxed server_state state transition sanity checks
In release build log a warning but continue with state transition
anyway. In debug build log warning and crash in assert.
2019-01-21 14:13:25 +02:00
76875c3be1 Allowed transition s_joined to s_donor 2019-01-21 14:13:25 +02:00
47263df442 Revert "codership/mariadb-wsrep#27 Galera cache encryption"
This reverts commit 7e9419e811.
2019-01-21 14:12:28 +02:00
476bcdb41e Revert "codership/mariadb-wsrep#27 Galera cache encryption fixup"
This reverts commit 043e8bc2ea.
2019-01-21 14:12:10 +02:00
043e8bc2ea codership/mariadb-wsrep#27 Galera cache encryption fixup
Fixup to enable/disable encryption on provider loading
2019-01-20 15:20:52 +02:00