Skip to content

common: fix md_config_cacher_t#61289

Merged
ronen-fr merged 4 commits intoceph:mainfrom
ronen-fr:wip-rf-catcher-fix
Jan 15, 2025
Merged

common: fix md_config_cacher_t#61289
ronen-fr merged 4 commits intoceph:mainfrom
ronen-fr:wip-rf-catcher-fix

Conversation

@ronen-fr
Copy link
Contributor

@ronen-fr ronen-fr commented Jan 9, 2025

In its get_tracked_conf_keys() member function, the cacher (in the existing code)
initializes a static function-block variable ('keys'), and uses it for
registering the observer.

But the cacher is instantiated on the type of
the configuration value. Thus, multiple cacher
objects for which the configuration values are
of the same type - share the static 'keys'. Only
one of the observers is registered.

Note that the code could have been simplified
somewhat, if the signature of the
get_tracked_conf_keys() function
was changed to return 'const char* const *'.

Fixes: https://tracker.ceph.com/issues/69236

Note:
Related to https://tracker.ceph.com/issues/69362
(which was errouneously marked as fixed by
#61184),
and its backport: https://tracker.ceph.com/issues/69374
(#61185)

@github-actions github-actions bot added the common label Jan 9, 2025
@ronen-fr ronen-fr added bug-fix needs-quincy-backport backport required for quincy needs-reef-backport needs-squid-backport PR needs a squid backport and removed common labels Jan 9, 2025
@ronen-fr ronen-fr marked this pull request as ready for review January 9, 2025 17:12
: conf(conf),
option_name(option_name) {
keys{option_name, nullptr},
option_name(keys[0]) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This assumes certain guarantees about the life-time of the passed option_name. It's nothing new but, if the config_cacher_t get rolled out broadlier, it might be an idea for another clean-up.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes - that's an unfortunate choice of the existing interface.
I do plan to make a deeper change in 'main', and will probably try to change that.
The simplest solution - just strdup() that name. But I'll try to move to std::string-s if possible.

class md_config_cacher_t : public md_config_obs_t {
ConfigProxy& conf;
const char* keys[2];
const char* const option_name;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do we really need option_name after introducing keys?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good catch. Fixed.

@ronen-fr
Copy link
Contributor Author

@rzarzynski - can you take a look again?

In its get_tracked_conf_keys() member function, the
cacher (in the existing code) initializes a static
function-block variable ('keys'), and uses it for
registering the observer.

But the cacher is instantiated on the type of
the configuration value. Thus, multiple cacher
objects for which the configuration values are
of the same type - share the static 'keys'. Only
one of the observers is registered.

Note that the code could have been simplified
somewhat, if the signature of the
get_tracked_conf_keys() function
was changed to return 'const char* const *'.

Fixes: https://tracker.ceph.com/issues/69236
Signed-off-by: Ronen Friedman <[email protected]>
moved out of the main commit to
facilitate backporting it to pre-C++20.

Signed-off-by: Ronen Friedman <[email protected]>
@ronen-fr ronen-fr requested a review from a team as a code owner January 14, 2025 09:27
@ronen-fr
Copy link
Contributor Author

Merging based on my Teuthology tests. Tested under two branches (the updated one - rf-cacher-fix-4).
The 'standalone' test failure - an unrelated timeout in the new 'abort' test, that will require a PR to fix.

@ronen-fr
Copy link
Contributor Author

jenkins test make check

@ronen-fr ronen-fr merged commit 091c7c5 into ceph:main Jan 15, 2025
5 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants