File tree Expand file tree Collapse file tree 4 files changed +17
-1
lines changed Expand file tree Collapse file tree 4 files changed +17
-1
lines changed Original file line number Diff line number Diff line change 1- 576c1b6898e3f5d9a8c54e6df7f802575532aac3
1+ 9184024c04c9a6f9cc079ebaea346ac89bc37aac
Original file line number Diff line number Diff line change @@ -834,6 +834,8 @@ class TTransaction::TImpl : public std::enable_shared_from_this<TImpl> {
834834 }
835835
836836 void AddPrecommitCallback (TPrecommitTransactionCallback cb) {
837+ std::lock_guard lock (PrecommitCallbacksMutex);
838+
837839 if (!ChangesAreAccepted) {
838840 ythrow TContractViolation (" Changes are no longer accepted" );
839841 }
@@ -842,6 +844,8 @@ class TTransaction::TImpl : public std::enable_shared_from_this<TImpl> {
842844 }
843845
844846 void AddOnFailureCallback (TOnFailureTransactionCallback cb) {
847+ std::lock_guard lock (OnFailureCallbacksMutex);
848+
845849 if (!ChangesAreAccepted) {
846850 ythrow TContractViolation (" Changes are no longer accepted" );
847851 }
@@ -856,6 +860,9 @@ class TTransaction::TImpl : public std::enable_shared_from_this<TImpl> {
856860 bool ChangesAreAccepted = true ; // haven't called Commit or Rollback yet
857861 std::vector<TPrecommitTransactionCallback> PrecommitCallbacks;
858862 std::vector<TOnFailureTransactionCallback> OnFailureCallbacks;
863+
864+ std::mutex PrecommitCallbacksMutex;
865+ std::mutex OnFailureCallbacksMutex;
859866};
860867
861868TTransaction::TTransaction (const TSession& session, const std::string& txId)
Original file line number Diff line number Diff line change @@ -92,6 +92,8 @@ TAsyncStatus TTransaction::TImpl::Rollback(const TRollbackTxSettings& settings)
9292
9393void TTransaction::TImpl::AddPrecommitCallback (TPrecommitTransactionCallback cb)
9494{
95+ std::lock_guard lock (PrecommitCallbacksMutex);
96+
9597 if (!ChangesAreAccepted) {
9698 ythrow TContractViolation (" Changes are no longer accepted" );
9799 }
@@ -101,6 +103,8 @@ void TTransaction::TImpl::AddPrecommitCallback(TPrecommitTransactionCallback cb)
101103
102104void TTransaction::TImpl::AddOnFailureCallback (TOnFailureTransactionCallback cb)
103105{
106+ std::lock_guard lock (OnFailureCallbacksMutex);
107+
104108 if (!ChangesAreAccepted) {
105109 ythrow TContractViolation (" Changes are no longer accepted" );
106110 }
Original file line number Diff line number Diff line change 22
33#include < ydb-cpp-sdk/client/table/table.h>
44
5+ #include < mutex>
6+
57namespace NYdb ::inline V3::NTable {
68
79class TTransaction ::TImpl : public std::enable_shared_from_this<TImpl> {
@@ -40,6 +42,9 @@ class TTransaction::TImpl : public std::enable_shared_from_this<TImpl> {
4042 bool ChangesAreAccepted = true ; // haven't called Commit or Rollback yet
4143 mutable std::vector<TPrecommitTransactionCallback> PrecommitCallbacks;
4244 mutable std::vector<TOnFailureTransactionCallback> OnFailureCallbacks;
45+
46+ std::mutex PrecommitCallbacksMutex;
47+ std::mutex OnFailureCallbacksMutex;
4348};
4449
4550}
You can’t perform that action at this time.
0 commit comments