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
mon: fix iterator mishandling in PGMap::apply_incremental #49480
Conversation
This is a draft to wire it up with the issue tracker. Happy to fill in the template and clean up after discussion about this fix. |
if (i->first.second == *p) { | ||
pg_pool_sum[i->first.first].sub(i->second); | ||
pool_statfs.erase(i); | ||
i = pool_statfs.erase(i); |
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.
From core PR scrub: this looks like a valid issue. We have a tracker for that?
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.
@rzarzynski Yes, they've been rather unnoticed so far. https://tracker.ceph.com/issues/58215 & https://tracker.ceph.com/issues/58303
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, @osnyx! I linked these tickets.
Would you mind to rework the commit description by:
- putting the
Fixes: https://tracker.ceph.com/issues/58303
line just before theSigned-off-by
, - changing the title to:
mon: fix iterator mishandling in PGMap::apply_incremental
?
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.
Let's take a look on the pool_statfs
member:
typedef mempool::pgmap::map<
std::pair<int64_t, int>, // <pool, osd>
store_statfs_t>
per_osd_pool_statfs_t;
per_osd_pool_statfs_t pool_statfs;
The underlying type is std::map
. From the doc:
References and iterators to the erased elements are invalidated. Other references and iterators are not affected.
My understanding is that we shall not i++
if the i
-pointed element has been erased. This stays coherent with the API design (returning new iterator) and even with the example there:
// erase all odd numbers from c
for (auto it = c.begin(); it != c.end();)
{
if (it->first % 2 != 0)
it = c.erase(it);
else
++it;
}
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 core change LGTM! Putting DNM only b/c of the commit description.
if (i->first.second == *p) { | ||
pg_pool_sum[i->first.first].sub(i->second); | ||
pool_statfs.erase(i); | ||
i = pool_statfs.erase(i); |
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.
Let's take a look on the pool_statfs
member:
typedef mempool::pgmap::map<
std::pair<int64_t, int>, // <pool, osd>
store_statfs_t>
per_osd_pool_statfs_t;
per_osd_pool_statfs_t pool_statfs;
The underlying type is std::map
. From the doc:
References and iterators to the erased elements are invalidated. Other references and iterators are not affected.
My understanding is that we shall not i++
if the i
-pointed element has been erased. This stays coherent with the API design (returning new iterator) and even with the example there:
// erase all odd numbers from c
for (auto it = c.begin(); it != c.end();)
{
if (it->first % 2 != 0)
it = c.erase(it);
else
++it;
}
8c9fd14
to
a63e9d1
Compare
Fixes: https://tracker.ceph.com/issues/58303 Signed-off-by: Oliver Schmidt <os@flyingcircus.io>, Christian Theune <ct@flyingcircus.io>
a63e9d1
to
6ba497f
Compare
@rzarzynski Requested changes are done. Thanks for taking care of this. |
|
jenkins retest this please |
jenkins test make check |
Hit the same flaw code, see https://tracker.ceph.com/issues/61912. |
Hey @ctheune can you fill out the checklist in #49480 (comment)? |
Sure - done! |
Contribution Guidelines
To sign and title your commits, please refer to Submitting Patches to Ceph.
If you are submitting a fix for a stable branch (e.g. "pacific"), please refer to Submitting Patches to Ceph - Backports for the proper workflow.
Checklist
Show available Jenkins commands
jenkins retest this please
jenkins test classic perf
jenkins test crimson perf
jenkins test signed
jenkins test make check
jenkins test make check arm64
jenkins test submodules
jenkins test dashboard
jenkins test dashboard cephadm
jenkins test api
jenkins test docs
jenkins render docs
jenkins test ceph-volume all
jenkins test ceph-volume tox
jenkins test windows