| 文件 | 最后提交记录 | 最后更新时间 |
|---|---|---|
cache: fix shm sizing on large-page Linux (#13536) POSIX shared-memory objects on Linux retain the exact length passed to ftruncate(), but the cache shm gates accepted any size through the next page boundary. On 64 KiB-page systems, a foreign control layout could therefore be treated as compatible, causing cleanup and tooling paths to walk an untrusted stripe table and leave segments behind. This patch requires exact shared-memory object sizes outside macOS while preserving macOS's page-rounded allowance. It keeps the foreign-layout test at its original size and directly covers the platform-specific sizing contract. Fixes: #13534 | 20 天前 | |
Add hidden metrics and MAX/MIN/incremental derived metric aggregation (#13505) * tsutil: make the Metrics unit tests order independent The tests asserted absolute metric ids and iterator positions, which only hold when the case runs first against an otherwise empty store. Any other test case that creates a published metric makes them fail. Assert on relative state instead so the cases can run in any order. * tsutil: add a separate storage for hidden metrics Hidden metrics are stored but never published. Using a separate Storage instance rather than a per-metric flag makes them structurally unreachable from the published store, so no metric consumer can expose them by omission. Gauge and Counter each gain createHiddenPtr overloads which return the same correctly typed pointer as createPtr, so a hidden metric is read and written with the normal typed mutators and no cast is needed at the call site. * tsutil: fail gracefully when metric storage is exhausted Storage::create() had no exhaustion check, so filling the last blob let the following bookkeeping call addBlob() and write one past the end of _blobs. Refuse the final slot instead and return the reserved bad_id, which keeps addBlob() from ever being reached in a full store and costs one slot out of 8M. The guard in addBlob() was also off by one against the access it protects, since the write is to _blobs[++_cur_blob], and being a debug_assert it was compiled out of release builds entirely. Make it a release_assert against MAX_BLOBS - 1. * traffic_ctl: add --include-hidden to metric match Hidden metrics are invisible to normal queries by design, which makes them hard to debug. Add an opt-in rec type bit, deliberately outside RECT_ALL so hidden metrics are never returned unless explicitly requested. The rec type also has to be accepted by the JSONRPC request decoder, which validates each requested type against a whitelist and rejects the whole request otherwise. No wire or schema change is needed, as rec_types is already an untyped list of ints. * tsutil: support MAX and MIN aggregation for derived metrics Derived metrics could only sum their sources. Add an op to the spec so a derived metric can also take the max or min across its sources, which is what an aggregate over instantaneous gauges needs. The accumulator is seeded from the first source rather than from zero, since a zero seed is only correct for SUM and would clamp MIN to <= 0. op defaults to SUM, so existing specs are unaffected. * tsutil: skip derived metric sources that do not resolve A source given by name or id that does not resolve was still passed to lookup(), which masks the unresolved id down to the reserved bad_id slot. The aggregate then silently included that slot's value instead of skipping the source, with no error reported. Resolve each source first and skip it if it does not resolve. This is observable under MAX and MIN, where the bad_id value can become the winning one; under SUM it happened to be hidden by bad_id holding zero. * tsutil: allow adding derived metric sources at runtime derive() only accepts a fixed initializer_list, which does not work for aggregates whose sources are discovered as the process runs. Calling it repeatedly for one derived name does not help either: it appends a separate entry per call, all targeting the same metric, so each update overwrites the others with its own subset and the last writer silently wins. add_source() accumulates sources into a single entry instead. Registering a source that is already present is a no-op, so a caller that may re-register the same source need not track that itself. * doc: document hidden and derived metrics Add a developer guide page for the metrics registry covering the hidden store, how it differs from the published one and why it is a separate store rather than a flag, and the derived metric aggregation ops including when derived values are recomputed and what that means for a sampled maximum. * Tag hidden metrics with RECT_HIDDEN_METRIC as well as RECT_PROCESS The record lookup callback rejects any record whose rec_type shares no bit with the requested mask, so tagging hidden metrics RECT_PROCESS alone made a request for only RECT_HIDDEN_METRIC fail with REQUESTED_TYPE_MISMATCH. Now that the request decoder accepts that type on its own, such a request is expressible, so set both bits. Add a unit test covering the hidden-only and include-hidden requests and confirming RECT_ALL still excludes them. * Value-initialize the synthetic records in the record lookups Both lookup functions build a RecRecord on the stack for metrics, which live outside the g_records array, and hand it to the caller's callback. The JSONRPC encoder reads version, registered, rsb_id, order and data_default unconditionally, so leaving them indeterminate lets a --format json metric query emit different values on successive runs, and reading an indeterminate bool is undefined behavior. Five sites, all with the same one word fix. Only the hidden metric loop is new in this branch; the rest have had the pattern for years. * Grow a new blob when a span ends on the blob boundary createSpan checked whether a span fit before reserving it but never re-checked afterwards, so a span ending exactly on MAX_SIZE left the offset at MAX_SIZE with no new blob allocated. The next create() then wrote one past the end of that blob's name array, and end() became an id that iterator::next() can never reach, since it wraps at ++offset == MAX_SIZE. create() has always grown as soon as it consumed the last slot; do the same here. Also refuse a span that would fill or overflow the final blob, so the new growth cannot ask addBlob() to go past the last one and trip its assert. createSpan(MAX_SIZE) always starts a fresh blob and fills it exactly, whatever the current offset, so the added test reaches the boundary deterministically. It fails without the fix. * Polish the --include-hidden surface Three small corrections to the flag added earlier in this branch: Skip slot 0 when walking the hidden store. Every Storage reserves it for the bad_id placeholder, so it exists under the same name in both stores and a query matching it returned two records differing only in value, in exactly the debugging situation the flag is for. Scope the option to 'match' with a nested program directive. As a bare option under 'traffic_ctl metric' it rendered as a peer of get, match and describe, so it read as another subcommand rather than a flag on match. This follows the 'config get --records' pattern earlier in the file. Put the flag before the positional in the CLI example usage so it agrees with that synopsis, which is also the convention the rest of the file uses. | 14 天前 | |
remove tsapi::c namespace (#11066) format | 2 年前 |
| 文件 | 最后提交记录 | 最后更新时间 |
|---|---|---|
| 20 天前 | ||
| 14 天前 | ||
| 2 年前 |