The existing TS API `TSStaFindName()` returns success if it's able to find the
stat in the stats hash table. This automatically becomes true for persistent
stats that get loaded from the stats snapshot, even when a `TSStatCreate()`
hasn't been called yet on that stat after a server restart.
There are certain use cases, which check if `TSStatFindName()` returns not
found and only then create the stat (call `TSStatCreate()`) - for example,
header-rewrite plugin. The intention there is to not call `TSStatCreate`
duplicate on a given counter that's potentially created via multiple rules.
However, this results in not setting the Sync CB for the counter while also not
updating the api_rsb_index. This can potentially affect subsequent API stats as
they end up getting stat ids that are already in use by previously used stats
that did not end up calling `TSStatCreate`
To address this, I'm proposing to add a new TS API `TSSyncStatFindName()` which
returns found only if the stat is in the hash table and it's sync_cb is set.
This API will replace the usage of `TSStatFindName` in header-rewrite and other
plugins that we internally have which have similar use cases.
Let me know any concerns/comments/feedback.
Thanks,
Sudheer