summaryrefslogtreecommitdiffstats
path: root/library/cpp/yt/error
Commit message (Collapse)AuthorAgeFilesLines
* YT-22593: Reduce TString usage in core/miscbabenko2 days1-1/+1
| | | | commit_hash:ba8c42476d6274212745348071682042e780037f
* Cache process/thread id getters and use them in TError origin capturebabenko2 days3-5/+8
| | | | | | | | | | | | | | | | | | | | | ## Motivation Profiling the YT master Automaton thread showed TOriginAttributes::Capture (run on every non-OK TError) spending ~60% of its time in a getpid() syscall — uncached on glibc >= 2.25. NYT::GetCurrentThreadId() (gettid) feeds hot thread-affinity / log-manager checks on the same thread. ## Changes - New library/cpp/yt/system/process_id.* with cached GetProcessId(); GetSystemThreadId() now caches the kernel tid in TLS. Both caches reset in the child after fork. - Moved thread_name.{h,cpp} from misc to system. - Removed GetCurrentProcessId/GetCurrentThreadId shims from yt/yt/core/misc/proc.{h,cpp}; migrated all callers to NYT::GetProcessId / NYT::GetSystemThreadId. - TOriginAttributes::Capture uses the cached getters; recorded Tid is now the real kernel tid (matches perf/ps). - Added microbenchmarks (library/cpp/yt/system/benchmarks, yt/yt/core/benchmarks/error.cpp). ## Microbenchmarks (release) | | before | after | |---|---|---| | getpid | 101 ns | 0.33 ns | | gettid | 102 ns | 1.64 ns | | Capture | 161 ns | 50 ns | | failed TError | 221 ns | 74 ns | commit_hash:ee37ae57d61a5a2dd33daee935270f4bb93b7ff9
* YT-26105: Make TError aware of ::TSystemErrordann2392026-05-251-0/+2
| | | | commit_hash:ca6efe06865fe9fc9ebfd5ca8bbd79c2acbb4ff3
* YT: Add missing 16bit types to TErrorAttribute conversionsdgolear2026-04-303-0/+22
| | | | commit_hash:7e973890af2061e2a78b34d31c404f000375a88b
* Use implicit bool conversion for null check in origin_attributes.cppbabenko2026-04-272-2/+2
| | | | commit_hash:cc1f5b9ecc05f6b098f1645ba338fc644c0bb53f
* Increase default error attributes string truncation limit to 32Kbabenko2026-04-181-2/+4
| | | | commit_hash:da3595c17e930ef69088c3164f42adc50d57f283
* Fix some use-after-move bugspavook2026-04-172-3/+4
| | | | commit_hash:4bc357937e76b2b082671bb0f67ac3012ee4dbca
* Add TErrorOr::ValueOrCrashdann2392026-04-033-0/+67
| | | | commit_hash:7a04b71703a53450dbaa8ec880141545e019a71e
* Intermediate changesrobot-piglet2026-03-031-1/+1
| | | | commit_hash:a66d1ef65085fb8e8bfe860b8b7a95cbc5793851
* Fixed error comparisonmikari2026-02-202-1/+15
| | | | commit_hash:76b32cc3992d0c6ce820f0b52a06deade4fa7558
* YT-18571: Use compound statements in YT_STATIC_INITIALIZERbabenko2026-01-091-2/+3
| | | | commit_hash:ef3baa3a943a47954a169d23ed8390da8fe6941b
* YT-27061: Make OKFuture constinitbabenko2026-01-022-29/+24
| | | | commit_hash:3522ca2def9e06894323c3ac1b5e0e4e83572857
* TErrorOr: propagate constuctible traitswarmer2025-12-243-12/+254
| | | | | | 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
* Error attribute order is attribute adding orderpechatnov2025-12-232-1/+3
| | | | commit_hash:1a8689ad5ded7d7bfab00e7fac0b0689f052c87a
* YT: Do not merge OK errors to inner errorsdgolear2025-12-172-12/+21
| | | | commit_hash:7204f6d279e6660168d497e5fc43a8fd6a21acaa
* Intermediate changesrobot-piglet2025-12-161-5/+4
| | | | commit_hash:01073d5debabb2b7da51639f6d5137155132d193
* fix coverity issueuzhas2025-08-081-1/+1
| | | | commit_hash:55fb7d7ce65181dcdcb238245c19a18f2bd3cf25
* YT-18571: Fix missing semicolonh0pless2025-07-211-1/+1
| | | | commit_hash:2d892bf3d9b67134ec8e9d461159ec4bbf0930b5
* YT: Fix enricher, add from backtrace enricherpechatnov2025-05-063-11/+101
| | | | | From backtrace enricher можно использовать для захвата бектрейсов при создании ошибок из исключений, а так же для перекладывания атрибутов из сложных исключений других библиотек. commit_hash:76711bd3bb7dbc1e41e43f80d43340d2ce8e4df7
* Add new macro to replace some of the YT_VERIFYsh0pless2025-04-231-6/+7
| | | | commit_hash:f4f2e8b9ba31109593c94251f64e1061f00af304
* YT: Add type name of std::exception to error text in TError constructorpechatnov2025-04-012-0/+17
| | | | | | | | | | | | | | | | | | | Без этого, исключение о выходе за пределы массива в векторе выглядит так: ``` vector origin (pid 178121, thread library-cpp-yt-) datetime 2025-03-31T14:59:49.069209Z ``` С фиксом: ``` vector origin (pid 178121, thread library-cpp-yt-) datetime 2025-03-31T14:59:49.069209Z exception_type std::out_of_range ``` commit_hash:7382eba16208f6847d581b901a7df4dfa39452b0
* YTORM-1292 Error enrichment via dependency injectiondeep2025-02-282-2/+40
| | | | | | | Идея такая: хочу подкладывать атрибуты в ошибки, не протаскивая их через стек (как в 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-2212-72/+72
| | | | | [nodiff:runtime] commit_hash:1ba799aed1703ab7c6304b6da7090b3337f768dd
* yt/error: optimize constructing TError from TErrorExceptionKonstantin Khlebnikov2025-02-163-0/+18
| | | | | | | | | | | 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-2611-83/+594
| | | | | | | std::string everywhere done commit_hash:8a83afa39917ba66a5161388a7cd74a4488d9908
* YT-21233: Issues and tidying up of rXXXXXXarkady-e1ppa2024-12-255-58/+37
| | | | commit_hash:19481c9fbb008aab4f4d676f1a3a242f6e90e90e
* YT-21233: Adjust (To/From)ErrorAttributeValue CPOs, revert ConvertTo ↵arkady-e1ppa2024-12-2520-106/+3438
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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
* YT-21233: Introduce ToAttributeValue cpo which removes dependency of ↵arkady-e1ppa2024-11-297-32/+92
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | TErrorAttribute from yt/core Plan: 1) Remove `IAttributedDictionary` type from the public API. \+ 2) Remove `Set` method from public API in favor of `operator<<=`. \+ 3) Adopt `ConvertTo<T>` (or other name) CPO with proper extension into `NYT::NYson::ConvertTo` from `yt/core`. 4) Use CPO from (3) to eliminate direct dependency on `yt/core` of `Get/Find` methods from attributes API. 5) Adopt `ConvertToYsonString` (or other name) CPO with proper extension into `yt/core` customisations. 6) Use CPO from (5) to eliminate direct dependency on `yt/core` of `TErrorAttribute` ctor. 7) Swap attributes implementation to the one which doesn’t use `IAttributeDictionary`. 8) At this point `stripped_error*` can be moved to library/cpp/yt and so can recursively dependant on THROW macro methods `Get/Find/…`. 9) Adjust CPO’s to work with `std::string` instead of `TYsonString` assuming text format to be used (maybe `TString` for now). 10) Remove dep of `library/cpp/yt/error` on `yson` entirely. This pr addresses 5-6 steps of plan. Below is a brief explanation of design decisions. We also expressed everything related to key-value code in terms of aliases of `TErrorAttribute` so that later we could make a relatively simple switch to `std::string`. We expect to do steps 7-8 in the next pull request as everything should be ready commit_hash:de9feca2bd24d823b33d904ef0fa5f4856f9b020
* YT-21233: Rewrite ConvertTo CPO using TagInvokearkady-e1ppa2024-11-083-0/+87
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Plan: 1) Remove `IAttributedDictionary` type from the public API. \+ 2) Remove `Set` method from public API in favor of `operator<<=`. \+ 3) Adopt `ConvertTo<T>` (or other name) CPO with proper extension into `NYT::NYson::ConvertTo` from `yt/core`. 4) Use CPO from (3) to eliminate direct dependency on `yt/core` of `Get/Find` methods from attributes API. 5) Adopt `ConvertToYsonString` (or other name) CPO with proper extension into `yt/core` customisations. 6) Use CPO from (5) to eliminate direct dependency on `yt/core` of `TErrorAttribute` ctor. 7) Swap attributes implementation to the one which doesn’t use `IAttributeDictionary`. 8) At this point `stripped_error*` can be moved to library/cpp/yt and so can recursively dependant on THROW macro methods `Get/Find/…`. 9) Adjust CPO’s to work with `std::string` instead of `TYsonString` assuming text format to be used (maybe `TString` for now). 10) Remove dep of `library/cpp/yt/error` on `yson` entirely. This pr addresses 3-4 steps of plan. Below is a brief explanation of design decisions. We want to have a concept which detects if there is a `ConvertTo` method and if true, try calling it. Templates can only perform unqualified name lookup and if we allow non-ADL overloads to be found, we would have dependency on inclusion order (if `ConvertTo` is included prior to our code, everything works fine, but if the order is reverse, templated dispatch would fail, but direct call would work just fine). That is why we adopt niebloids which first disable ADL lookup of the name `ConvertTo` by directing it to niebloid implemented via `TagInvoke` mechanism. TagInvoke design <https://www.open-std.org/jtc1/sc22/wg21/docs/papers/2019/p1895r0.pdf> . TL;DR: we want to have behavior which is consistent with inclusion order. Key difference now is that `ConvertTo` works consistently in both manual calls and template function body calls and is no longer visible for ADL part of the unqualified name lookup commit_hash:32af641bd0af559bfe670c2ceb36721fb4afc2dd
* YT-21233: Introduce TErrorAttributes as an opaque type for attributes to ↵arkady-e1ppa2024-10-226-0/+315
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | hide dependencies on IAttributeDictionary's API Plan: 1) Remove `IAttributedDictionary` type from the public API. \+ 2) Remove `Set` method from public API in favor of `operator<<=`. \+ 3) Adopt `ConvertTo<T>` (or other name) CPO with proper extension into `NYT::NYson::ConvertTo` from `yt/core`. 4) Use CPO from (3) to eliminate direct dependency on `yt/core` of `Get/Find` methods from attributes API. 5) Adopt `ConvertToYsonString` (or other name) CPO with proper extension into `yt/core` customisations. 6) Use CPO from (5) to eliminate direct dependency on `yt/core` of `TErrorAttribute` ctor. 7) Swap attributes implementation to the one which doesn’t use `IAttributeDictionary`. 8) At this point `stripped_error*` can be moved to library/cpp/yt and so can recursively dependant on THROW macro methods `Get/Find/…`. 9) Adjust CPO’s to work with `std::string` instead of `TYsonString` assuming text format to be used (maybe `TString` for now). 10) Remove dep of `library/cpp/yt/error` on `yson` entirely. This pull request covers steps 1 and 2 laying foundation to 3-4 being implemented in the next one commit_hash:e899bccdef4ebed321ea2eb93215282694c261ac
* init pid fielduzhas2024-09-181-1/+1
| | | | commit_hash:018112cc71f6f4d8bb32bb04a09e8741ba4f8d3d
* YT-21233: Split error into error and stripped_error to rid the latter of ↵arkady-e1ppa2024-08-153-0/+213
deps on global variables What happened: 1. error contents has been split into stripped_error and error. stripped_error contains the error itself (with attributes for now) and macros; error contains stripped_error and some extensions, namely, functions to get fiberId, hostname and traceid/spanid and all functions used to (de-)serialize error. This means that you cannot print error if you only include stripped_error, therefore you are likely to still require the entire error.h at the moment. 2. Mechanic for gathering origin attributes has been moved to newly created library/cpp/yt/error thus having no dependency on fibers, net or tracing. stripped_error uses these attributes as extendable semi-erased (meaning, you still would have to add a field and recompile the entire thing, but you don't have to introduce an extra dependency) storage for a bunch of attributes 3. Parsing of said attributes is done in error file (and not stripped_error). P.S. So far the plan is to eventually move stripped_error (once dependency on core/ytree/attributes is eliminated) without any actual change to dependency graph of anything outside of core (e.g. you would still have to include misc/error.h to use it). Next step would be re-teaching the error how to print, which would move some more methods from core to the standalone module. After that one could finally depend on the error itself and not the entire core. Annotations: [nodiff:caesar] 66615172181355821241d2e5f8e4a0f15e0ea791