1
0
mirror of https://github.com/codership/wsrep-lib.git synced 2025-04-19 21:02:17 +03:00

181 Commits

Author SHA1 Message Date
Leandro Pacheco
a9987aa970 s_prepared state for XA transactions
After the XA PREPARE, the XA transactions stay s_prepared until
commit/rollback
2019-10-16 10:15:55 +02:00
Leandro Pacheco
b73df49cff basic XA unit tests 2019-10-16 10:15:55 +02:00
Daniele Sciascia
b614822f08 Fixup to previous commit
Fix client_service in test mock and dbsim to update signature of
method prepare_fragment_for_replication().
2019-10-16 10:15:55 +02:00
Leandro Pacheco
36346beab4 Fixes for XA transactions with streaming enabled
Changes mostly related to handling of XA PREPARE fragments
2019-10-16 10:15:55 +02:00
Daniele Sciascia
54b0eeee45 Add is_query() and is_xa() to dbsim/test client service implementations 2019-10-16 10:15:55 +02:00
Teemu Ollakka
eb4cf86c1e Implemented thread service support.
Added a wsrep::thread_service interface to allow application to
inject instrumented thread, mutex and condition variable implementation
for provider.

The interface is defined in include/wsrep/thread_service.hpp.
Sample implementation is provided in dbsim/db_threads.[h|c]pp.

This patch will also clean up some remaining dependencies to
wsrep-API compilation units so that the dependency to wsrep-API
is header only. This will extending the provider support to
later wsrep-API versions.
2019-10-14 09:30:15 +03:00
Teemu Ollakka
477a71dd46 Updated wsrep-API, added -Wconversion to compiler flags, fixed errors. 2019-10-11 09:56:07 +03:00
Teemu Ollakka
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
Alexey Yurchenko
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
Teemu Ollakka
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
Alexey Yurchenko
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
Leandro Pacheco
ae746fb289 fixing reviewer comments
- style fixes
- small improvement to avoid unnecessary search on close_orphaned_sr
2019-03-05 10:53:21 +01:00
Leandro Pacheco
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
Teemu Ollakka
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
Teemu Ollakka
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
Teemu Ollakka
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
Teemu Ollakka
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
Teemu Ollakka
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
mkaruza
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
Teemu Ollakka
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
Teemu Ollakka
47263df442 Revert "codership/mariadb-wsrep#27 Galera cache encryption"
This reverts commit 7e9419e8111c3ca37d5e484282fe11a690eb2c6a.
2019-01-21 14:12:28 +02:00
mkaruza
7e9419e811 codership/mariadb-wsrep#27 Galera cache encryption
* Implemented encryption callback and enc_set_key
* Added pure virtual functions for encryption functionality
* Set enc key if provider was not loaded on time
2019-01-19 23:58:20 +01:00
Teemu Ollakka
ae734a33f8 Fixed compilation errors picked up by travis clang builds 2019-01-19 18:08:49 +02:00
Teemu Ollakka
55f6c63328 codership/wsrep-lib#52 Removed client_service do_2pc() 2019-01-16 19:33:32 +02:00
Teemu Ollakka
89b3561ad8 Read recovered position from sst_received() after initialization
In general the position where the storage recovers after a SST
cannot be known untile the recovery process is over. This in turn
means that the position cannot be known when the server_state
sst_received() method is called. Worked around the problem by
introducing get_position() method into server service which
can be used to get the position from stable storage after SST
has completed and the state has been recovered.
2019-01-15 12:35:06 +02:00
Teemu Ollakka
fccdad6ee9 Changed certification to happen in before_prepare()
Certification for commit fragments was changed to happen in
before_prepare in order to make GTID available for storage
engines in prepare phase.

Removed unused file src/wsrep-lib_test.cpp
2019-01-11 18:30:30 +02:00
Daniele Sciascia
4ac15e4349 Fix attempt to replicate empty fragments
* Adds method wsrep::transaction::streaming_step() so that there is a
  single place where streaming context unit counter is udpated.
  The method also checks that some data has been generated before
  attempting fragment replication.
* Emit a warning if there is an attempt to replicate a fragment and
  there is no data to replicate.
2019-01-07 16:33:32 +01:00
Teemu Ollakka
0441746368 codership/wsrep-lib#44 Provider name, version and vendor getters
Added methods to get provider name, version and vendor strings
into wsrep::provider interface. Implementations for v26 and mock
providers.
2019-01-02 12:11:26 +02:00
Teemu Ollakka
ba02e7525b codership/wsrep-lib#34 Unit tests for initialization errors
Unit test for server initialization state errors.
2018-12-20 19:35:31 +02:00
Teemu Ollakka
ac5a4cde0d codership/wsrep-lib#34 Fixed init first IST processing
Init first join crashed in

  server: s1 unallowed state transition: joined -> joined

This was due to missing state check for state in on_primary_view()
before changing to joined state. Added appropriate check.

Implemented unit tests for simple IST scenarios.
2018-12-20 19:35:31 +02:00
Teemu Ollakka
76335a3042 Added test case for desync-pause-resume-resync. 2018-12-20 19:35:31 +02:00
Teemu Ollakka
728eaa80b5 Added test cases for donor transitions.
Replaced all references to provider_ in server_state methods to
provider() call which is virtual and can be overridden by test classes.
Provider pointer may not be initialized during unit tests yet.
2018-12-20 19:35:31 +02:00
Teemu Ollakka
e5e5d409ed Test case for init first succesfull SST. 2018-12-20 19:35:31 +02:00
Teemu Ollakka
a4ea80e11a Added test cases for error/shutdown in joined and donor states. 2018-12-20 19:35:31 +02:00
Teemu Ollakka
7cd0656990 Allow server_state joiner - disconnecting transition.
Transition joiner - disconnecting may happen when the joiner failed
to receive SST succesfully. Because the system is at undefined state
at this point, skip most of the processing in sst_received()
and return control to caller after notifying the provider about
failure.
2018-12-20 19:35:31 +02:00
Teemu Ollakka
e81c66cd59 Fixed assertion on server_state connected - disconnecting transition
Transition from server_state connected state to disconnecting must
be allowed to deal with errors during server startup.

Added SST first test cases for server_state transitions:
* Successful join via SST
* Error in connect state
* Error in joiner state
2018-12-20 19:35:31 +02:00
Teemu Ollakka
1776537765 codership/wsrep-lib#34 Handle sync-disconnected-sync for init first
Handle init first case where state is cycled from synced to
disconnected and back synced without SST.
2018-12-20 19:35:31 +02:00
Teemu Ollakka
76424ad515 codership/wsrep-lib#34 Unit test for sync-disconnect-sync
Added unit test for sync-disconnect-sync transition without SST.
2018-12-20 19:35:31 +02:00
Teemu Ollakka
bf83907f38 codership/wsrep-lib#34 Moved cluster_id, bootstrap_view into base fixture
Made cluster_id, bootstrap_view members of server_fixture_base and
initialize them in serveri_fixture_base constructor to reduce typing
in test cases.
2018-12-20 19:35:31 +02:00
Teemu Ollakka
36dbb37645 codership/wsrep-lib#35 Rewrote member_index() to use iterators
Use iterators for scanning members vector in order to avoid
issues with integer signedness and range checks. The vector is
usually rather small and not in hot codepath, so performance
is here not an issue.

Added unit test for member_index() method.
2018-12-15 13:46:42 +00:00
sjaakola
cfcf34e70f codership/wsrep-lib#23 before_command() wait for ongoing rollbacks leaks
Storing information that background rollbacker in ongoing in client state has_rollback_
This can be used for detecting if there is ongoing background rollback,
and client should keep waiting in before_command() entry to avoid conflicts
in accessing client state during background rollbacking.

transaction::bf_abort() is modified to set has_rollback_ flag when
backgroung rollbacking has been assigned for the client

sync_rollback_complete() method has been modified to reset the backround
rollbacker flag
2018-11-27 12:26:14 +02:00
Alexey Yurchenko
fb14883547 Recover current view from state after SST.
When member joins the group and needs to receive an SST it won't
receive the corresponding menbership view event because the SST
happens after the event and will already include the effects of
all events ordered before it. The view then must be recovered from
the received state.

Minor renames and cleanups.

References codership/wsrep-lib#18
2018-11-12 12:47:42 +02:00
Alexey Yurchenko
ea9971d54b - Initialize member cluster ID only on connection to cluster and forget
it on disconnect.
 - Don't rely on own index from the view because the view may come from
   another member (IST/SST), instead always determine own index from own ID.

Refs codership/wsrep-lib#13
2018-11-09 00:42:05 +02:00
Teemu Ollakka
d4efa598bb Added is_empty() method to transaction class
Method is_empty() can be determined if there have no been changes
to the transaction.
2018-10-26 11:48:59 +03:00
Teemu Ollakka
b322a3a45c Cleaned up obsolete methods 2018-10-24 19:15:52 +03:00
Daniele Sciascia
cf434f3da5 Fix make test
Fixed `make test` so that it runs unit tests.

codership/wsrep-lib#7
2018-10-19 12:13:10 +03:00
Teemu Ollakka
cb1ca4e66e Rollback and release streaming appliers in unit tests
Unit tests which cause streaming rollback leaked memory because
the streaming applier handle which was created for rollback
fragment handling was not released. Roll back a streaming transaction
and release applier handle appropriately in corresponding tests.
2018-10-17 12:51:01 +03:00
Teemu Ollakka
a9abb3a80a Extracted mock_server_service out of mock_server_state. 2018-10-17 12:07:41 +03:00
Teemu Ollakka
c0c977f9ab Added GPLv2 licence and copyright headers. 2018-10-15 15:14:22 +03:00
Teemu Ollakka
5e5906d598 Prefixed cmake WITH_ definitions with WSREP_LIB_ to avoid collisions
with superproject definitions.

Avoid using client_service::do_2pc() in before_commit() to
determine if 2pc is actually happening, will use transaction
states to deduce that. client_service::do_2pc() should be deprecated.

Fixed a compiler warning in db_high_priority_service.cpp.
2018-10-12 16:04:52 +03:00