@@ -95,6 +95,9 @@ class TCreateLock: public TSubOperation {
95
95
THolder<TProposeResponse> Propose (const TString&, TOperationContext& context) override {
96
96
const auto & workingDir = Transaction.GetWorkingDir ();
97
97
const auto & op = Transaction.GetLockConfig ();
98
+ const auto lockTxId = Transaction.HasLockGuard () && Transaction.GetLockGuard ().HasOwnerTxId ()
99
+ ? TTxId (Transaction.GetLockGuard ().GetOwnerTxId ())
100
+ : OperationId.GetTxId ();
98
101
99
102
LOG_N (" TCreateLock Propose"
100
103
<< " : opId# " << OperationId
@@ -158,17 +161,19 @@ class TCreateLock: public TSubOperation {
158
161
const auto pathId = tablePath.Base ()->PathId ;
159
162
result->SetPathId (pathId.LocalPathId );
160
163
161
- if (tablePath.LockedBy () == OperationId.GetTxId ()) {
162
- result->SetError (NKikimrScheme::StatusAlreadyExists, TStringBuilder () << " path checks failed"
163
- << " , path already locked by this operation"
164
- << " , path: " << tablePath.PathString ());
165
- return result;
166
- }
167
-
168
- TString errStr;
169
- if (!context.SS ->CheckLocks (pathId, Transaction, errStr)) {
170
- result->SetError (NKikimrScheme::StatusMultipleModifications, errStr);
171
- return result;
164
+ if (auto lockedBy = tablePath.LockedBy (); lockedBy != InvalidTxId) {
165
+ if (lockedBy == lockTxId) {
166
+ result->SetError (NKikimrScheme::StatusAlreadyExists, TStringBuilder () << " path checks failed"
167
+ << " , path already locked by this operation"
168
+ << " , path: " << tablePath.PathString ());
169
+ return result;
170
+ } else {
171
+ result->SetError (NKikimrScheme::StatusMultipleModifications, TStringBuilder () << " path checks failed"
172
+ << " , path already locked by another operation"
173
+ << " , path: " << tablePath.PathString ()
174
+ << " , locked by: " << lockedBy);
175
+ return result;
176
+ }
172
177
}
173
178
174
179
auto guard = context.DbGuard ();
@@ -177,7 +182,7 @@ class TCreateLock: public TSubOperation {
177
182
context.MemChanges .GrabNewTxState (context.SS , OperationId);
178
183
179
184
context.DbChanges .PersistPath (pathId);
180
- context.DbChanges .PersistLongLock (pathId, OperationId. GetTxId () );
185
+ context.DbChanges .PersistLongLock (pathId, lockTxId );
181
186
context.DbChanges .PersistTxState (OperationId);
182
187
183
188
Y_ABORT_UNLESS (!context.SS ->FindTx (OperationId));
@@ -194,7 +199,7 @@ class TCreateLock: public TSubOperation {
194
199
context.OnComplete .Dependence (splitOpId.GetTxId (), OperationId.GetTxId ());
195
200
}
196
201
197
- context.SS ->LockedPaths [pathId] = OperationId. GetTxId () ;
202
+ context.SS ->LockedPaths [pathId] = lockTxId ;
198
203
context.SS ->TabletCounters ->Simple ()[COUNTER_LOCKS_COUNT].Add (1 );
199
204
200
205
context.OnComplete .ActivateTx (OperationId);
0 commit comments