Skip to content

crimson/net: refactors to encapsulate ProtocolV2 message read and write paths and event dispatching - #49420

Merged
cyx1231st merged 35 commits into
ceph:mainfrom
cyx1231st:wip-seastar-msgr-multi-core
Feb 15, 2023
Merged

cyx1231st merged 35 commits into
ceph:mainfrom
cyx1231st:wip-seastar-msgr-multi-core

Conversation

@cyx1231st

@cyx1231st cyx1231st commented Dec 14, 2022 •

Copy link
Copy Markdown
Member

This is an intermediate step towards multi-core messenger. There should be no impact to the msgr users yet.

The goal of this step is about introducing an IOHandler class that is responsible to the executions in ProtocolV2::READY state, as well as event dispatching in all states. Changes are including:

  • Move IO related logic into Protocol and move IO unrelated logic out of Protocol.
  • Clean up and categorize in and out logic in Protocol.
  • Break the inheritance relationship from ProtocolV2 to Protocol.
  • Introduce FrameAssemblerV2 to be shared by both IOHandler and ProtocolV2 for the low level protocol-v2 frame processings, and to be responsible for the Socket ownership.
  • Rename Protocol to IOHandler.
  • Major refactors about how to hand over the READY state from ProtocolV2 to IOHandler, and how IOHandler to notify ProtocolV2 to exit the READY state in various scenarios.
  • Other fixes and cleanups.

The next step(s) will include:

  • Design Socket and ServerSocket to manage seastar sockets in multiple cores.
  • Design Dispatcher interfaces for multi-core event dispatching, especially about how to notify the user about the connection core changes.
  • Further refactor the interactions between IOHandler and ProtocolV2 for the inevitable cross-core communications.
  • How to make the design compatible to both single-shard and multiple-shard use cases.

The basic idea is to:

  • Distribute the messenger IO workload to multiple cores.
  • Make sure the IO core and the socket core are the same for a connection (as the connection core from user perspective), to prevent unnecessary cross-core in the IO path.
  • Hide the user from the complexity that connection handshake may be on a different core.
  • User still needs to call Messenger interfaces from core-0, such as connect().

The architecture now looks:
multi-core msgr

Contribution Guidelines

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

@athanatos athanatos 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.

Looks great! Let's run this through the crimson-rados suite and then merge it assuming that the result seems similar to existing runs (there are some failures in main).

@cyx1231st

Copy link
Copy Markdown
Member Author

@athanatos

Copy link
Copy Markdown
Contributor

Ok, I just scheduled a crimson-rados run on it.

@cyx1231st

Copy link
Copy Markdown
Member Author

The original build was expired.

Just amended the commit message to get a different sha1 for rebuild, but it is broken now: https://shaman.ceph.com/builds/ceph/wip-yingxin-testing-msgr-multi-core-crimson-only/ee2e418e7afae5419f468d3249af77bff4b7bc3b/crimson/328156/

@Matan-B

Matan-B commented Jan 3, 2023 •

Copy link
Copy Markdown
Contributor

The original build was expired.

Just amended the commit message to get a different sha1 for rebuild, but it is broken now: https://shaman.ceph.com/builds/ceph/wip-yingxin-testing-msgr-multi-core-crimson-only/ee2e418e7afae5419f468d3249af77bff4b7bc3b/crimson/328156/

FTBFS because of:

CMake Error at /usr/share/cmake/Modules/FindJava.cmake:171 (message):
  Error executing java -version
Call Stack (most recent call first):
  src/java/CMakeLists.txt:1 (find_package)

which is not related to your changes. (All builds are affected)

@cyx1231st

Copy link
Copy Markdown
Member Author

@Matan-B

Matan-B commented Jan 15, 2023

Copy link
Copy Markdown
Contributor

https://pulpito.ceph.com/sjust-2023-01-13_02:27:49-crimson-rados-wip-yingxin-testing-msgr-multi-core-crimson-only-2-distro-default-smithi/7140360/

cluster [ERR] Unhandled exception from module 'devicehealth' while running on mgr.x: disk I/O error" in cluster log

Might be related to the changes introduced.

@cyx1231st

Copy link
Copy Markdown
Member Author

Attatched the according traceback in the log:

2023-01-13T03:21:25.057 INFO:tasks.ceph.mgr.x.smithi080.stderr:2023-01-13T03:21:25.056+0000 7f11c7dec700 -1 client.4130: SimpleRADOSStriper: lock_keeper_main: main.db: lock renewal failed: (2) No such file or directory
2023-01-13T03:21:25.098 INFO:tasks.ceph.mgr.x.smithi080.stderr:2023-01-13T03:21:25.097+0000 7f11dce16700 -1 log_channel(cluster) log [ERR] : Unhandled exception from module 'devicehealth' while running on mgr.x: disk I/O error
2023-01-13T03:21:25.099 INFO:tasks.ceph.mgr.x.smithi080.stderr:2023-01-13T03:21:25.097+0000 7f11dce16700 -1 devicehealth.serve:
2023-01-13T03:21:25.099 INFO:tasks.ceph.mgr.x.smithi080.stderr:2023-01-13T03:21:25.097+0000 7f11dce16700 -1 Traceback (most recent call last):
2023-01-13T03:21:25.099 INFO:tasks.ceph.mgr.x.smithi080.stderr:  File "/usr/share/ceph/mgr/devicehealth/module.py", line 376, in serve
2023-01-13T03:21:25.100 INFO:tasks.ceph.mgr.x.smithi080.stderr:    self.set_kv('last_scrape', last_scrape.strftime(TIME_FORMAT))
2023-01-13T03:21:25.100 INFO:tasks.ceph.mgr.x.smithi080.stderr:  File "/usr/share/ceph/mgr/mgr_module.py", line 1149, in set_kv
2023-01-13T03:21:25.100 INFO:tasks.ceph.mgr.x.smithi080.stderr:    self.db.execute(SQL, (key, value))
2023-01-13T03:21:25.106 INFO:tasks.ceph.mgr.x.smithi080.stderr:sqlite3.OperationalError: disk I/O error
2023-01-13T03:21:25.107 INFO:tasks.ceph.mgr.x.smithi080.stderr: 

Looks to me it is not related to the messenger changes.

https://pulpito.ceph.com/sjust-2023-01-13_02:27:49-crimson-rados-wip-yingxin-testing-msgr-multi-core-crimson-only-2-distro-default-smithi/7140360/

I have also searched the keywords "error", "warn", "trace" and "stderr" from the log, seems no direct related issues. Not sure if there is a better way to check whether there are regressions?

@Matan-B

Matan-B commented Jan 16, 2023

Copy link
Copy Markdown
Contributor

I have also searched the keywords "error", "warn", "trace" and "stderr" from the log, seems no direct related issues. Not sure if there is a better way to check whether there are regressions?

Perhaps looking at the mgr log itself can provide more information. [1]
Comparing to recent successful similar job can also help. [2]
I will schedule another run (and edit this comment) with this job few times to verify whether we hit this again/consistently.

[1] http://qa-proxy.ceph.com/teuthology/sjust-2023-01-13_02:27:49-crimson-rados-wip-yingxin-testing-msgr-multi-core-crimson-only-2-distro-default-smithi/7140360/remote/smithi080/log/ceph-mgr.x.log.gz
[2] https://pulpito.ceph.com/sjust-2023-01-12_20:57:32-crimson-rados-wip-sjust-testing-2023-01-11-102020-distro-default-smithi/7139330/

@cyx1231st

cyx1231st commented Jan 16, 2023 •

Copy link
Copy Markdown
Member Author

Perhaps looking at the mgr log itself can provide more information. [1]

@Matan-B thanks for the link to the logs!

I checked the mgr log, seems to me there are no further useful logs there.

I also tried to search the big osd log file, looks there is no crash and no error log is related to the messenger.

Comparing to recent successful similar job can also help. [2]
I will schedule another run (and edit this comment) with this job few times to verify whether we hit this again/consistently.

Should I rebase this PR to a more recent main branch first? It is currently based on the main branch on Dec 12.

@Matan-B

Matan-B commented Jan 16, 2023 •

Copy link
Copy Markdown
Contributor

Should I rebase this PR to a more recent main branch first? It is currently based on the main branch on Dec 12.

Yes.
There are issues atm w/ centos 8 builds (Hopefully brief ones). Nethertheless a rebase before rebuilding is a good idea.

@cyx1231st
cyx1231st force-pushed the wip-seastar-msgr-multi-core branch from b197efc to bd33281 Compare January 17, 2023 08:25
@cyx1231st

cyx1231st commented Jan 17, 2023 •

Copy link
Copy Markdown
Member Author

Rebased onto the same base of https://pulpito.ceph.com/sjust-2023-01-12_20:57:32-crimson-rados-wip-sjust-testing-2023-01-11-102020-distro-default-smithi/7139330/ for better cross-checking.

@Matan-B

Matan-B commented Jan 24, 2023 •

Copy link
Copy Markdown
Contributor

Rebased onto the same base of https://pulpito.ceph.com/sjust-2023-01-12_20:57:32-crimson-rados-wip-sjust-testing-2023-01-11-102020-distro-default-smithi/7139330/ for better cross-checking.

There were a few errors while building the branch because of newer fmt version used.
I tried cherry-picking #49768 and adding to io_handler.h:

+#if FMT_VERSION >= 9000
+template <> struct fmt::formatter<crimson::net::IOHandler::io_stat_printer> : fmt::ostream_formatter {};
+#endif

However, additional changes are required to compile successfully.
https://shaman.ceph.com/builds/ceph/wip-seastar-msgr-multi-core-testing/ee031b18244275d0b7864013de3538d64a1a93e4/crimson/330607/

@cyx1231st

Copy link
Copy Markdown
Member Author

There were a few errors while building the branch because of newer fmt version used.

Thanks Matan! I'm working on the fixes to build this PR.

@cyx1231st
cyx1231st force-pushed the wip-seastar-msgr-multi-core branch from 4ee165c to f43f3d3 Compare February 7, 2023 04:57
@cyx1231st

Copy link
Copy Markdown
Member Author

The build issue is fixed in f43f3d3, and the base commit is unchanged.

@Matan-B The build now looks good at https://shaman.ceph.com/builds/ceph/wip-yingxin-testing-msgr-multi-core-crimson-only-5/f43f3d3c951bc8a7b8628ae54c70cca88353aec9/crimson/332056/

@Matan-B

Matan-B commented Feb 7, 2023 •

Copy link
Copy Markdown
Contributor

@athanatos

Copy link
Copy Markdown
Contributor

Oh, let's rebase this on main. I merged a fix for the ooo bug #49935

IOHandler also represents the Connection as ConnectionHandler.

ProtocolV2 and IOHandler will be finally running in different cores, as
ProtocolV2 will need to call IOHandler interfaces asynchronously. And
IOHandler will also notify ProtocolV2 through HandshakeListener
asynchronously.

Signed-off-by: Yingxin Cheng <[email protected]>
__func__ is meaningless in the lambda function with continuations.

Signed-off-by: Yingxin Cheng <[email protected]>
@cyx1231st
cyx1231st force-pushed the wip-seastar-msgr-multi-core branch from f43f3d3 to 1bc5827 Compare February 8, 2023 09:53
@cyx1231st

Copy link
Copy Markdown
Member Author

@Matan-B

Matan-B commented Feb 8, 2023 •

Copy link
Copy Markdown
Contributor

Rebased onto the latest main, and the build is successful at https://shaman.ceph.com/builds/ceph/wip-yingxin-testing-msgr-multi-core-crimson-only-6/

https://pulpito.ceph.com/matan-2023-02-08_09:57:18-crimson-rados-wip-yingxin-testing-msgr-multi-core-crimson-only-6-distro-crimson-smithi/

@cyx1231st There were some lab outages, I will schedule a new run once it's up again. (You can join the slack channel for updates)

@cyx1231st

Copy link
Copy Markdown
Member Author

@cyx1231st

Copy link
Copy Markdown
Member Author

jenkins test make check

@Matan-B

Matan-B commented Feb 9, 2023

Copy link
Copy Markdown
Contributor

@cyx1231st

Copy link
Copy Markdown
Member Author

jenkins test make check

@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.

Test results LGTM

@Matan-B

Matan-B commented Feb 9, 2023

Copy link
Copy Markdown
Contributor

Unfortunately I stumbled upon this failure while testing other PRs (with this one included) :

DEBUG 2023-02-09 18:18:04,340 [shard 0] osd - send_alive want=12 <= up_thru_wanted=12; skipping
WARN  2023-02-09 18:18:04,340 [shard 0] ms - [0x611000075c00 osd.0(cluster) v2:172.21.15.45:6801/104333 >> osd.2 v2:172.21.15.154:6800/103981@58315] server_connect: connection race detected (cs=5384176050906078089, e_cs=2371520450440684931, ss=0) and win, reusing existing CONNECTING [0x611000079080 osd.0(cluster) v2:172.21.15.45:6801/104333 >> osd.? v2:172.21.15.154:6800/103981]
ERROR 2023-02-09 18:18:04,340 [shard 0] none - /home/jenkins-build/build/workspace/ceph-dev-new-build/ARCH/x86_64/AVAILABLE_ARCH/x86_64/AVAILABLE_DIST/centos8/DIST/centos8/MACHINE_SIZE/gigantic/release/18.0.0-2195-gffb68840/rpm/el8/BUILD/ceph-18.0.0-2195-gffb68840/src/crimson/net/ProtocolV2.cc:1691 : In function 'void crimson::net::ProtocolV2::trigger_replacing(bool, bool, crimson::net::FrameAssemblerV2::mover_t&&, crimson::net::ProtocolV2::AuthConnectionMetaRef&&, uint64_t, uint64_t, entity_name_t, uint64_t, uint64_t, uint64_t, uint64_t)', ceph_assert(%s)
has_socket
Aborting on shard 0.
..
 1# abort in /lib64/libc.so.6
 2# ceph::__ceph_assert_fail(char const*, char const*, int, char const*) in ceph-osd
 3# crimson::net::ProtocolV2::trigger_replacing(bool, bool, crimson::net::FrameAssemblerV2::mover_t&&, seastar::lw_shared_ptr<AuthConnectionMeta>&&, unsigned long, unsigned long, entity_name_t, unsigned long, unsigned long, unsigned long, unsigned long) in ceph-osd
 4# crimson::net::ProtocolV2::reuse_connection(crimson::net::ProtocolV2*, bool, bool, unsigned long, unsigned long) in ceph-osd
 5# crimson::net::ProtocolV2::handle_existing_connection(seastar::shared_ptr<crimson::net::SocketConnection>) in ceph-osd

https://pulpito.ceph.com/matan-2023-02-09_17:49:18-crimson-rados-wip-matanb-crimson-testing-9.2-distro-crimson-smithi/7164131/

@cyx1231st

Copy link
Copy Markdown
Member Author

Thanks Matan! I have a clue about this issue, will dig into the log to confirm.

@athanatos

Copy link
Copy Markdown
Contributor

@cyx1231st

Copy link
Copy Markdown
Member Author

Thanks Sam! The issue is a corner case that hasn't been coverred by the msgr UT.

I prefer to fix it in this PR (should be soon) so we don't need to worry about the main branch.

Consolidate the name/port/nonce of the addresses used in the messenger
unit tests.

Signed-off-by: Yingxin Cheng <[email protected]>
* add blockings at custom_bp_t::SOCKET_CONNECTING
* adjust peer_wins to true

Signed-off-by: Yingxin Cheng <[email protected]>
@cyx1231st

Copy link
Copy Markdown
Member Author

changeset: appended 4 commits.

The issue should be reproduced after commit "test/crimson: improve messenger test coverage", and be fixed in the last commit "crimson/net: fix the corner case when the replacing connection doesn't have socket".

I will go forward to test it again in sepia.

@cyx1231st

Copy link
Copy Markdown
Member Author

@athanatos athanatos 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!

@Matan-B

Matan-B commented Feb 14, 2023

Copy link
Copy Markdown
Contributor

LGTM

@cyx1231st
cyx1231st merged commit 3d8b913 into ceph:main Feb 15, 2023
@cyx1231st
cyx1231st deleted the wip-seastar-msgr-multi-core branch February 15, 2023 01:13
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