|
5 | 5 | #include <library/cpp/string_utils/base64/base64.h>
|
6 | 6 |
|
7 | 7 | #include <ydb/core/data_integrity_trails/data_integrity_trails.h>
|
| 8 | +#include <ydb/core/tx/data_events/events.h> |
| 9 | +#include <ydb/core/tx/datashard/datashard.h> |
8 | 10 |
|
9 | 11 | namespace NKikimr {
|
10 | 12 | namespace NDataIntegrity {
|
@@ -96,23 +98,110 @@ inline void LogIntegrityTrails(const TString& traceId, NKikimrKqp::EQueryAction
|
96 | 98 | }
|
97 | 99 |
|
98 | 100 | // DataExecuter
|
99 |
| -inline void LogIntegrityTrails(const TString& txType, const TString& traceId, ui64 txId, TMaybe<ui64> shardId, const TActorContext& ctx) { |
100 |
| - auto log = [](const auto& type, const auto& traceId, const auto& txId, const auto& shardId) { |
| 101 | +inline void LogIntegrityTrails(const TString& txType, const TString& txLocksDebugStr, const TString& traceId, ui64 txId, TMaybe<ui64> shardId, const TActorContext& ctx) { |
| 102 | + auto log = [](const auto& type, const auto& txLocksDebugStr, const auto& traceId, const auto& txId, const auto& shardId) { |
101 | 103 | TStringStream ss;
|
102 | 104 | LogKeyValue("Component", "Executer", ss);
|
| 105 | + LogKeyValue("Type", "Request", ss); |
103 | 106 | LogKeyValue("TraceId", traceId, ss);
|
104 | 107 | LogKeyValue("PhyTxId", ToString(txId), ss);
|
| 108 | + LogKeyValue("Locks", "[" + txLocksDebugStr + "]", ss); |
105 | 109 |
|
106 | 110 | if (shardId) {
|
107 | 111 | LogKeyValue("ShardId", ToString(*shardId), ss);
|
108 | 112 | }
|
109 | 113 |
|
110 |
| - LogKeyValue("Type", type, ss, /*last*/ true); |
| 114 | + LogKeyValue("TxType", type, ss, /*last*/ true); |
| 115 | + |
| 116 | + return ss.Str(); |
| 117 | + }; |
| 118 | + |
| 119 | + LOG_INFO_S(ctx, NKikimrServices::DATA_INTEGRITY, log(txType, txLocksDebugStr, traceId, txId, shardId)); |
| 120 | +} |
| 121 | + |
| 122 | +inline void LogIntegrityTrails(const TString& state, const TString& traceId, const NEvents::TDataEvents::TEvWriteResult::TPtr& ev, const TActorContext& ctx) { |
| 123 | + auto log = [](const auto& state, const auto& traceId, const auto& ev) { |
| 124 | + const auto& record = ev->Get()->Record; |
| 125 | + |
| 126 | + TStringStream ss; |
| 127 | + LogKeyValue("Component", "Executer", ss); |
| 128 | + LogKeyValue("Type", "Response", ss); |
| 129 | + LogKeyValue("State", state, ss); |
| 130 | + LogKeyValue("TraceId", traceId, ss); |
| 131 | + LogKeyValue("PhyTxId", ToString(record.GetTxId()), ss); |
| 132 | + LogKeyValue("ShardId", ToString(record.GetOrigin()), ss); |
| 133 | + |
| 134 | + TStringBuilder locksDebugStr; |
| 135 | + locksDebugStr << "["; |
| 136 | + for (const auto& lock : record.GetTxLocks()) { |
| 137 | + locksDebugStr << lock.ShortDebugString(); |
| 138 | + } |
| 139 | + locksDebugStr << "]"; |
| 140 | + |
| 141 | + LogKeyValue("Locks", locksDebugStr, ss); |
| 142 | + LogKeyValue("Status", NKikimrDataEvents::TEvWriteResult::EStatus_Name(ev->Get()->GetStatus()), ss); |
| 143 | + |
| 144 | + NYql::TIssues issues; |
| 145 | + NYql::IssuesFromMessage(record.GetIssues(), issues); |
| 146 | + LogKeyValue("Issues", issues.ToString(), ss, /*last*/ true); |
| 147 | + |
| 148 | + return ss.Str(); |
| 149 | + }; |
| 150 | + |
| 151 | + LOG_INFO_S(ctx, NKikimrServices::DATA_INTEGRITY, log(state, traceId, ev)); |
| 152 | +} |
| 153 | + |
| 154 | +inline void LogIntegrityTrails(const TString& state, const TString& traceId, const TEvDataShard::TEvProposeTransactionResult::TPtr& ev, const TActorContext& ctx) { |
| 155 | + auto log = [](const auto& state, const auto& traceId, const auto& ev) { |
| 156 | + const auto& record = ev->Get()->Record; |
| 157 | + |
| 158 | + TStringStream ss; |
| 159 | + LogKeyValue("Component", "Executer", ss); |
| 160 | + LogKeyValue("Type", "Response", ss); |
| 161 | + LogKeyValue("State", state, ss); |
| 162 | + LogKeyValue("TraceId", traceId, ss); |
| 163 | + LogKeyValue("PhyTxId", ToString(record.GetTxId()), ss); |
| 164 | + LogKeyValue("ShardId", ToString(record.GetOrigin()), ss); |
| 165 | + |
| 166 | + TStringBuilder locksDebugStr; |
| 167 | + locksDebugStr << "["; |
| 168 | + for (const auto& lock : record.GetTxLocks()) { |
| 169 | + locksDebugStr << lock.ShortDebugString(); |
| 170 | + } |
| 171 | + locksDebugStr << "]"; |
| 172 | + |
| 173 | + LogKeyValue("Locks", locksDebugStr, ss); |
| 174 | + LogKeyValue("Status", NKikimrTxDataShard::TEvProposeTransactionResult_EStatus_Name(ev->Get()->GetStatus()), ss); |
| 175 | + LogKeyValue("Issues", ev->Get()->GetError(), ss, /*last*/ true); |
| 176 | + |
| 177 | + return ss.Str(); |
| 178 | + }; |
| 179 | + |
| 180 | + LOG_INFO_S(ctx, NKikimrServices::DATA_INTEGRITY, log(state, traceId, ev)); |
| 181 | +} |
| 182 | + |
| 183 | +template <typename TActorResultInfo> |
| 184 | +inline void LogIntegrityTrails(const TString& type, const TString& traceId, ui64 txId, const TActorResultInfo& info, const TActorContext& ctx) { |
| 185 | + auto log = [](const auto& type, const auto& traceId, const auto& txId, const auto& info) { |
| 186 | + TStringStream ss; |
| 187 | + LogKeyValue("Component", "Executer", ss); |
| 188 | + LogKeyValue("Type", type, ss); |
| 189 | + LogKeyValue("TraceId", traceId, ss); |
| 190 | + LogKeyValue("PhyTxId", ToString(txId), ss); |
| 191 | + |
| 192 | + TStringBuilder locksDebugStr; |
| 193 | + locksDebugStr << "["; |
| 194 | + for (const auto& lock : info.GetLocks()) { |
| 195 | + locksDebugStr << lock.ShortDebugString(); |
| 196 | + } |
| 197 | + locksDebugStr << "]"; |
| 198 | + |
| 199 | + LogKeyValue("Locks", locksDebugStr, ss); |
111 | 200 |
|
112 | 201 | return ss.Str();
|
113 | 202 | };
|
114 | 203 |
|
115 |
| - LOG_INFO_S(ctx, NKikimrServices::DATA_INTEGRITY, log(txType, traceId, txId, shardId)); |
| 204 | + LOG_INFO_S(ctx, NKikimrServices::DATA_INTEGRITY, log(type, traceId, txId, info)); |
116 | 205 | }
|
117 | 206 |
|
118 | 207 | }
|
|
0 commit comments