[MXS-4289] Transaction starts on wrong server with autocommit=0 Created: 2022-09-12  Updated: 2022-09-15  Resolved: 2022-09-15

Status: Closed
Project: MariaDB MaxScale
Component/s: readwritesplit
Affects Version/s: 6.4.2, 22.08.2
Fix Version/s: 6.4.3, 22.08.2

Type: Bug Priority: Major
Reporter: markus makela Assignee: markus makela
Resolution: Fixed Votes: 0
Labels: None

Attachments: File maxscale.log    
Sprint: MXS-SPRINT-166

 Description   

If a transaction is started by a session command that ends up failing while autocommit is disabled, it is possible that the transaction ends up starting on the slave server. In debug builds the debug assertion mentioned later on would be hit. In release builds the session command could end up being executed twice before the transaction would be migrated to the correct server. This could result in a possible transaction replay failure if for some reason the result of the session command isn't idempotent. In practice this should manifest as a temporary slowdown and an unusually long replay failure.


The mxs3924_sescmd_retry test failed with a debug assertion in route_session_write:

debug assert at /home/timofey_turenko_mariadb_com/MaxScale/server/modules/routing/readwritesplit/rwsplit_route_stmt.cc:617 failed: Trx target is server4 when m_sescmd_replier is server1 while trx is open (!trx_is_open() || m_trx.target() == m_sescmd_replier)
alert  : MaxScale 22.08.2 received fatal signal 6. Commit ID: 2c23e5b843d03745ac4ce6a282fe0c837a569a53 System name: Linux Release string: Red Hat Enterprise Linux Server release 7.9 (Maipo)
 
 
2022-09-12 10:13:41   alert  : (4) MaxScale 22.08.2 received fatal signal 6. Commit ID: 2c23e5b843d03745ac4ce6a282fe0c837a569a53 System name: Linux Release string: Red Hat Enterprise Linux Server release 7.9 (Maipo)
2022-09-12 10:13:41   alert  : (4) Statement currently being classified: none/unknown
2022-09-12 10:13:41   alert  : (4) DCB: 0x7f5038019770 Session: 4 Service: RW-Split-Router
2022-09-12 10:13:41   notice : (4) For a more detailed stacktrace, install GDB and add 'debug=gdb-stacktrace' under the [maxscale] section.
  /lib64/libpthread.so.0(raise+0x2b): ??:?
  /usr/lib64/maxscale/libreadwritesplit.so(_ZN14RWSplitSession19route_session_writeEP5GWBUFhj+0xad8): server/modules/routing/readwritesplit/rwsplit_route_stmt.cc:617 (discriminator 18)
  /usr/lib64/maxscale/libreadwritesplit.so(_ZN14RWSplitSession20handle_target_is_allEON8maxscale6BufferERKNS_11RoutingPlanE+0xb8): server/modules/routing/readwritesplit/rwsplit_route_stmt.cc:157
  /usr/lib64/maxscale/libreadwritesplit.so(_ZN14RWSplitSession10route_stmtEON8maxscale6BufferERKNS_11RoutingPlanE+0x220): server/modules/routing/readwritesplit/rwsplit_route_stmt.cc:325
  /usr/lib64/maxscale/libreadwritesplit.so(_ZN14RWSplitSession11route_queryEON8maxscale6BufferE+0x1bc): server/modules/routing/readwritesplit/rwsplitsession.cc:132
  /usr/lib64/maxscale/libreadwritesplit.so(+0xc552c): server/modules/routing/readwritesplit/rwsplit_route_stmt.cc:76
  /usr/lib64/maxscale/libreadwritesplit.so(+0xca257): /opt/rh/devtoolset-9/root/usr/include/c++/9/bits/std_function.h:287
  /usr/lib64/maxscale/libmaxscale-common.so.1.0.0(_ZNKSt8functionIFbP5GWBUFEEclES1_+0x49): /opt/rh/devtoolset-9/root/usr/include/c++/9/bits/std_function.h:689
  /usr/lib64/maxscale/libmaxscale-common.so.1.0.0(+0x6ca3e3): server/core/session.cc:613
  /usr/lib64/maxscale/libmaxscale-common.so.1.0.0(+0x6d06b6): /opt/rh/devtoolset-9/root/usr/include/c++/9/bits/std_function.h:287
  /usr/lib64/maxscale/libmaxscale-common.so.1.0.0(_ZNKSt8functionIFbN7maxbase6Worker8Callable6ActionEEEclES3_+0x48): /opt/rh/devtoolset-9/root/usr/include/c++/9/bits/std_function.h:689
  /usr/lib64/maxscale/libmaxscale-common.so.1.0.0(_ZN7maxbase6Worker22DCallFunctorWithCancel7do_callENS0_8Callable6ActionE+0x24): maxutils/maxbase/include/maxbase/worker.hh:1089
  /usr/lib64/maxscale/libmaxscale-common.so.1.0.0(_ZN7maxbase6Worker5DCall4callENS0_8Callable6ActionE+0x2b): maxutils/maxbase/include/maxbase/worker.hh:928
  /usr/lib64/maxscale/libmaxscale-common.so.1.0.0(_ZN7maxbase6Worker4tickEv+0x2cf): maxutils/maxbase/src/worker.cc:1225
  /usr/lib64/maxscale/libmaxscale-common.so.1.0.0(_ZN7maxbase6Worker15DelegatingTimerIS0_E4tickEv+0x66): maxutils/maxbase/include/maxbase/worker.hh:469 (discriminator 4)
  /usr/lib64/maxscale/libmaxscale-common.so.1.0.0(_ZN7maxbase11WorkerTimer18handle_poll_eventsEPNS_6WorkerEjNS_8Pollable7ContextE+0x1b1): maxutils/maxbase/src/worker.cc:327
  /usr/lib64/maxscale/libmaxscale-common.so.1.0.0(_ZN7maxbase6Worker14deliver_eventsEmNSt6chrono10time_pointINS1_3_V212steady_clockENS1_8durationIlSt5ratioILl1ELl1000000000EEEEEEPNS_8PollableEjNSA_7ContextE+0x1b4): maxutils/maxbase/src/worker.cc:1041
  /usr/lib64/maxscale/libmaxscale-common.so.1.0.0(_ZN7maxbase6Worker15poll_waiteventsEv+0x647): maxutils/maxbase/src/worker.cc:1168
  /usr/lib64/maxscale/libmaxscale-common.so.1.0.0(_ZN7maxbase6Worker3runEPNS_9SemaphoreE+0x129): maxutils/maxbase/src/worker.cc:820
  /usr/lib64/maxscale/libmaxscale-common.so.1.0.0(_ZN7maxbase6Worker11thread_mainEPS0_PNS_9SemaphoreE+0x23): maxutils/maxbase/src/worker.cc:933
  /usr/lib64/maxscale/libmaxscale-common.so.1.0.0(_ZSt13__invoke_implIvPFvPN7maxbase6WorkerEPNS0_9SemaphoreEEJS2_S4_EET_St14__invoke_otherOT0_DpOT1_+0x4d): /opt/rh/devtoolset-9/root/usr/include/c++/9/bits/invoke.h:60
  /usr/lib64/maxscale/libmaxscale-common.so.1.0.0(_ZSt8__invokeIPFvPN7maxbase6WorkerEPNS0_9SemaphoreEEJS2_S4_EENSt15__invoke_resultIT_JDpT0_EE4typeEOS8_DpOS9_+0x4f): /opt/rh/devtoolset-9/root/usr/include/c++/9/bits/invoke.h:96
  /usr/lib64/maxscale/libmaxscale-common.so.1.0.0(_ZNSt6thread8_InvokerISt5tupleIJPFvPN7maxbase6WorkerEPNS2_9SemaphoreEES4_S6_EEE9_M_invokeIJLm0ELm1ELm2EEEEvSt12_Index_tupleIJXspT_EEE+0x5f): /opt/rh/devtoolset-9/root/usr/include/c++/9/thread:244
  /usr/lib64/maxscale/libmaxscale-common.so.1.0.0(_ZNSt6thread8_InvokerISt5tupleIJPFvPN7maxbase6WorkerEPNS2_9SemaphoreEES4_S6_EEEclEv+0x18): /opt/rh/devtoolset-9/root/usr/include/c++/9/thread:252
  /usr/lib64/maxscale/libmaxscale-common.so.1.0.0(_ZNSt6thread11_State_implINS_8_InvokerISt5tupleIJPFvPN7maxbase6WorkerEPNS3_9SemaphoreEES5_S7_EEEEE6_M_runEv+0x1c): /opt/rh/devtoolset-9/root/usr/include/c++/9/thread:195
  /usr/lib64/maxscale/libmaxscale-common.so.1.0.0(+0x85d6f0): thread48.o:?
  /lib64/libpthread.so.0(+0x7ea5): pthread_create.c:?

The complete log of the test case is attached.



 Comments   
Comment by markus makela [ 2022-09-15 ]

Session commands in transactions now correctly fail earlier if the master server is not available.

Generated at Thu Feb 08 04:27:34 UTC 2024 using Jira 8.20.16#820016-sha1:9d11dbea5f4be3d4cc21f03a88dd11d8c8687422.