-
Notifications
You must be signed in to change notification settings - Fork 1.1k
Couch stats resource tracker v3 rebase main #5602
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Conversation
This reverts commit 020743f.
Alright I went ahead and reworked the This also removed the ugly string conversion in |
I talked with @nickva out of band and realized I confused myself on the need for using absolute values around the time deltas for negative timestamps, negative negative numbers confused me, but he's correct that the use of |
Okay over in 38608f7 I've dropped the extraneous You can actually create that matcher now, but it needs to be registered directly by way of remsh, for example, the follow dynamically creates a CSRT logger matcher that satisfies the constraint (node1@127.0.0.1)16> rr(csrt_server).
[coordinator,rctx,rpc_worker,st]
(node1@127.0.0.1)17> ets:fun2ms(fun(#rctx{dbname = <<"foo">>, type=#coordinator{mod='chttpd_db', func='handle_changes_req'}, ioq_calls=IC, js_filter=JF}=R) when IC > 1000 andalso JF > 100 -> R end).
[{#rctx{started_at = '_',updated_at = '_',pid_ref = '_',
nonce = '_',
type = #coordinator{mod = chttpd_db,
func = handle_changes_req,method = '_',path = '_'},
dbname = <<"foo">>,username = '_',db_open = '_',
docs_read = '_',docs_written = '_',rows_read = '_',
changes_returned = '_',ioq_calls = '$1',js_filter = '$2',
js_filtered_docs = '_',get_kv_node = '_',get_kp_node = '_'},
[{'andalso',{'>','$1',1000},{'>','$2',100}}],
['$_']}]
(node1@127.0.0.1)18> csrt_logger:register_matcher("custom_foo", ets:fun2ms(fun(#rctx{dbname = <<"food_db', func='handle_changes_req'}, ioq_calls=IC, js_filter=JF}=R) when IC > 1000 andalso JF > 100 -> R end)).
ok That'll dynamically compile the matchspec and push it out by way of persistent_term to be picked up by the tracker pids to decide whether or not to generate a process lifecycle report. The tricky bit is mapping I would love to see a simple translation layer that basically lets us use Mango syntax for declaring these filters, as that would make it much easier to express within the ini files, but also it would allow us to dynamically construct the logger matcher specs on the fly for a given HTTP request, eg you could |
sed -I '' 's/csrt.hrl/couch_srt.hrl/g' src/*/{src,test/eunit}/*.erl sed -I '' 's/csrt:/couch_srt:/g' src/*/{src,test/eunit}/*.erl sed -I '' 's/csrt_\([a-z_]*\):/couch_srt_\1:/g' src/*/{src,test/eunit}/*.erl Cleanup remaining 'csrt\(_[a-z_]*\)\?:' references Hook in couch_srt app sed -I '' 's/^-module(csrt/-module(couch_srt/g' src/*/{src,test/eunit}/*.erl More cleanup
Over in 38a53a0 I migrated CSRT into the
That commit creates a clean separation between One thing that I'd like feedback on in particular, I preserved the name "CSRT" as I think it's a good name for the system and I've grown accustomed to referring to it as such. The public Erlang APIs all use I like the balance of I kept that as an isolated commit to have a logical commit containing all the direct sed changes, and then I waited to run Tomorrow I'll add some additional updates to the overview documentation to better illustrate when/where/how users would initially enable and utilize CSRT. Aside from the additional documentation updates, I think I've addressed all outstanding issues I'm aware of, any further feedback on this PR? |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looked over the PR again. Great progress! Lots of improvements. The separate application looks much cleaner. The example looks great, and the default ini looks much better!
Left a some more comments in review. Some are just suggestions or tips and questions about how things work. Some of the highlighted things are below but see more inline:
- This is a rather large feature and so we'd want to add something to the official docs about it
- New config settings and API endpoints should be documented as well.
- CouchDB has a Prometheus endpoint. Would couch_srt work with it? Or maybe could work with it in the future? I haven't look at it in a while, but I think Prometheus is also pretty good with higher metrics, so maybe some of the couch_srt entries could end up there and then magically in some dashboard? If there is anything interesting there maybe add some thought to the readme about it.
src/couch_srt/README.md
Outdated
|
||
## config:get(?CSRT, "enable_rpc_reporting", false). | ||
|
||
This enables the possibility of RPC workers generating reports. They still need |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The thresholds here are per node per worker if enable_rpc_reporting = true? If enable_rpc_reporting = false do those thresholds not take effect or they work only on the coordinator side the?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The thresholds apply to any rctx()
, we have a safety hatch to disable RPC reporting entirely, by way of:
%% Return a subset of Matchers for each Matcher that matches on Rctxs
-spec find_matches(Rctxs :: [rctx()], Matchers :: matchers()) -> matchers().
find_matches(Rctxs, Matchers) when is_list(Rctxs) andalso is_map(Matchers) ->
Rctxs1 =
case couch_srt_util:is_enabled_rpc_reporting() of
true ->
Rctxs;
false ->
[Rctx || #rctx{type = #coordinator{}} = Rctx <- Rctxs]
end,
maps:filter(
fun(_Name, {_MSpec, CompMSpec}) ->
(catch ets:match_spec_run(Rctxs1, CompMSpec)) =/= []
end,
Matchers
).
All process lifecycle reports happen on the local node, but the RPC workers can funnel their stats to the remote coordinator process, technically The thresholds here are per node per worker
is The thresholds here are per node per coordinator or RPC worker context
, eg if you enable the ioq_calls
matcher with Threshold=10000
, and you also enable RPC reporting, then any coordinator or RPC worker inducing 10000 IOQ calls will log, which naturally means the coordinator would also log given it had a worker alone that induced 10000 IOQ calls. It's a bit awkward, but it's a pragmatic escape hatch if you need to enable RPC report logging on a node or cluster.
Over in 828667e I've reworked the docs extensively into the Sphinx docs app, and I've covered details on enabling RPC reporting in both the main CSRT docs index and the CSRT config index, with details covering the nuances. I don't know how to link out to branch level built Sphinx documentation, but I put an entire section together highlighting these nuances, why it's a problem, why it's a temporary problem, and how to specify the clustered db name vs the sharded db name in the RPC workers, over in http://localhost:8000/csrt/index.html#demonstration-of-expressiveness-constraints-in-logger-matchers-and-ini-settings (that link should work if you run it locally, or eventually by changing the host on the documentation).
src/couch_srt/README.md
Outdated
process lifetime reports for individual RPC workers that trigger the configured | ||
logger thresholds. This allows for quantifying per node resource usage when | ||
desired, as otherwise the reports are at the http request level and don't | ||
provide per node stats. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We do ship delta stats across rexi to the coordinators are those not the node stats? Or we just see them at the end of the request when/if a report is generated at the end from the coordinator
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah, I added more details above in #5602 (comment) but yes, RPC workers track their local stats, ship the deltas across the wire to the coordinator through the rexi calls, and then those RPC workers themselves don't generate a report if the RPC reporting is disable.
The tricky thing is for large Q
aggregate queries, say Q=64
, if consistent hashing is uniform, each replica only induces 1/64th of the workload we're matching on the coordinator, which means we have to store a lot more reports to post facto aggregate the data or we do the aggregation up front to get the data to the coordinator process while we're already streaming all the rows.
Or we just see them at the end of the request
To be very clear: CSRT ships these stats in real time, whenever the (fabric_rpc
) RPC worker responds through rexi, so that we get the delta updates live as they're happening. This is why it's CRITICAL to include the CSRT deltas in the rexi:ping
function so that long running workers that aren't returning rows will funnel their deltas back to the coordinator during the ping calls so we can maintain a real time update at the coordinator level of the work being induced. This was a core goal given the issues we've seen around long running _find
queries not returning data until way too late, combined with the client socket timing out and not getting notified until much later. The recent updates to allow for the client to supply the nonce value also means we get that nonce value directly when instantiating the CSRT coordinator context and RPC worker contexts, such that even if the client request disconnects prior to us ever sending the request back through a front load balancer like HAProxy, we'll still be able to generate the report but importantly we'll generate the report with the provided nonce value, allowing for connections to the original client request that would have otherwise been lostl
src/couch_srt/README.md
Outdated
The key idea here is that having RPC level CSRT process lifetime reporting is | ||
incredibly useful, but can also generate large quantities of data. For example, | ||
a view query on a Q=64 database will stream results from 64 shard replicas, | ||
resulting in at least 64 RPC reports, plus any that might have been generated | ||
from RPC workers that "lost" the race for shard replica. This is very useful, | ||
but a lot of data given the verbose nature of funneling it through the RSyslog | ||
reports, however, the ability to write directly to something like ClickHouse or | ||
another columnar store would be great. | ||
|
||
Until there's an efficient storage mechanism to stream the results to, the | ||
rsyslog entries work great and are very practical, but care must be taken to | ||
not generate too much data for aggregate queries as they generate at least `Qx` | ||
more report than an individual report per http request from the coordinator. | ||
This setting exists as a way to either a) utilize the logger matcher configured | ||
thresholds to allow for _any_ rctx's to be recorded when they induce heavy | ||
operations, either Coordinator or RPC worker; or b) to _only_ log workloads at | ||
the coordinator level. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That's why I was thinking maybe having a per/node per/time window summary mode might help to avoid the logs being overloaded and still get the rpc-level data. Kind of a middle ground or if that works out it could be just the default (one mode) so we (users) won't have to choose between only vs coordinator + enable_rpc_reporting
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah I agree that would be nice, it's just not immediately obvious to me what that should look like. I've mentioned up above in #5602 (comment) some of the issues around large Q
databases and the potential RPC volume.
To be clear, I agree this would be nice, but I think this is a secondary phase type of thing, as this kind of strikes like me setting up agents that periodically query to periodically perform an aggregation and log the results. It also doesn't seem like a data structure issue on the core CSRT tracking, but rather another instance of the expressiveness problem with the matchers and the ini settings.
I mentioned above reworking the CSRT docs considerably and moving them into the Sphinx docs page, but I kept the old CSRT.md
as couch_srt/README.md
, and I've updated it based on your feedback, but I also included a section on # Extending CSRT
and ## Next Steps
, where I mention adding report "snapshots".
I've always kind of though of report "snapshots" as a natural evolution to the process lifecyle reports, especially for long running background jobs once those are support. For instance, it'd be great to get periodic progress status reports generated for large index builds.
@nickva do you think there's any core data structure issues with our ets #rctx{}
setup that would prevent this from being added later? Personally I don't think so, I think CSRT is in a good spot with solid data collection and a well tested/documented/type_spec'ed HTTP and query API built on the performant matchers, and it's in a good spot to start putting to use and figure out what types of additional querying and introspection capabilities are needed.
For instance, if we had periodic per node processes logging these stats, what would they aggregate on? We could certainly do something like generate a report on top 10 IOQ calls grouped by user
or something, but we lose a lot of the nuance in the data there, making it harder to work with the aggregated report values. Another idea I had was during the context destruction when we potentially generate a report, we have the final rctx for the process, we could take that and aggregate those stats into some type of periodic report. But again, it's not obvious to me what that would look like, and I think it'll be much clearer when we solve the CSRT Logger Matcher expressiveness problem first.
src/couch_srt/README.md
Outdated
## config:get(?CSRT, "randomize_testing", true). | ||
|
||
This is a `make eunit` only feature toggle that will induce randomness into the | ||
cluster's `couch_srt:is_enabled()` state, specifically to utilize the test suite to | ||
exercise edge case scenarios and failures when CSRT is only conditionally | ||
enabled, ensuring that it gracefuly and robustly handles errors without fallout | ||
to the underlying http clients. | ||
|
||
The idea here is to introduce randomness into whether CSRT is enabled across all | ||
the nodes to simulate clusters with heterogeneous CSRT enablement and also to | ||
ensure that CSRT works properly when toggled on/off wihout causing any | ||
unexpected fallout to the client requests. | ||
|
||
This is a config toggle specifically so that the actual CSRT tests can disable | ||
it for making accurate assertions about resource usage traacking, and is not | ||
intended to be used directly. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Maybe it's better to skip mentioning it? Users will likely either toggle or not toggle csrt reporting on a cluster and likely won't run eunit tests. For eunit tests a note for devs in the tests module is good enough.
src/couch_srt/README.md
Outdated
|
||
## config:get_integer(?CSRT, "query_limit", ?QUERY_LIMIT) | ||
|
||
Limit the quantity of rows that can be loaded in an http query. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If the rows are truncated is there an indication in the response? If this meant to be used by cluster operators wonder if the extra safety is even needed, it would be one off request and the'd probably want to wait to get all the rows than forcing them to build an iteration / bookmarking thing.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah!! @iilyak did a great job here, if the request specifies a limit larger than the configured limit, an error is returned up front before any work is performed, and in the event a csrt_query:group_by
groups and aggregates on more than config:get_integer(?CSRT, "query_limit", ?QUERY_LIMIT)
rows, that will trigger a {limit, Acc}
fallback that will bubble up the current aggregations results without further processing. In the event a query is done that returns more than query_limit()
rows, it automatically initiates a topK
on those results to constrain the response size to max query_limit()
groups. Ilya did a great job making sure the data found is funneled back, even in the event of hitting the limits.
I also patched this earlier today (/cc @iilyak) to use ets:select/3
directly instead of ets:foldl
, as the former is done directly in the ETS NIF and bypasses a lot of fetching of data into the caller, more details in 711b070, but I fixed the notion of query_cardinality_limit
vs query_limit
, so that query_limit
is the limit of aggregation groups in the response, and query_cardinality_limit
is the maximum ets row working set to fetch for handling the query that then attempts to group the data down into less than query_limit()
groups. Now csrt_query:group_by
will use ets:select/3
with query_cardinality_limit() = 10000 by default
so that the ETS select will happen within the NIF, do the filtering, and then return up to query_cardinality_limit()
rows which we then aggregate into groups, and run topK
over with query_limit()
if need be, while also bubbling up the limit
hit error to indicate this is a truncated response; the patch also includes a test demonstrating hitting the query cardinality limit bubbles this up as well. I config toggled around the existing ets:foldl
implementation in case folks are interested, but that becomes even worse if we optimize the ets:select
calls to only return the fields needed in the aggregation as that minimizes the working set size, and can be extended further with special cases like https://www.erlang.org/docs/23/man/ets#select_count-2 to just doing counting (I wish there was a ets:select_and_agg_by
).
|
||
%% Return a subset of Matchers for each Matcher that matches on Rctxs | ||
-spec find_matches(Rctxs :: [rctx()], Matchers :: matchers()) -> matchers(). | ||
find_matches(Rctxs, Matchers) when is_list(Rctxs) andalso is_map(Matchers) -> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Suggestion: up to you but often #{} =
works just as well instead of is_map/1
and avoid an extra andalso
guard
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Lol yeah... pros and cons... doing the map pattern guard match inline results in:
find_matches(Rctxs, #{}=Matchers) when is_list(Rctxs) ->
which now has conflicted uses of guard clauses, but if we try to resolve that inline like with map, we have to do something like:
find_matches([|]=Rctxs, #{}=Matchers) ->
Except now that won't match against Rctxs=[]
as that's valid value for the type spec [rctx()]
but neither of those pattern matches are.
@@ -20,6 +20,7 @@ url_handler(<<"_utils">>) -> fun chttpd_misc:handle_utils_dir_req/1; | |||
url_handler(<<"_all_dbs">>) -> fun chttpd_misc:handle_all_dbs_req/1; | |||
url_handler(<<"_dbs_info">>) -> fun chttpd_misc:handle_dbs_info_req/1; | |||
url_handler(<<"_active_tasks">>) -> fun chttpd_misc:handle_task_status_req/1; | |||
url_handler(<<"_active_resources">>) -> fun couch_srt_httpd:handle_resource_status_req/1; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We have an API documentation section, we should probably document what the requests look like there
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I've got the documentation reworked into the formal Sphinx docs and now we've got a CSRT working set of docs to extend from, I'm hoping @iilyak can update those docs with his HTTP API updates. I was also wondering if there's a simple way to get the inline docs from the couch_srt_query
module, as those have a lot of great info, where do those end up?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm hoping @iilyak can update those docs with his HTTP API updates.
Docs are added.
This shows us the top 3 most active processes (being tracked in CSRT) over the | ||
next 1000 milliseconds, sorted by number of `ioq_calls` induced! All of three | ||
of these processes are incurring heavy usage, reading many thousands of docs | ||
with 15k+ IOQ calls and heavy JS filter usage, exactly the types of requests | ||
you want to be alerted to. CSRT's proc window logic is built on top of Recon's, | ||
which doesn't return the process info itself, so you'll need to fetch the | ||
process status with `couch_srt:get_resource/1` and then pretty print it with | ||
`couch_srt:to_json/1`. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nice! This is good stuff, a small example is worth a 1000 words!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks! Then you'll appreciate the even further extend example and additional example I added into the main csrt/index.rst
documentation page! :D
src/couch_srt/README.md
Outdated
* `csrt_query.erl` "Query API functions" | ||
- https://github.com/apache/couchdb/blob/93bc894380056ccca1f77415454e991c4d914249/src/couch_stats/src/csrt_query.erl#L319-L674 | ||
* `couch_srt_query.erl` "Query API functions" | ||
- https://github.com/apache/couchdb/blob/93bc894380056ccca1f77415454e991c4d914249/src/couch_stats/src/couch_srt_query.erl#L319-L674 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The sha of this link is most likely need to be updated
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I did update all links
Alright I've gone through and addressed most things:
|
Thanks for the additional feedback Ilya, I've fixed up all the typos in 6481338, much appreciated. Fwiw I'm having a lot of trouble seeing the commit specific comments, I didn't see those in the PR at all, I happened to notice an email notification. For some reason, those conversations are not showing up for me in this top level PR, or the specific PR commit 828667e but I finally found your comments over in the raw commit page at 828667e . I've sorted out all of those comments aside from the recommendation to switch to Erlang code blocks, as that made Sphinx not happy, oddly it complained about the |
This PR supercedes #5491 and includes @iilyak's excellent HTTP updates on top of it, as well as some final cleanup and documentation from me. I've copied the contents of
CSRT.md
into the PR description here:Couch Stats Resource Tracker (CSRT)
CSRT (Couch Stats Resource Tracker) is a real time stats tracking system that
tracks the quantity of resources induced at the process level in a live
queryable manner that also generates process lifetime reports containing
statistics on the total resource load of a request, as a function of things like
dbs/docs opened, view and changes rows read, changes returned vs processed,
Javascript filter usage, duration, and more. This system is a paradigm shift in
CouchDB visibility and introspection, allowing for expressive real time querying
capabilities to introspect, understand, and aggregate CouchDB internal resource
usage, as well as powerful filtering facilities for conditionally generating
reports on "heavy usage" requests or "long/slow" requests. CSRT also extends
recon:proc_window
withcsrt:proc_window
allowing for the same style ofbattle hardened introspection with Recon's excellent
proc_window
, but with thesample window over any of the CSRT tracked CouchDB stats!
CSRT does this by piggy-backing off of the existing metrics tracked by way of
couch_stats:increment_counter
at the time when the local process induces thosemetrics inc calls, and then CSRT updates an ets entry containing the context
information for the local process, such that global aggregate queries can be
performed against the ets table as well as the generation of the process
resource usage reports at the conclusions of the process's lifecyle.The ability
to do aggregate querying in realtime in addition to the process lifecycle
reports for post facto analysis over time, is a cornerstone of CSRT that is the
result of a series of iterations until a robust and scalable aproach was built.
The real time querying is achieved by way of a global ets table with
read_concurrency
,write_concurrency
, anddecentralized_counters
enabled.Great care was taken to ensure that zero concurrent writes to the same key
occure in this model, and this entire system is predicated on the fact that
incremental updates to
ets:update_counters
provides really fast andefficient updates in an atomic and isolated fashion when coupled with
decentralized counters and write concurrency. Each process that calls
couch_stats:increment_counter
tracks their local context in CSRT as well, withzero concurrent writes from any other processes. Outside of the context setup
and teardown logic, only operations to
ets:update_counter
are performed, oneper process invocation of
couch_stats:increment_counter
, and one forcoordinators to update worker deltas in a single batch, resulting in a 1:1 ratio
of ets calls to real time stats updates for the primary workloads.
The primary achievement of CSRT is the core framework iself for concurrent
process local stats tracking and real time RPC delta accumulation in a scalable
manner that allows for real time aggregate querying and process lifecycle
reports. This took several versions to find a scalable and robust approach that
induced minimal impact on maximum system throughput. Now that the framework is
in place, it can be extended to track any further desired process local uses of
couch_stats:increment_counter
. That said, the currently selected set of statsto track was heavily influenced by the challenges in reotractively understanding
the quantity of resources induced by a query like
/db/_changes?since=$SEQ
, orsimilarly,
/db/_find
.CSRT started as an extension of the Mango execution stats logic to
_changes
feeds to get proper visibility into quantity of docs read and filtered per
changes request, but then the focus inverted with the realization that we should
instead use the existing stats tracking mechanisms that have already been deemed
critical information to track, which then also allows for the real time tracking
and aggregate query capabilities. The Mango execution stats can be ported into
CSRT itself and just become one subset of the stats tracked as a whole, and
similarly, any additional desired stats tracking can be easily added and will
be picked up in the RPC deltas and process lifetime reports.
CSRT Config Keys
-define(CSRT, "csrt").
Primary CSRT config namespace: contains core settings for enabling different
layers of functionality in CSRT, along with global config settings for limiting
data volume generation.
-define(CSRT_MATCHERS_ENABLED, "csrt_logger.matchers_enabled").
Config toggles for enabling specific builtin logger matchers, see the dedicated
section below on
# CSRT Default Matchers
.-define(CSRT_MATCHERS_THRESHOLD, "csrt_logger.matchers_threshold").
Config settings for defining the primary
Threshold
value of the builtin loggermatchers, see the dedicated section below on
# CSRT Default Matchers
.-define(CSRT_MATCHERS_DBNAMES, "csrt_logger.dbnames_io").
Config section for setting
$db_name = $threshold
resulting in instantiating a"dbname_io" logger matcher for each
$db_name
that will generate a CSRTlifecycle report for any contexts that that induced more operations on any one
field of
ioq_calls|get_kv_node|get_kp_node|docs_read|rows_read
that is greaterthan
$threshold
and is on database$db_name
.This is basically a simple matcher for finding heavy IO requests on a particular
database, in a manner amenable to key/value pair specifications in this .ini
file until a more sophisticated declarative model exists. In particular, it's
not easy to sequentially generate matchspecs by way
ets:fun2ms/1
, and so analternative mechanism for either dynamically assembling an
#rctx{}
to matchagainst or generating the raw matchspecs themselves is warranted.
-define(CSRT_INIT_P, "csrt.init_p").
Config toggles for tracking counters on spawning of RPC
fabric_rpc
workers byway of
rexi_server:init_p
. This allows us to conditionally enable new metricsfor the desired RPC operations in an expandable manner, without having to add
new stats for every single potential RPC operation. These are for the individual
metrics to track, the feature is enabled by way of the config toggle
config:get(?CSRT, "enable_init_p")
, and these configs can left alone for themost part until new operations are tracked.
CSRT Code Markers
-define(CSRT_ETS, csrt_server).
This is the reference to the CSRT ets table, it's managed by
csrt_server
sothat's where the name originates from.
-define(MATCHERS_KEY, {csrt_logger, all_csrt_matchers}).
This marker is where the active matchers are written to in
persisten_term
forconcurrently and parallelly and accessing the logger matchers in the CSRT
tracker processes for lifecycle reporting.
CSRT Process Dictionary Markers
-define(PID_REF, {csrt, pid_ref}).
This marker is for the core storing the core
PidRef
identifier. The key ideahere is that a lifecycle is a context lifecycle is contained to within the given
PidRef
, meaning that aPid
can instantiate different CSRT lifecycles andpass those to different workers.
This is specifically necessary for long running processes that need to handle
many CSRT context lifecycles over the course of that individual process's
lifecycle independent. In practice, this is immediately needed for the actual
coordinator lifecycle tracking, as
chttpd
uses a worker pool of http requesthandlers that can be re-used, so we need a way to create a CSRT lifecycle
corresponding to the given request currently being serviced. This is also
intended to be used in other long running processes, like IOQ or
couch_js
pidssuch that we can track the specific context inducing the operations on the
couch_file
pid or indexer or replicator or whatever.Worker processes have a more clear cut lifecycle, but either style of process
can be exit'ed in a manner that skips the ability to do cleanup operations, so
additionally there's a dedicated tracker process spawned to monitor the process
that induced the CSRT context such that we can do the dynamic logger matching
directly in these tracker processes and also we can properly cleanup the ets
entries even if the Pid crashes.
-define(TRACKER_PID, {csrt, tracker}).
A handle to the spawned tracker process that does cleanup and logger matching
reprots at the end of the process lifecycle. We store a reference to the tracker
pid so that for explicit context destruction, like in
chttpd
workers after arequest has been serviced, we can update stop the tracker and perform the
expected cleanup directly.
-define(DELTA_TA, {csrt, delta_ta}).
This stores our last delta snapshot to track progress since the last incremental
streaming of stats back to the coordinator process. This will be updated after
the next delta is made with the latest value. Eg this stores
T0
so we can doT1 = get_resource()
make_delta(T0, T1)
and then we saveT1
as the newT0
for use in our next delta.
-define(LAST_UPDATED, {csrt, last_updated}).
This stores the integer corresponding to the
erlang:monotonic_time()
value ofthe most recent
updated_at
value. Basically this lets us utilize a pdictvalue to be able to turn
update_at
tracking into an incremental operation thatcan be chained in the existing atomic
ets:update_counter
andets:update_element
calls.The issue being that our updates are of the form
+2 to ioq_calls for $pid_ref
,which ets does atomically in a guaranteed
atomic
andisolated
manner. Thestrict use of the atomic operations for tracking these values is why this
system works effeciently at scale. This means that we can increment counters on
all of the stats counter fields in a batch, very quickly, but for tracking
updated_at
timestamps we'd need to either do an extra ets call to get the lastupdated_at
value, or do an extra ets call toets:update_element
to set theupdated_at
value tocsrt_util:tnow()
. The core problem with this is that thebatch inc operation is essentially the only write operation performed after the
initial context setting of dbname/handler/etc; this means that we'd literally
double the number of ets calls induced to track CSRT updates, just for tracking
the
updated_at
. So instead, we rely on the fact that the local processcorresponding to
$pid_ref
is the only process doing updates so we know thelast
updated_at
value will be the last time this process updated the data. Sowe track that value in the pdict and then take a delta between
tnow()
andupdated_at
, and thenupdated_at
becomes a value we can sneak into the otherinteger counter updates we're already performing!
Primary Config Toggles
CSRT (?CSRT="csrt") Config Settings
config:get(?CSRT, "enable", false).
Core enablement toggle for CSRT, defaults to false. Enabling this setting
intiates local CSRT stats collection as well as shipping deltas in RPC
responses to accumulate in the coordinator.
This does not trigger the new RPC spawn metrics, and it does not enable
reporting for any of the rctx types.
NOTE: you MUST have all nodes in the cluster running a CSRT aware CouchDB
before you enable it on any node, otherwise the old version nodes won't know
how to handle the new RPC formats including an embedded Delta payload.
config:get(?CSRT, "enable_init_p", false).
Enablement of tracking new metric counters for different
fabric_rpc
operationstypes to track spawn rates of RPC work induced across the cluster. There is
corresponding config lookups into the
?CSRT_INIT_P
namespace for keys of theform:
atom_to_list(Mod) ++ "__" atom_to_list(Fun)
, eg"fabric_rpc__open_doc"
for enabling the specific RPC endpoints.
However, those individual settings can be ignored and this top level config
toggle is what should be used in general, as the function specific config
toggles predominantly exist to enable tracking a subet of total RPC operations
in the cluster, and new endpoints can be added here.
config:get(?CSRT, "enable_reporting", false).
This is the primary toggle for enabling CSRT process lifetime reports containing
detailed information about the quantity of work induced by the given
request/worker/etc. This is the top level toggle for enabling any reporting,
and there also exists
config:get(?CSRT, "enable_rpc_reporting", false).
todisable the reporting of any individual RPC workers, leaving the coordinator
responsible of generating a report with the accumulated deltas.
config:get(?CSRT, "enable_rpc_reporting", false).
This enables the possibility of RPC workers generating reports. They still need
to hit the configured thresholds to induce a report, but this will generate CSRT
process lifetime reports for individual RPC workers that trigger the configured
logger thresholds. This allows for quantifying per node resource usage when
desired, as otherwise the reports are at the http request level and don't
provide per node stats.
The key idea here is that having RPC level CSRT process lifetime reporting is
incredibly useful, but can also generate large quantities of data. For example,
a view query on a Q=64 database will stream results from 64 shard replicas,
resulting in at least 64 RPC reports, plus any that might have been generated
from RPC workers that "lost" the race for shard replica. This is very useful,
but a lot of data given the verbose nature of funneling it through the RSyslog
reports, however, the ability to write directly to something like ClickHouse or
another columnar store would be great.
Until there's an efficient storage mechanism to stream the results to, the
rsyslog entries work great and are very practical, but care must be taken to
not generate too much data for aggregate queries as they generate at least
Qx
more report than an individual report per http request from the coordinator.
This setting exists as a way to either a) utilize the logger matcher configured
thresholds to allow for any rctx's to be recorded when they induce heavy
operations, either Coordinator or RPC worker; or b) to only log workloads at
the coordinator level.
NOTE: this setting exists because we lack an expressive enough config
declaration to easily chain the matchspec constructions as
ets:fun2ms/1
is aspecial compile time parse transform macro that requires the fully definition to
be specified directly, it cannot be iteractively constructed. That said, you
can register matchers through remsh with more specific and fine grained
pattern matching, and a more expressive system for defining matchers are being
explored.
config:get_boolean(?CSRT, "should_truncate_reports", true)
Enables truncation of the CSRT process lifetime reports to not include any
fields that are zero at the end of process lifetime, eg don't include
js_filter=0
in the report if the request did not induce Javascript filtering.This can be disabled if you really care about consistent fields in the report
logs, but this is a log space saving mechanism, similar to disabling RPC
reporting by default, as its a simple way to reduce overall volume
config:get(?CSRT, "randomize_testing", true).
This is a
make eunit
only feature toggle that will induce randomness into thecluster's
csrt:is_enabled()
state, specifically to utilize the test suite toexercise edge case scenarios and failures when CSRT is only conditionally
enabled, ensuring that it gracefuly and robustly handles errors without fallout
to the underlying http clients.
The idea here is to introduce randomness into whether CSRT is enabled across all
the nodes to simulate clusters with heterogeneous CSRT enablement and also to
ensure that CSRT works properly when toggled on/off wihout causing any
unexpected fallout to the client requests.
This is a config toggle specifically so that the actual CSRT tests can disable
it for making accurate assertions about resource usage traacking, and is not
intended to be used directly.
config:get_integer(?CSRT, "query_limit", ?QUERY_LIMIT)
Limit the quantity of rows that can be loaded in an http query.
CSRT_INIT_P (?CSRT_INIT_P="csrt.init_p") Config Settings
config:get(?CSRT_INIT_P, ModFunName, false).
These config toggles exist to conditionaly enable additional tracking of RPC
endpoints of interest, but rather it's a way to selectively enable tracking for
a subset of RPC operations, in a way we can extend later to add more. The
ModFunName
is of the formatom_to_list(Mod) ++ "__" atom_to_list(Fun)
, eg"fabric_rpc__open_doc"
, and right now, only exists forfabric_rpc
modules.NOTE: this is a bit awkward and isn't meant to be used directly, instead,
utilize
config:set(?CSRT, "enable_init_p", "true").
to enable or disable theseas a whole.
The current set of operations, as copied in from
default.ini
CSRT Logger Matcher Enablement and Thresholds
There are currently six builtin default loggers designed to make it easy to do
filtering on heavy resource usage inducing and long running requests. These are
designed as a simple baseline of useful matchers, declared in a manner amenable
to
default.ini
based constructs. More expressive matcher declarations arebeing explored, and matchers of arbitrary complexity can be registered directly
through remsh. The default matchers are all designed around an integer config
Threshold that triggers on a specific field, eg docs read, or on a delta of
fields for long requests and changes requests that process many rows but return
few.
The current default matchers are:
less than was necessarily loaded to complete the request (eg find heavy
filtered changes requests reading many rows but returning few).
Each of the default matchers has an enablement setting in
config:get(?CSRT_MATCHERS_ENABLED, Name)
for toggling enablement of it, and acorresponding threshold value setting in
config:get(?CSRT_MATCHERS_THRESHOLD, Name)
that is an integer value corresponding to the specific nature of thatmatcher.
CSRT Logger Matcher Enablement (?CSRT_MATCHERS_ENABLED)
config:get_boolean(?CSRT_MATCHERS_ENABLED, "docs_read", false)
Enable the
docs_read
builtin matcher, with a defaultThreshold=1000
, suchthat any request that reads more than
Threshold
docs will generate a CSRTprocess lifetime report with a summary of its resouce consumption.
This is different from the
rows_read
filter in that a view with?limit=1000
will read 1000 rows, but the same request with
?include_docs=true
will alsoinduce an additional 1000 docs read.
config:get_boolean(?CSRT_MATCHERS_ENABLED, "rows_read", false)
Enable the
rows_read
builtin matcher, with a defaultThreshold=1000
, suchthat any request that reads more than
Threshold
rows will generate a CSRTprocess lifetime report with a summary of its resouce consumption.
This is different from the
docs_read
filter so that we can distinguish betweenheavy view requests with lots of rows or heavy requests with lots of docs.
config:get_boolean(?CSRT_MATCHERS_ENABLED, "docs_written", false)
Enable the
docs_written
builtin matcher, with a defaultThreshold=500
, suchthat any request that writtens more than
Threshold
docs will generate a CSRTprocess lifetime report with a summary of its resouce consumption.
config:get_boolean(?CSRT_MATCHERS_ENABLED, "ioq_calls", false)
Enable the
ioq_calls
builtin matcher, with a defaultThreshold=10000
, suchthat any request that induces more than
Threshold
IOQ calls will generate aCSRT process lifetime report with a summary of its resouce consumption.
config:get_boolean(?CSRT_MATCHERS_ENABLED, "long_reqs", false)
Enable the
long_reqs
builtin matcher, with a defaultThreshold=60000
, suchthat any request where the the last CSRT rctx
updated_at
timestamp is at leastThreshold
milliseconds grather than thestarted_at timestamp
will generate aCSRT process lifetime report with a summary of its resource consumption.
CSRT Logger Matcher Threshold (?CSRT_MATCHERS_THRESHOLD)
config:get_integer(?CSRT_MATCHERS_THRESHOLD, "docs_read", 1000)
Threshold for
docs_read
logger matcher, defaults to1000
docs read.config:get_integer(?CSRT_MATCHERS_THRESHOLD, "rows_read", 1000)
Threshold for
rows_read
logger matcher, defaults to1000
rows read.config:get_integer(?CSRT_MATCHERS_THRESHOLD, "docs_written", 500)
Threshold for
docs_written
logger matcher, defaults to500
docs written.config:get_integer(?CSRT_MATCHERS_THRESHOLD, "ioq_calls", 10000)
Threshold for
ioq_calls
logger matcher, defaults to10000
IOQ calls made.config:get_integer(?CSRT_MATCHERS_THRESHOLD, "long_reqs", 60000)
Threshold for
long_reqs
logger matcher, defaults to60000
milliseconds.Core CSRT API
The
csrt(.erl)
module is the primary entry point into CSRT, containing APIfunctionality for tracking the lifecycle of processes, inducing metric tracking
over that lifecycle, and also a variety of functions for aggregate querying.
It's worth noting that the CSRT context tracking functions are specifically
designed to not
throw
and be safe in the event of unexpected CSRT failures oredge cases. The aggregate query API has some callers that will actually throw,
but aside from this core CSRT operations will not bubble up exceptions, and will
either return the error value, or catch the error and move on rather than
chaining further errors.
PidRef API
These are functions are CRUD operations around creating and storing the CSRT
PidRef
handle.Context Lifecycle API
These are the CRUD functions for handling a CSRT context lifecycle, where a
lifecycle context is created in a
chttpd
coordinator process by way ofcsrt:create_coordinator_context/2
, or inrexi_server:init_p
by way ofcsrt:create_worker_context/3
. Additional functions are exposed for settingcontext specific info like username/dbname/handler.
get_resource
fetches thecontext being tracked corresponding to the given
PidRef
.Public API
The "Public" or miscellaneous API for lack of a better name. These are various
functions exposed for wider use and/or testing purposes.
Stats Collection API
This is the stats collection API utilized by way of
couch_stats:increment_counter
to do local process tracking, and also inrexi
to adding and extracting delta contexts and then accumulating those values.
NOTE:
make_delta/0
is a "destructive" operation that will induce a new deltaby way of the last local pdict's rctx delta snapshot, and then update to the
most recent version. Two individual rctx snapshots for a PidRef can safely
generate an actual delta by way of
csrt_util:rctx_delta/2
.TODO: RPC/QUERY DOCS
Recon API Ports of https://github.com/ferd/recon/releases/tag/2.5.6
This is a "port" of
recon:proc_window
tocsrt:proc_window
, allowing forproc_window
style aggregations/sorting/filtering but with the stats fieldscollected by CSRT! This is also a direct port of
recon:proc_window
in that itutilizes the same underlying logic and effecient internal data structures as
recon:proc_window
, but rather only changes the Sample function:In particular, our change is
Sample = fun() -> pid_ref_attrs(AttrName) end,
,and in fact, if recon upstream parameterized the option of
AttrName
orSampleFunction
, this could be reimplemented as:This implementation is being highlighted here because
recon:proc_window/3
isbattle hardened and
recon_lib:sliding_window
uses an effecient internal datastructure for storing the two samples that has been proven to work in production
systems with millions of active processes, so swapping the
Sample
functionwith a CSRT version allows us to utilize the production grade recon
functionality, but extended out to the particular CouchDB statistics we're
esepecially interested in.
And on a fun note: any further stats tracking fields added to CSRT tracking will
automatically work with this too.
Core types and Maybe types
Before we look at the
#rctx{}
record fields, lets examine the core datatypesdefined by CSRT for use in Dialyzer typespecs. There are more, but these are the
essentials and demonstrate the "maybe" typespec approach utilized in CSRT.
Let's say we have a
-type foo() :: #foo{}
and-type maybe_foo() :: foo() | undefined
, we then can construct functions of the form-spec get_foo(id()) -> maybe_foo()
and then we can use Dialyzer to statically assert all callers ofget_foo/1
handle themaybe_foo()
data type rather than justfoo()
andensure that all subsequent callers do as well.
This approach of
-spec maybe_<Type> :: <Type> | undefined
is utilizedthroughout CSRT and has greatly aided in the development, refactoring, and
static analysis of this system. Here's a useful snippet for running Dialyzer
while hacking on CSRT:
Above we have the core
pid_ref()
data type, which is just a tuple with apid()
and areference()
, and naturally,maybe_pid_ref()
handles theoptional presence of a
pid_ref()
, allowing for our APIs likecsrt:get_resource(maybe_pidref())
to handle ambiguity of the presence of apid_ref()
.We define our core
rctx()
data type as an empty#rctx{}
, or the morespecific
coordinator_rctx()
orrpc_worker_rctx()
such that we can bespecific about the
rctx()
type in functions that need to distinguish. And thenas expected, we have the notion of
maybe_rctx()
.#rctx{}
This is the core data structure utilized to track a CSRT context for a
coordinator or rpc_worker process, represented by the
#rctx{}
record, andstored in the
?CSRT_ETS
table keyed on{keypos, #rctx.pid_ref}
.The Metadata fields store labeling data for the given process being tracked,
such as started_at and updated_at timings, the primary
pid_ref
id key, thetype of the process context, and some additional information like username,
dbname, and the nonce of the coordinator request.
The Stats Counters fields are
non_neg_integer()
monotonically increasingcounters corresponding to the
couch_stats
metrics counters we're interested intracking at a process level cardinality. The use of these purely integer counter
fields represented by a record represented in an ets table is the cornerstone of
CSRT and why its able to operate at high throughput and high concurrency, as
ets:update_counter/{3,4}
take increment operations to be performed atomicallyand in isolation, in a manner in which does not require fetching and loading the
data directly. We then take care to batch the accumulation of delta updates into
a single
update_counter
call and even sneak in theupdated_at
tracking as ainteger counter update without inducing an extra ets call.
NOTE: the typespec's for these fields include
'_'
atoms as possible types asthat is the matchspec wildcard any of the fields can be set to when using an
existing
#rctx{}
record to search with.Metadata
We use
csrt_util:tnow()
for time tracking, which is anative
formaterlang:monotonic_time()
integer, which, noteably, can be and is often anegative value. You must either take a delta or convert the time to get into a
useable format, as one might suspect by the use of
native
.We make use of
erlang:mononotic_time/0
as per the recommendation inhttps://www.erlang.org/doc/apps/erts/time_correction.html#how-to-work-with-the-new-api
for the suggested way to
Measure Elasped Time
, as quoted:So our
csrt_util:tnow/0
is implemented as the following, and we storetimestamps in
native
format as long as possible to avoid precision loss athigher units of time, eg 300 microseconds is zero milliseconds.
We store timestamps in the node's local erlang representation of time,
specifically to be able to effeciently do time deltas, and then we track time
deltas from the local node's perspective to not send timestamps across the wire.
We then utilize
calendar:system_time_to_rfc3339
to convert the local node'snative time representation to its corresponding time format when we generate the
process life cycle reports or send an http response.
NOTE: because we do an inline definition and assignment of the
#rctx.started_at
and#rctx.updated_at
fields tocsrt_util:tnow()
, wemust declare
#rctx.updated_at
after#rctx.started_at
to avoidfundamental time incongruenties.
#rctx.started_at = csrt_util:tnow() :: integer() | '_',
A static value corresponding to the local node's Erlang monotonic_time at which
this context was created.
#rctx.updated_at = csrt_util:tnow() :: integer() | '_',
A dynamic value corresponding to the local node's Erlang monotonic_time at which
this context was updated. Note: unlike
#rctx.started_at
, this value willupdate over time, and in the process lifecycle reports the
#rctx.updated_at
value corresponds to the point at which the context was destroyed, allowing for
calculation of the total duration of the request/context.
#rctx.pid_ref :: maybe_pid_ref() | {'', ''} | '_',
The primary identifier used to track the resources consumed by a given
pid()
for a specific context identified with a
make_ref()
, and combined together asunit as a given
pid()
, eg thechttpd
worker pool, can have many contextsover time.
#rctx.nonce :: nonce() | undefined | '_',
The
Nonce
value of the http request being serviced by thecoordinator_rctx()
used as the primary grouping identifier of workers across the cluster, as the
Nonce
is funneled throughrexi_server
.#rctx.type :: rctx_type() | undefined | '_',
A subtype classifier for the
#rctx{}
contexts, right now only supporting#rpc_worker{}
and#coordinator{}
, but CSRT was designed to accomodateadditional context types like
#view_indexer{}
,#search_indexer{}
,#replicator{}
,#compactor{}
,#etc{}
.#rctx.dbname :: dbname() | undefined | '_',
The database name, filled in at some point after the initial context creation by
way of
csrt:set_context_dbname/{1,2}
.#rctx.username :: username() | undefined | '_',
The requester's username, filled in at some point after the initial context
creation by way of
csrt:set_context_username/{1,2}
.Stats Counters
All of these stats counters are stricly
non_neg_integer()
counter values thatare monotonically increasing, as we only induce positive counter increment calls
in CSRT. Not all of these values will be nonzero, eg if the context doesn't
induce Javascript filtering of documents, it won't inc the
#rctx.js_filter
field. The
"should_truncate_reports"
config value described in this documentwill conditionally exclude the zero valued fields from being included in the
process life cycle report.
#rctx.db_open = 0 :: non_neg_integer() | '_',
The number of
couch_server:open/2
invocations induced by this context.#rctx.docs_read = 0 :: non_neg_integer() | '_',
The number of
couch_db:open_doc/3
invocations induced by this context.#rctx.docs_written = 0 :: non_neg_integer() | '_',
A phony metric counting docs written by the context, induced by
csrt:docs_written(length(Docs0)),
infabric_rpc:update_docs/3
as a way tocount the magnitude of docs written, as the actual document writes happen in the
#db.main_pid
couch_db_updater
pid and subprocess tracking is not yetsupported in CSRT.
This can be replaced with direct counting once passthrough contexts work.
#rctx.rows_read = 0 :: non_neg_integer() | '_',
A value tracking multiple possible metrics corresponding to rows streamed in
aggregate operations. This is used for view_rows/changes_rows/all_docs/etc.
#rctx.changes_returned = 0 :: non_neg_integer() | '_',
The number of
fabric_rpc:changes_row/2
invocations induced by this context,specifically tracking the number of changes rows streamed back to the client
requeest, allowing for distinguishing between the number of changes processed to
fulfill a request versus the number actually returned in the http response.
#rctx.ioq_calls = 0 :: non_neg_integer() | '_',
A phony metric counting invocations of
ioq:call/3
induced by this context. Aswith
#rctx.docs_written
, we need a proxy metric to reperesent these callsuntil CSRT context passing is supported so that the
ioq_server
pid and returnits own delta back to the worker pid.
#rctx.js_filter = 0 :: non_neg_integer() | '_',
A phony metric counting the number of
couch_query_servers:filter_docs_int/5
(eg ddoc_prompt) invocations induced by this context. This is called by way of
csrt:js_filtered(length(JsonDocs))
which both incrementsjs_filter
by 1, andjs_filtered_docs
by the length of the docs so we can track magnitude of docsand doc revs being filtered.
#rctx.js_filtered_docs = 0 :: non_neg_integer() | '_',
A phony metric counting the quantity of documents filtered by way of
couch_query_servers:filter_docs_int/5
(eg ddoc_prompt) invocations induced bythis context. This is called by way of
csrt:js_filtered(length(JsonDocs))
which both increments
#rctx.js_filter
by 1, and#rctx.js_filtered_docs
bythe length of the docs so we can track magnitude of docs and doc revs being
filtered.
#rctx.get_kv_node = 0 :: non_neg_integer() | '_',
This metric tracks the number of invocations to
couch_btree:get_node/2
inwhich the
NodeType
returned bycouch_file:pread_term/2
iskv_node
, insteadof
kp_node
.This provides a mechanism to quantify the impact of document count and document
size as those values become larger in the logarithmic complexity btree
algorithms. size on the logarithmic complexity btree algorithms as the database
btrees grow.
#rctx.get_kp_node = 0 :: non_neg_integer() | '_'
This metric tracks the number of invocations to
couch_btree:get_node/2
inwhich the
NodeType
returned bycouch_file:pread_term/2
iskp_node
, insteadof
kv_node
.This provides a mechanism to quantify the impact of document count and document
size as those values become larger in the logarithmic complexity btree
algorithms. size on the logarithmic complexity btree algorithms as the database
btrees grow.
%% "Example to extend CSRT"
%%write_kv_node = 0 :: non_neg_integer() | '',
%%write_kp_node = 0 :: non_neg_integer() | ''