Skip to content

Commit 5cc4e55

Browse files
committed
operation_preparer uses IClient methods instead of IRawClient to enable retries
commit_hash:067376925c20e9ab7e1bf25d91ebb5e17b692c51
1 parent a31d49a commit 5cc4e55

File tree

1 file changed

+8
-12
lines changed

1 file changed

+8
-12
lines changed

yt/cpp/mapreduce/client/operation_preparer.cpp

Lines changed: 8 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -210,22 +210,19 @@ TRichYPath TOperationPreparer::LockFile(const TRichYPath& path)
210210
{
211211
CheckValidity();
212212

213-
auto lockRequest = Client_->GetRawClient()->CreateRawBatchRequest();
214-
auto lockIdFuture = lockRequest->Lock(
213+
auto fileTx = Client_->AttachTransaction(
215214
FileTransaction_->GetId(),
216-
path.Path_,
217-
ELockMode::LM_SNAPSHOT,
218-
TLockOptions().Waitable(true));
215+
TAttachTransactionOptions()
216+
.AbortOnTermination(false)
217+
.AutoPingable(false));
219218

220-
lockRequest->ExecuteBatch();
219+
auto lock = fileTx->Lock(path.Path_, ELockMode::LM_SNAPSHOT);
221220

222-
auto nodeIdFuture = Client_->GetRawClient()->Get(
223-
FileTransaction_->GetId(),
224-
::TStringBuilder() << '#' << GetGuidAsString(lockIdFuture.GetValue()) << "/@node_id");
221+
auto nodeId = lock->GetLockedNodeId();
225222

226223
auto result = path;
227224
result.OriginalPath(path.Path_);
228-
result.Path("#" + nodeIdFuture.AsString());
225+
result.Path("#" + nodeId.AsGuidString());
229226

230227
YT_LOG_DEBUG("Locked file %v, new path is %v",
231228
*result.OriginalPath_,
@@ -380,8 +377,7 @@ const TVector<TRichYPath>& TJobPreparer::TEagerLockingFileCache::GetFiles() cons
380377

381378
void TJobPreparer::TEagerLockingFileCache::InsertFile(const TRichYPath& path)
382379
{
383-
LockedFiles_.emplace_back(
384-
OperationPreparer_.LockFile(path));
380+
LockedFiles_.emplace_back(OperationPreparer_.LockFile(path));
385381
}
386382

387383
////////////////////////////////////////////////////////////////////////////////

0 commit comments

Comments
 (0)