summaryrefslogtreecommitdiffstats
path: root/library/cpp/yt/error/error.h
Commit message (Collapse)AuthorAgeFilesLines
* YT-28451: Add tagged logging API and opaque event payloadbabenko6 days1-4/+9
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Replace `TLogEvent::MessageRef` with an opaque `Payload` that carries the message together with structured key/value tags, deferring tag rendering to the consumer (logging thread). - Add the `TTaggedPayloadWriter`/`TTaggedPayloadReader` codec (`NDetail`), with a per-thread chunk-cached builder so tagged logging does no per-message heap allocation. - Model the payload as a typed `TLogEventPayload` — a `std::variant` of the opaque strong typedefs `TTaggedLogEventPayload` and `TStructuredLogEventPayload` (each over `TSharedRef`). The active alternative identifies the event kind, so the separate `ELogMessageKind` enum and `TLogEvent::MessageKind` field are removed; consumers dispatch via `std::holds_alternative`/`std::get` instead of a tag. - Add the fluent `YT_TLOG_*` API: `YT_TLOG_INFO("Message").With(key, value)` and `.With(key, value, "%spec")`; disabled levels skip argument evaluation. - Add well-known tags: `.With(value)` attaches a value under a statically known key resolved by ADL (e.g. `.With(error)` for the `Error` tag). - Teach the plain-text and structured formatters to render tags; add the `enable_native_tags` knob to emit tags into a nested structured attribute. - Add producer-side benchmarks. The tagged API is cheaper than `YT_LOG_*` for tagged calls and on par for tag-free ones: #| || **Producer call** | **`YT_LOG_*`** | **`YT_TLOG_*`** | **Δ** || || no tags | 81 ns | 82 ns | +2% || || 1 tag | 124 ns | 88 ns | -29% || || 2 tags | 140 ns | 101 ns | -28% || || 3 tags | 372 ns | 283 ns | -24% || |# -- #| || **<a href="https://nda.ya.ru/t/p0sVNSOC7ijzFF" target="_blank">![](https://nda.ya.ru/t/mAiQIjHx7Mm3JC =30x) Echo tests</a>** || |# commit_hash:70efc90e5c2b71e5311415a4e4508db42ff28971
* Fix use-after-free in TError during program shutdownperst2011 days1-3/+0
| | | | | | | | | | | | | | | | --- Type: fix Component: library/cpp/yt/error Problem: TError::Enricher_ and TError::FromExceptionEnricher_ are static class members whose destructors are registered when error.cpp is loaded. However, if any code calls Singleton<>() during static initialization before error.cpp loads, the OnExit handler gets registered in standard atexit() first. Due to LIFO ordering, at program exit the enrichers are destroyed before OnExit() runs, but OnExit() then destroys Singletons whose destructors may create TError objects (e.g., to cancel futures), which invokes Enrich() on the already-destroyed std::function, causing use-after-free. This can lead to intermittent segfaults depending on the link order of translation units. Solution: Store enrichers in a LeakySingleton<TEnricherStorage> so they are never destroyed, as TError can be created anywhere including during program shutdown. --- Pull Request resolved: https://github.com/ytsaurus/ytsaurus/pull/1582 commit_hash:a9607f0094b4c60414d00ebca844db6a2ceafeb9
* Increase default error attributes string truncation limit to 32Kbabenko2026-04-181-2/+4
| | | | commit_hash:da3595c17e930ef69088c3164f42adc50d57f283
* Fix some use-after-move bugspavook2026-04-171-0/+1
| | | | commit_hash:4bc357937e76b2b082671bb0f67ac3012ee4dbca
* Add TErrorOr::ValueOrCrashdann2392026-04-031-0/+4
| | | | commit_hash:7a04b71703a53450dbaa8ec880141545e019a71e
* YT-27061: Make OKFuture constinitbabenko2026-01-021-4/+11
| | | | commit_hash:3522ca2def9e06894323c3ac1b5e0e4e83572857
* TErrorOr: propagate constuctible traitswarmer2025-12-241-9/+22
| | | | | | Constructors are now conditionally enabled based on whether T is copy- or move-constructible. This allows constructibility to be checked, instead of causing compilation errors during template instantiation. commit_hash:e31da137034705c5c73cd700d9476e96320f2f70
* YT-18571: Fix missing semicolonh0pless2025-07-211-1/+1
| | | | commit_hash:2d892bf3d9b67134ec8e9d461159ec4bbf0930b5
* YT: Fix enricher, add from backtrace enricherpechatnov2025-05-061-3/+12
| | | | | From backtrace enricher можно использовать для захвата бектрейсов при создании ошибок из исключений, а так же для перекладывания атрибутов из сложных исключений других библиотек. commit_hash:76711bd3bb7dbc1e41e43f80d43340d2ce8e4df7
* YTORM-1292 Error enrichment via dependency injectiondeep2025-02-281-0/+10
| | | | | | | Идея такая: хочу подкладывать атрибуты в ошибки, не протаскивая их через стек (как в orm/server/objects) и не прогоняя все ошибки через специальные методы (как в orm/library/attributes). Для этого завожу fiber-local структурку с ленивым выведением строчек. Поскольку TError и TFls живут в разных мирах, пришлось сделать отдельный трамплин для совсем генеричной доработки ошибок в момент создания. Игнат посоветовал глянуть на Codicil. Там очень похоже, но нет key/value, поэтому похитил только название. Вообще, можно унифицировать, если есть запрос. commit_hash:203ec7abe5e8c8484e66d55f16192485db776806
* YT-22593: More trivial TString->std::string migrationsbabenko2025-02-221-6/+6
| | | | | [nodiff:runtime] commit_hash:1ba799aed1703ab7c6304b6da7090b3337f768dd
* yt/error: optimize constructing TError from TErrorExceptionKonstantin Khlebnikov2025-02-161-0/+7
| | | | | | | | | | | Here we can avoid dynamic cast and exception hazard. Signed-off-by: Konstantin Khlebnikov <[email protected]> --- Pull Request resolved: https://github.com/ytsaurus/ytsaurus/pull/1070 commit_hash:e0709e1fe0f2109792b20b850e0e11a6e96f846a
* YT-21233: Drop dependency on yson in library/cpp/yt/error by switch to ↵arkady-e1ppa2024-12-261-2/+0
| | | | | | | std::string everywhere done commit_hash:8a83afa39917ba66a5161388a7cd74a4488d9908
* YT-21233: Issues and tidying up of rXXXXXXarkady-e1ppa2024-12-251-2/+1
| | | | commit_hash:19481c9fbb008aab4f4d676f1a3a242f6e90e90e
* YT-21233: Adjust (To/From)ErrorAttributeValue CPOs, revert ConvertTo ↵arkady-e1ppa2024-12-251-0/+442
becoming CPO, move TErrorCode and TError to library/cpp/yt/error \[nodiff:caesar\] List of changes: 1) Make `ConvertTo` a normal function again (basically, a revert of previous change). It turned out to be very inconvenient entry point 2) Introduce concept for "Primitive types" which are handled without yt/core module. Please note that inclusion of core **does not** affect work with primitive types (otherwise we would be facing and ODR violation). These are numerics, duration, instant, string-like objects and guid 3) Introduce `FromErrorAttributeValue` which is a substitute to `ConvertTo` with special behavior (see below) 4) Scheme for (de-)serialization has changed: 1) Primitive types are handled via `ConvertToTextYsonString` and `ConvertFromTextYsonString` 2) Other types are not supported without yt/core. Otherwise `ConvertToYsonString(value, EYsonFormat::Text)` used for serialization and `ConvertTo<T>(value)` for deserialization. 5) New format of attribute value storage allows to not care about concrete type of the attribute (text yson strings can be detected since they start with `\"` and deserialized so are text yson bools, everything else is already human readable). This drops dependency on `TTokenizer` 6) Some small parts (e.g. enums or constants or aliases) of yt/core/misc files were moved to library/cpp/yt/\* locations and re-included to drop dependencies of stripped\_error on them 7) `TErrorAttributes` is now a simple hash map instead of a handle to `IAttributeDictionary` 8) `ExtractFromAttributes` weak symbol is finally moved to library/cpp/yt/error due to point 9 allowing to fully drop dependency on `IAttributeDictionary`. Combined with point 7 this drops dep on yt/core/ytree altogether 9) Moved `TErrorCode` to library/cpp/yt/error. There is a logger there which forces dep on library/cpp/yt/logging. It is not required really, and can be later removed 10) Moved `TError` with format and macroes to library/cpp/yt/error. It still (and probably forever will) depend on yson. What can be done next: Switch TYsonString to TString and move ConvertTo/FromTextYsonString to library/cpp/yt/error. This would remove dep on library/cpp/yt/yson\_string commit_hash:6f11dc478ab782a1f98a5aedcd45a4800d3f4e7b