Skip to content

crimson: use gate per shard for AlienStore and OSD - #58986

Merged
Matan-B merged 4 commits into
ceph:mainfrom
NitzanMordhai:wip-nitzan-crimson-op_gate-alianstore-multi-core
Sep 10, 2024
Merged

Matan-B merged 4 commits into
ceph:mainfrom
NitzanMordhai:wip-nitzan-crimson-op_gate-alianstore-multi-core

Conversation

@NitzanMordhai

@NitzanMordhai NitzanMordhai commented Aug 1, 2024 •

Copy link
Copy Markdown
Contributor

This change modifies AlienStore and OSD to use a gate per seastar
shard instead of a shared gate.
It introduces a new gate_per_shard class in Gated to manage
a vector of gates, ensuring proper gate handling across shards.

Fixes: https://tracker.ceph.com/issues/64332
Signed-off-by: NitzanMordhai [email protected]

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. "quincy"), please refer to Submitting Patches to Ceph - Backports for the proper workflow.

  • When filling out the below checklist, you may click boxes directly in the GitHub web UI. When entering or editing the entire PR message in the GitHub web UI editor, you may also select a checklist item by adding an x between the brackets: [x]. Spaces and capitalization matter when checking off items this way.

Checklist

  • Tracker (select at least one)
    • References tracker ticket
    • Very recent bug; references commit where it was introduced
    • New feature (ticket optional)
    • Doc update (no ticket needed)
    • Code cleanup (no ticket needed)
  • Component impact
    • Affects Dashboard, opened tracker ticket
    • Affects Orchestrator, opened tracker ticket
    • No impact that needs to be tracked
  • Documentation (select at least one)
    • Updates relevant documentation
    • No doc update is appropriate
  • Tests (select at least one)
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
  • jenkins test rook e2e

@github-actions

github-actions Bot commented Aug 1, 2024

Copy link
Copy Markdown

This pull request can no longer be automatically merged: a rebase is needed and changes have to be manually resolved

Comment thread src/crimson/osd/osd.h Resolved
Comment thread src/crimson/common/gated.h Resolved
Comment thread src/crimson/common/gated.h Resolved
Comment thread src/crimson/common/gated.h Resolved
Comment thread src/crimson/common/gated.h Resolved
Comment thread src/crimson/common/gated.h Resolved
Comment thread src/crimson/common/gated.h Outdated

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

The gate needs to be closed in the specific shard where it is used, otherwise the same old issue could happen, right?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

I don't think so, as soon as you created the gate, you need to close it anyway, you can't close it more then one time, but you have to close it so the gate and holder will be destroyed later on and the debug gated will work and count the gates

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Yeah, the gates need to be closed.

I meant the specific gate should be closed in the shard where it is used in dispatch(). For example, gates[4] is used in shard 4, so it should be closed also in shard 4, because close() will access the internal _count which shouldn't be safe from a different shard.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

@cyx1231st we will close the gates only when osd is prepared to stop, so the gates remain open, then we are closing all the gates, for each shard we will call its close. is that what you mean? or I'm missing your point?

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Correct, inside parallel_for_each(), refer to seastar::smp::submit_to(core, fn) about how to run logic in a specific shard.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

@Matan-B now it is. took me some time to get it

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Correct, inside parallel_for_each(), refer to seastar::smp::submit_to(core, fn) about how to run logic in a specific shard.

@cyx1231st please let me know if that's what you meant (I changed close_all)

@Matan-B Matan-B Aug 15, 2024 •

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

I think that you got it right with submit_to usage in close_all. Why did you drop parallel_for_each usage?

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

In case the reason was to use the index of the loop as shard id, we can introduce get_shard_id() for Gated.

@cyx1231st cyx1231st Aug 16, 2024 •

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

@NitzanMordhai Yes, looks good to me now. Feel free to reach me (Yingxin) in slack if my comment isn't clear in the future.

Regarding to parallel_for_each, and to make code cleaner, probably the following seastar document is useful:

/// \note parallel_for_each() schedules all invocations of \c func on the
///       current shard. If you want to run a function on all shards in parallel,
///       have a look at \ref smp::invoke_on_all() instead.

@NitzanMordhai
NitzanMordhai force-pushed the wip-nitzan-crimson-op_gate-alianstore-multi-core branch 2 times, most recently from c0c2021 to 3842333 Compare August 12, 2024 06:05
Comment thread src/crimson/common/gated.h Resolved

@cyx1231st cyx1231st left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Approve except for the comments.

@github-actions

Copy link
Copy Markdown

This pull request can no longer be automatically merged: a rebase is needed and changes have to be manually resolved

@Matan-B Matan-B left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

lgtm! Last comments. Seastar submodule should be rebased

Comment thread src/crimson/common/gated.h Resolved
Comment thread src/crimson/common/gated.h Outdated
Comment on lines 70 to 73

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

I think we can remove set_shard_id and set the shard_id only in the ctor

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

we are setting it during the ctor of gate_per_shard:
gate_per_shard() : gates(seastar::smp::count) {
for (unsigned shard = 0; shard < seastar::smp::count; ++shard) {
gates[shard].set_shard_id(shard);
}
}

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

I meant that this should not compile now as sid is const.

Comment thread src/crimson/common/gated.h Outdated

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

assert(seastar::this_shard_id() == sid);

Shard id is printed in each log line, we can simply mention "closing gate" after the assert above.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

done

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

I can't find the assertion in the new commit.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

@cyx1231st asserting during close will cause some issues with io_handle, we are doing close of prev sid (cleanup_prv_shard) and trying to close the gate on a different shard it was created on. checking that

@cyx1231st cyx1231st Aug 28, 2024 •

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

@cyx1231st do you have any opinion on io_handler, do you think it should be changed as well to use gate_per_shard?
it should run on each core, but currently using single gate

I think not, io_handler can only run on a single core (it is owned by Connection living on one core as well). However, it (as well as Connection) may switch cores due to connection recovery (which is a complicated mechanism).

Probably there were some unexpected issues revealed by adding Gated::sid asserts in this PR. But I believe it shouldn't use gate_per_shard for the reasons.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

See IOHandler::cleanup_prv_shard(prv_sid):

return seastar::smp::submit_to(prv_sid, [this] {
logger().debug("{} got cleanup_prv_shard()", conn);
assert(maybe_prv_shard_states != nullptr);
auto ref_prv_states = std::move(maybe_prv_shard_states);
auto &prv_states = *ref_prv_states;
return prv_states.close(
).then([ref_prv_states=std::move(ref_prv_states)] {
ceph_assert_always(ref_prv_states->assert_closed_and_exit());
});

Looks to me this part is correct, because the logic is submitted to prv_sid in calling prv_states.close(), and prv_states (containing the gate) is destructed inside prv_sid as well.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

However, it seems to be an issue when switch to a new core

shard_states = shard_states_t::create_from_previous(
*maybe_prv_shard_states, new_sid);

^ The new shard_states (and shard_states_t::gate) isn't created by the new shard new_sid where it will be used.


A potential fix might be introducing another constructor for Gated to specify sid where it will be used, so that:

shard_states_t(seastar::shard_id _sid, io_state_t state)
: sid{_sid}, io_state{state} {}

can be modified as:

shard_states_t(seastar::shard_id _sid, io_state_t state)
  : sid{_sid}, io_state{state}, gate{_sid} {}  // allow gate to be constructed by one sid, and used by another sid

If this looks reasonable, can you have a try to see whether it works?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

@cyx1231st that will work, thanks!

Comment thread src/crimson/common/gated.h Resolved

@Matan-B Matan-B left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

wip-nitzan-seastar-enable-gate-debug branch should be rebased

Comment thread src/crimson/common/gated.h Outdated
Comment on lines 70 to 73

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

I meant that this should not compile now as sid is const.

Comment thread src/crimson/common/gated.h Resolved
@NitzanMordhai

Copy link
Copy Markdown
Contributor Author

@cyx1231st do you have any opinion on io_handler, do you think it should be changed as well to use gate_per_shard?
it should run on each core, but currently using single gate

@Matan-B

Matan-B commented Aug 27, 2024

Copy link
Copy Markdown
Contributor

The commit that made the change in seastar submodule was removed

Comment thread src/crimson/common/gated.h Outdated

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Nit, seems smp::invoke_on_all() is a better choice in this case. Up to you, though.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

@cyx1231st if i'm using smp::invoke_on_all i'll need to loop over all the gates vector to find the one with the same shard_id and for that only to call the close, unlike the parallel for each and submit_to

@Matan-B Matan-B left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Allowing to construct gates from shards different from the ones they are being used on can open a "gate" for more unexpectancies. I would suggest to assert the this_shard is same as sid in all of the relevant methods.

Moreover, this should also be a separate commit as it's not related to gate_per_shard, and is only a side effect of the added assertion, right?

Note that makecheck fails due to the new submodule branch not pushed to remote.

Comment thread src/crimson/net/io_handler.h Resolved
Comment thread src/seastar Resolved
@NitzanMordhai

Copy link
Copy Markdown
Contributor Author

I commented few of the new ceph_assert that check for shard id and added https://tracker.ceph.com/issues/67773
since this is out of the scope for that PR

This change modifies AlienStore and OSD to use a gate per seastar
shard instead of a shared gate.
It introduces a new `gate_per_shard` class in `Gated` to manage
a vector of gates, ensuring proper gate handling across shards.

Fixes: https://tracker.ceph.com/issues/64332
Signed-off-by: NitzanMordhai <[email protected]>

@Matan-B Matan-B left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

@cyx1231st, can you take a final look at the last commit?

Comment thread src/crimson/common/gated.h Outdated

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Is io_handler still related to this violation?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

@cyx1231st Yes, but I'm not sure if it's the only one, I ran some local tests and found out it failed for io_handler, but it can be in other cases, that's the reason I opened a new tracker and commented those added asserts

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

OK, please let me know if io_handler still breaks after 4f77386

Comment thread src/crimson/common/gated.h Resolved
@cyx1231st

Copy link
Copy Markdown
Member

jenkins test signed

@cyx1231st

Copy link
Copy Markdown
Member

jenkins test api

IOHandler::to_new_sid provides a mechanism to switch to a new core from the current one used.
This behavior is tricky for making sure that we keep the IOHandler::shard_states_t::gate instance to be used on the same core that it was created.
In order to resolve this, we should be able to construct Gated out of specified core_id (and not from this_shard_id).

See: ceph#58986 (comment)

Signed-off-by: NitzanMordhai <[email protected]>
After adding sid (shard ID) to Gated, each shard should have its own gate.
However, some users of Gated had a single instance, which either failed
these assertions or created the Gated object on the wrong shard.
A tracker issue ceph#67773 was opened for this, and this commit comments out
the assertions until the issue is resolved.

Signed-off-by: NitzanMordhai <[email protected]>
@NitzanMordhai

Copy link
Copy Markdown
Contributor Author

@Matan-B tests suite: https://pulpito.ceph.com/nmordech-2024-09-09_04:25:13-crimson-rados-wip-nitzan-crimson-op_gate-alianstore-multi-core-distro-crimson-smithi/

2 unrelated issues:
7895936 - RadosModel failed with ops (testing issue)
7895949 - Assertion `_instances.empty()' failed

@Matan-B

Matan-B commented Sep 9, 2024

Copy link
Copy Markdown
Contributor

@Matan-B tests suite: https://pulpito.ceph.com/nmordech-2024-09-09_04:25:13-crimson-rados-wip-nitzan-crimson-op_gate-alianstore-multi-core-distro-crimson-smithi/

2 unrelated issues: 7895936 - RadosModel failed with ops (testing issue) 7895949 - Assertion `_instances.empty()' failed

Can you please reference the trackers next time if the issues are known? Thanks!

7895949 - https://tracker.ceph.com/issues/67568

What does testing issue mean? The crash looks meaningful:

2024-09-09T04:55:49.581 INFO:tasks.rados.rados.0.smithi019.stderr:../src/test/osd/RadosModel.h: 1648: FAILED ceph_assert(omap.size() == old_value.attrs.size())

@NitzanMordhai

Copy link
Copy Markdown
Contributor Author

@Matan-B I re-run the suite, and the assertion in RadosModel didn't happen again, I ran it against main as well, and it didn't appear there either.
i ran the failing job 15 times - nothing related to that assertion (https://pulpito.ceph.com/nmordech-2024-09-09_12:02:55-crimson-rados:thrash-wip-nitzan-crimson-op_gate-alianstore-multi-core-distro-crimson-smithi/)
I ran it 15 times against the failing job on main and nothing appear as well (https://pulpito.ceph.com/nmordech-2024-09-09_12:02:31-crimson-rados:thrash-main-distro-crimson-smithi/)

@NitzanMordhai

Copy link
Copy Markdown
Contributor Author

@Matan-B

Matan-B commented Sep 10, 2024

Copy link
Copy Markdown
Contributor

Thank you for the additional check! Merging

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.

3 participants