|
1 | 1 | #include "kqp_read_actor.h"
|
2 | 2 |
|
| 3 | +#include <ydb/core/kqp/runtime/kqp_read_iterator_common.h> |
3 | 4 | #include <ydb/core/kqp/runtime/kqp_scan_data.h>
|
4 | 5 | #include <ydb/core/base/tablet_pipecache.h>
|
5 | 6 | #include <ydb/core/engine/minikql/minikql_engine_host.h>
|
@@ -28,73 +29,9 @@ bool IsDebugLogEnabled(const NActors::TActorSystem* actorSystem, NActors::NLog::
|
28 | 29 | return settings && settings->Satisfies(NActors::NLog::EPriority::PRI_DEBUG, component);
|
29 | 30 | }
|
30 | 31 |
|
31 |
| -struct TEvReadSettings : public TAtomicRefCount<TEvReadSettings> { |
32 |
| - NKikimrTxDataShard::TEvRead Read; |
33 |
| - NKikimrTxDataShard::TEvReadAck Ack; |
34 |
| - |
35 |
| - TEvReadSettings() { |
36 |
| - Read.SetMaxRows(32767); |
37 |
| - Read.SetMaxBytes(5_MB); |
38 |
| - |
39 |
| - Ack.SetMaxRows(32767); |
40 |
| - Ack.SetMaxBytes(5_MB); |
41 |
| - } |
42 |
| -}; |
43 |
| - |
44 |
| -struct TEvReadDefaultSettings { |
45 |
| - THotSwap<TEvReadSettings> Settings; |
46 |
| - |
47 |
| - TEvReadDefaultSettings() { |
48 |
| - Settings.AtomicStore(MakeIntrusive<TEvReadSettings>()); |
49 |
| - } |
50 |
| - |
51 |
| -} DefaultSettings; |
52 |
| - |
53 |
| -THolder<NKikimr::TEvDataShard::TEvRead> DefaultReadSettings() { |
54 |
| - auto result = MakeHolder<NKikimr::TEvDataShard::TEvRead>(); |
55 |
| - auto ptr = DefaultSettings.Settings.AtomicLoad(); |
56 |
| - result->Record.MergeFrom(ptr->Read); |
57 |
| - return result; |
58 |
| -} |
59 |
| - |
60 |
| -THolder<NKikimr::TEvDataShard::TEvReadAck> DefaultAckSettings() { |
61 |
| - auto result = MakeHolder<NKikimr::TEvDataShard::TEvReadAck>(); |
62 |
| - auto ptr = DefaultSettings.Settings.AtomicLoad(); |
63 |
| - result->Record.MergeFrom(ptr->Ack); |
64 |
| - return result; |
65 |
| -} |
66 |
| - |
67 | 32 | NActors::TActorId MainPipeCacheId = NKikimr::MakePipePeNodeCacheID(false);
|
68 | 33 | NActors::TActorId FollowersPipeCacheId = NKikimr::MakePipePeNodeCacheID(true);
|
69 | 34 |
|
70 |
| -struct TBackoffStorage { |
71 |
| - THotSwap<NKikimr::NKqp::TIteratorReadBackoffSettings> SettingsPtr; |
72 |
| - |
73 |
| - TBackoffStorage() { |
74 |
| - SettingsPtr.AtomicStore(new NKikimr::NKqp::TIteratorReadBackoffSettings()); |
75 |
| - } |
76 |
| -}; |
77 |
| - |
78 |
| -TDuration CalcDelay(size_t attempt, bool allowInstantRetry) { |
79 |
| - return Singleton<::TBackoffStorage>()->SettingsPtr.AtomicLoad()->CalcShardDelay(attempt, allowInstantRetry); |
80 |
| -} |
81 |
| - |
82 |
| -size_t MaxShardResolves() { |
83 |
| - return Singleton<::TBackoffStorage>()->SettingsPtr.AtomicLoad()->MaxShardResolves; |
84 |
| -} |
85 |
| - |
86 |
| -size_t MaxShardRetries() { |
87 |
| - return Singleton<::TBackoffStorage>()->SettingsPtr.AtomicLoad()->MaxShardAttempts; |
88 |
| -} |
89 |
| - |
90 |
| -TMaybe<size_t> MaxTotalRetries() { |
91 |
| - return Singleton<::TBackoffStorage>()->SettingsPtr.AtomicLoad()->MaxTotalRetries; |
92 |
| -} |
93 |
| - |
94 |
| -TMaybe<TDuration> ShardTimeout() { |
95 |
| - return Singleton<::TBackoffStorage>()->SettingsPtr.AtomicLoad()->ReadResponseTimeout; |
96 |
| -} |
97 |
| - |
98 | 35 | }
|
99 | 36 |
|
100 | 37 |
|
@@ -540,7 +477,7 @@ class TKqpReadActor : public TActorBootstrapped<TKqpReadActor>, public NYql::NDq
|
540 | 477 | }
|
541 | 478 |
|
542 | 479 | void ResolveShard(TShardState* state) {
|
543 |
| - if (state->ResolveAttempt >= ::MaxShardResolves()) { |
| 480 | + if (state->ResolveAttempt >= MaxShardResolves()) { |
544 | 481 | RuntimeError(TStringBuilder() << "Table '" << Settings->GetTable().GetTablePath() << "' resolve limit exceeded",
|
545 | 482 | NDqProto::StatusIds::UNAVAILABLE);
|
546 | 483 | return;
|
@@ -792,19 +729,19 @@ class TKqpReadActor : public TActorBootstrapped<TKqpReadActor>, public NYql::NDq
|
792 | 729 | auto state = Reads[id].Shard;
|
793 | 730 |
|
794 | 731 | TotalRetries += 1;
|
795 |
| - auto limit = ::MaxTotalRetries(); |
| 732 | + auto limit = MaxTotalRetries(); |
796 | 733 | if (limit && TotalRetries > *limit) {
|
797 | 734 | return RuntimeError(TStringBuilder() << "Table '" << Settings->GetTable().GetTablePath() << "' retry limit exceeded",
|
798 | 735 | NDqProto::StatusIds::UNAVAILABLE);
|
799 | 736 | }
|
800 | 737 |
|
801 | 738 | state->RetryAttempt += 1;
|
802 |
| - if (state->RetryAttempt > ::MaxShardRetries()) { |
| 739 | + if (state->RetryAttempt > MaxShardRetries()) { |
803 | 740 | ResetRead(id);
|
804 | 741 | return ResolveShard(state);
|
805 | 742 | }
|
806 | 743 |
|
807 |
| - auto delay = ::CalcDelay(state->RetryAttempt, allowInstantRetry); |
| 744 | + auto delay = CalcDelay(state->RetryAttempt, allowInstantRetry); |
808 | 745 | if (delay == TDuration::Zero()) {
|
809 | 746 | return DoRetryRead(id);
|
810 | 747 | }
|
@@ -848,7 +785,7 @@ class TKqpReadActor : public TActorBootstrapped<TKqpReadActor>, public NYql::NDq
|
848 | 785 | }
|
849 | 786 | }
|
850 | 787 |
|
851 |
| - auto ev = ::DefaultReadSettings(); |
| 788 | + auto ev = GetDefaultReadSettings(); |
852 | 789 | auto& record = ev->Record;
|
853 | 790 |
|
854 | 791 | state->FillEvRead(*ev, KeyColumnTypes, Settings->GetReverse());
|
@@ -1307,7 +1244,7 @@ class TKqpReadActor : public TActorBootstrapped<TKqpReadActor>, public NYql::NDq
|
1307 | 1244 | }
|
1308 | 1245 |
|
1309 | 1246 | if (!limit || *limit > 0) {
|
1310 |
| - auto request = ::DefaultAckSettings(); |
| 1247 | + auto request = GetDefaultReadAckSettings(); |
1311 | 1248 | request->Record.SetReadId(record.GetReadId());
|
1312 | 1249 | request->Record.SetSeqNo(record.GetSeqNo());
|
1313 | 1250 | request->Record.SetMaxBytes(Min<ui64>(request->Record.GetMaxBytes(), BufSize));
|
@@ -1538,40 +1475,9 @@ void RegisterKqpReadActor(NYql::NDq::TDqAsyncIoFactory& factory, TIntrusivePtr<T
|
1538 | 1475 | });
|
1539 | 1476 | }
|
1540 | 1477 |
|
1541 |
| -void InjectRangeEvReadSettings(const NKikimrTxDataShard::TEvRead& read) { |
1542 |
| - auto ptr = ::DefaultSettings.Settings.AtomicLoad(); |
1543 |
| - TEvReadSettings settings = *ptr; |
1544 |
| - settings.Read.MergeFrom(read); |
1545 |
| - ::DefaultSettings.Settings.AtomicStore(MakeIntrusive<TEvReadSettings>(settings)); |
1546 |
| -} |
1547 |
| - |
1548 |
| -void InjectRangeEvReadAckSettings(const NKikimrTxDataShard::TEvReadAck& ack) { |
1549 |
| - auto ptr = ::DefaultSettings.Settings.AtomicLoad(); |
1550 |
| - TEvReadSettings settings = *ptr; |
1551 |
| - settings.Ack.MergeFrom(ack); |
1552 |
| - ::DefaultSettings.Settings.AtomicStore(MakeIntrusive<TEvReadSettings>(settings)); |
1553 |
| -} |
1554 |
| - |
1555 |
| -void SetDefaultIteratorQuotaSettings(ui32 rows, ui32 bytes) { |
1556 |
| - auto ptr = ::DefaultSettings.Settings.AtomicLoad(); |
1557 |
| - TEvReadSettings settings = *ptr; |
1558 |
| - |
1559 |
| - settings.Read.SetMaxRows(rows); |
1560 |
| - settings.Ack.SetMaxRows(rows); |
1561 |
| - |
1562 |
| - settings.Read.SetMaxBytes(bytes); |
1563 |
| - settings.Ack.SetMaxBytes(bytes); |
1564 |
| - |
1565 |
| - ::DefaultSettings.Settings.AtomicStore(MakeIntrusive<TEvReadSettings>(settings)); |
1566 |
| -} |
1567 |
| - |
1568 | 1478 | void InterceptReadActorPipeCache(NActors::TActorId id) {
|
1569 | 1479 | ::MainPipeCacheId = id;
|
1570 | 1480 | }
|
1571 | 1481 |
|
1572 |
| -void SetReadIteratorBackoffSettings(TIntrusivePtr<TIteratorReadBackoffSettings> ptr) { |
1573 |
| - Singleton<::TBackoffStorage>()->SettingsPtr.AtomicStore(ptr); |
1574 |
| -} |
1575 |
| - |
1576 | 1482 | } // namespace NKqp
|
1577 | 1483 | } // namespace NKikimr
|
0 commit comments