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