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

476 Commits

Author SHA1 Message Date
Teemu Ollakka
9b25cebdf1 codership/wsrep-lib#117 Fixed empty vector access.
Access to empty vector by using operator[] may cause stdlib++
assertions to fail. Replaced the vector data access to use data()
method which is valid operation even if the vector is empty.

Added unit test to reproduce assertion with empty mutable_buffer access.

Added -D_GLIBCXX_ASSERTIONS preprocessor option to debug builds
to catch standard library misuse.

Added gcc 8 and gcc9 into travis build matrix.
2019-12-05 14:27:35 +02:00
Teemu Ollakka
c9513bd2e4 Fixed compilation errors with GCC 4.7
- Do not use [[noreturn]] with GCC older than 4.8.
- Use if/else instead of ternary operator in transaction
  commit_or_rollback_by_xid() to avoid debug build failure with
  GCC 4.7.
2019-10-28 17:22:09 +02:00
Teemu Ollakka
5ca8e4780e Added GCC 4.7 to travis build matrix. 2019-10-28 17:22:00 +02:00
Daniele Sciascia
66ee7bed1b Add type wsrep::xid
Create type `wsrep::xid`, and change all signatures that take
`std::string xid` to take `wsrep::xid xid`.
2019-10-18 09:36:18 +02:00
Daniele Sciascia
682d1b2034 Split commit_or_rollback_by_xid() in two methods
Split `client_state::commit_or_rollback_by_xid()` into
`client_state::commit_by_xid()` and `client_state::rollback_by_xid()`.
2019-10-16 11:42:44 +02:00
Daniele Sciascia
725f148ddb Remove query() method from wsrep::client_service interface 2019-10-16 10:16:39 +02:00
Daniele Sciascia
5d18ce3e75 Minimize client_service interface for XA
Remove methods `is_xa()`, `is_xa_prepare()`, and `xid()` from
client_service interface. Instead, transactions are explicitly
assigned their xid, through at start of XA.
2019-10-16 10:16:39 +02:00
Daniele Sciascia
052247144f Support recovery of XA transactions
* Add method `restore_prepared_transaction` to `client_state` class
  which restores a transaction state from storage given its xid.
* Add method `commit_or_rollback_by_xid` to terminate prepared XA
  transactions by xid.
* Make sure that transactions in prepared state are not rolled back
  when their master fails/partitions away.
2019-10-16 10:16:39 +02:00
Leandro Pacheco
98af85498b removing bytes_certified 2019-10-16 10:16:39 +02:00
Leandro Pacheco
d9ada0226f use log_position when calculating bytes_to_replicate
`bytes_certified` includes XA events which are not written to the
binlog. Thus, we need to use `log_position` instead.
2019-10-16 10:16:39 +02:00
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
e02f617d5f Document log_position param in client_service::prepare_data_for_replication() 2019-10-16 10:15:55 +02:00
Daniele Sciascia
68adbe35f6 Fixup unused parameter position in prepare_fragment_for_replication() 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
Daniele Sciascia
f80f97db2f Record database log_postion for streaming
Class streaming_context can now keep track of database specific log
position for streaming. Previously, it  was assumed that the log
position was based of off the buffer size which was filled in
client_service::prepare_fragment_for_replication(). However, for XA
the buffer may contain data that is not in the log. Therefore,
subsequent calls to prepare_fragment_for_replication() could not find
the appropriate log_position based on the certified_bytes(), which
would returns the total number of bytes return in the buffers that
were certified.
2019-10-16 10:15:55 +02:00
Daniele Sciascia
24cd49b23f Improved logging output of ws_meta 2019-10-16 10:15:55 +02:00
Leandro Pacheco
e0118c1378 removing assertion about current thread in next_fragment
next_fragment is called outside the scope of a high_priority_switch,
and we may be in a different thread context then the streaming applier
was created in
2019-10-16 10:15:55 +02:00
Leandro Pacheco
3389074e24 comments and style fixes 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
Daniele Sciascia
9c9323e2a5 Initial support for XA
Force fragment replication when XA transaction is prepared, with
prepare fragment. Commit fragment happens in before_commit().
Adjusted fragment removal, which cannot happen in atomically with the
executing transaction.
2019-10-16 10:15:55 +02:00
Teemu Ollakka
5c27d6dafa Removed unneeded provider version probe. 2019-10-15 11:47:35 +03:00
Teemu Ollakka
54ad9d94f5 Use v26 provider implementation by default if dummy provider is
loaded.
2019-10-14 15:52:24 +03:00
Teemu Ollakka
613b55a007 Fixes to make code backwards compatible. 2019-10-14 09:58:20 +03: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
58aa3e821f Updated travis definitions
- Xenial is now default build environment
- Use Trusty for older compilers
2019-08-29 15:58:38 +03:00
Teemu Ollakka
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
Leandro Pacheco
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
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
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
Teemu Ollakka
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
Teemu Ollakka
503d4e7ab4 GCC 4.4 build for Travis 2019-06-07 14:16:40 +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
Teemu Ollakka
e9dafb7373 Provided methods to clone subset of transaction state for replay. 2019-04-03 18:51:27 +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
5ef5becea6 removing previous_primary_view from public iface and style fixes 2019-03-05 10:34:30 +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
56f605c607 Added sync points before and after commit order leave 2019-02-28 14:27:35 +02: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
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
Teemu Ollakka
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
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
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
Teemu Ollakka
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