File tree Expand file tree Collapse file tree 4 files changed +33
-10
lines changed Expand file tree Collapse file tree 4 files changed +33
-10
lines changed Original file line number Diff line number Diff line change @@ -936,11 +936,6 @@ TBatchRequestPtr TClientBase::CreateBatchRequest()
936
936
return MakeIntrusive<TBatchRequest>(TransactionId_, GetParentClientImpl ());
937
937
}
938
938
939
- IClientPtr TClientBase::GetParentClient ()
940
- {
941
- return GetParentClientImpl ();
942
- }
943
-
944
939
IRawClientPtr TClientBase::GetRawClient () const
945
940
{
946
941
return RawClient_;
@@ -1056,6 +1051,11 @@ ITransactionPingerPtr TTransaction::GetTransactionPinger()
1056
1051
return TransactionPinger_;
1057
1052
}
1058
1053
1054
+ IClientPtr TTransaction::GetParentClient (bool ignoreGlobalTx)
1055
+ {
1056
+ return GetParentClientImpl ()->GetParentClient (ignoreGlobalTx);
1057
+ }
1058
+
1059
1059
TClientPtr TTransaction::GetParentClientImpl ()
1060
1060
{
1061
1061
return ParentClient_;
@@ -1489,6 +1489,20 @@ TClientPtr TClient::GetParentClientImpl()
1489
1489
return this ;
1490
1490
}
1491
1491
1492
+ IClientPtr TClient::GetParentClient (bool ignoreGlobalTx)
1493
+ {
1494
+ if (!TransactionId_.IsEmpty () && ignoreGlobalTx) {
1495
+ return MakeIntrusive<TClient>(
1496
+ RawClient_,
1497
+ Context_,
1498
+ TTransactionId (),
1499
+ ClientRetryPolicy_
1500
+ );
1501
+ } else {
1502
+ return this ;
1503
+ }
1504
+ }
1505
+
1492
1506
void TClient::CheckShutdown () const
1493
1507
{
1494
1508
if (Shutdown_) {
Original file line number Diff line number Diff line change @@ -222,8 +222,6 @@ class TClientBase
222
222
223
223
TBatchRequestPtr CreateBatchRequest () override ;
224
224
225
- IClientPtr GetParentClient () override ;
226
-
227
225
IRawClientPtr GetRawClient () const ;
228
226
229
227
const TClientContext& GetContext () const ;
@@ -328,6 +326,8 @@ class TTransaction
328
326
329
327
ITransactionPingerPtr GetTransactionPinger () override ;
330
328
329
+ IClientPtr GetParentClient (bool ignoreGlobalTx) override ;
330
+
331
331
protected:
332
332
TClientPtr GetParentClientImpl () override ;
333
333
@@ -488,6 +488,8 @@ class TClient
488
488
489
489
ITransactionPingerPtr GetTransactionPinger () override ;
490
490
491
+ IClientPtr GetParentClient (bool ignoreGlobalTx) override ;
492
+
491
493
// Helper methods
492
494
TYtPoller& GetYtPoller ();
493
495
Original file line number Diff line number Diff line change @@ -165,8 +165,15 @@ class IClientBase
165
165
// / @see [YT doc](https://ytsaurus.tech/docs/en/api/commands.html#execute_batch)
166
166
virtual TBatchRequestPtr CreateBatchRequest () = 0;
167
167
168
- // / @brief Get root client outside of all transactions.
169
- virtual IClientPtr GetParentClient () = 0;
168
+ // /
169
+ // / @brief Get root client.
170
+ // /
171
+ // / @param ignoreGlobalTx root client could be created already attached to some global transaction, @ref NYT::TConfig::GlobalTx.
172
+ // / when ignoreGlobalTx = false original client (attached to GlobalTx) is returned
173
+ // / when ignoreGlobalTx = true, returned client is not attached to any transaction.
174
+ // /
175
+ // / TODO: rename to GetRootClient()
176
+ virtual IClientPtr GetParentClient (bool ignoreGlobalTx = false ) = 0;
170
177
};
171
178
172
179
// //////////////////////////////////////////////////////////////////////////////
Original file line number Diff line number Diff line change @@ -133,7 +133,7 @@ TYPath CreateTempTable(
133
133
// we retry attempt if it was failed with path resolution error.
134
134
const int maxAttempts = 3 ;
135
135
for (int i = 0 ; i < maxAttempts; ++i) {
136
- client->GetParentClient ()->Create (resultDirectory, NT_MAP, TCreateOptions ().Recursive (true ).IgnoreExisting (true ));
136
+ client->GetParentClient (/* ignoreGlobalTx= */ true )->Create (resultDirectory, NT_MAP, TCreateOptions ().Recursive (true ).IgnoreExisting (true ));
137
137
138
138
try {
139
139
client->Create (result, NT_TABLE, options);
You can’t perform that action at this time.
0 commit comments