Skip to content

librados/asio: forward asio cancellations to AioCompletion::cancel() - #60379

Merged
cbodley merged 5 commits into
ceph:mainfrom
cbodley:wip-librados-cancellation
Jan 8, 2025
Merged

cbodley merged 5 commits into
ceph:mainfrom
cbodley:wip-librados-cancellation

Conversation

@cbodley

@cbodley cbodley commented Oct 17, 2024 •

Copy link
Copy Markdown
Contributor

librados::AioCompletion::cancel() calls Objecter::op_cancel() to cancel the operation. this is thread-safe, and does nothing if the op already completed

the asio interfaces in librados/librados_asio.h hook this up to asio's per-op cancellation support

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 added the core label Oct 17, 2024

@adamemerson adamemerson 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 good so far.

@cbodley
cbodley force-pushed the wip-librados-cancellation branch from 05b6626 to b4eead4 Compare October 18, 2024 02:03
@cbodley
cbodley marked this pull request as ready for review October 18, 2024 02:04
@cbodley
cbodley requested a review from a team as a code owner October 18, 2024 02:04
@cbodley
cbodley force-pushed the wip-librados-cancellation branch from b4eead4 to ede956e Compare October 18, 2024 02:07
@cbodley
cbodley requested review from a team October 18, 2024 02:09
@cbodley

cbodley commented Oct 18, 2024

Copy link
Copy Markdown
Contributor Author

https://jenkins.ceph.com/job/ceph-windows-pull-requests/48527/

/home/ubuntu/ceph/src/test/librados/asio.cc:412:11: error: no member named 'WSAPoll' in 'boost::asio::io_context'
  service.poll();
  ~~~~~~~ ^
/home/ubuntu/ceph/src/include/win32/winsock_compat.h:21:14: note: expanded from macro 'poll'
#define poll WSAPoll
             ^

looks like some windows macros are coming from include/compat.h -> include/win32/winsock_compat.h. any suggestions here @petrutlucian94?

Comment thread PendingReleaseNotes Resolved
Comment thread src/librados/librados_cxx.cc Resolved
Comment thread src/test/librados/aio_cxx.cc Resolved
@cbodley
cbodley force-pushed the wip-librados-cancellation branch from ede956e to a362947 Compare October 21, 2024 14:18
@cbodley cbodley changed the title librados: expose op cancellation through AioCompletion::cancel() librados/asio: forward asio cancellations to IoCtx::aio_cancel() Oct 21, 2024
Comment thread src/librados/librados_asio.h Resolved
Comment thread src/test/librados/aio.cc Resolved
Comment thread src/test/librados/aio_cxx.cc Resolved
Comment thread src/test/librados/aio_cxx.cc Resolved
@cbodley
cbodley force-pushed the wip-librados-cancellation branch from 60a9a77 to 56d345a Compare October 23, 2024 13:40
@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

@cbodley
cbodley force-pushed the wip-librados-cancellation branch from 56d345a to 75e70e1 Compare October 23, 2024 13:46
@cbodley
cbodley force-pushed the wip-librados-cancellation branch from 75e70e1 to 3185b11 Compare October 23, 2024 17:16
@petrutlucian94

Copy link
Copy Markdown
Contributor

looks like some windows macros are coming from include/compat.h -> include/win32/winsock_compat.h. any suggestions here @petrutlucian94?

I guess the undef is ok for the time being. The alternative would be to drop the macro and define a simple wrapper function instead.

@cbodley

cbodley commented Oct 24, 2024

Copy link
Copy Markdown
Contributor Author

looks like some windows macros are coming from include/compat.h -> include/win32/winsock_compat.h. any suggestions here @petrutlucian94?

I guess the undef is ok for the time being. The alternative would be to drop the macro and define a simple wrapper function instead.

thanks @petrutlucian94. the windows check now fails on ceph_test_rados_api_asio, but i don't know how to debug further

@petrutlucian94

Copy link
Copy Markdown
Contributor

@petrutlucian94

Copy link
Copy Markdown
Contributor

Here's a trace of the test that crashes (AsioRados.AsyncReadOperationCancelTerminal):

Thread 1 received signal SIGILL, Illegal instruction.
do_complete ()
    at /mnt/data/workspace/ceph_win_latest/build.deps/mingw/boost/include/boost/asio/detail/executor_op.hpp:70
70            static_cast<Handler&&>(handler)();
              ^
(gdb) bt
#0  do_complete ()
    at /mnt/data/workspace/ceph_win_latest/build.deps/mingw/boost/include/boost/asio/detail/executor_op.hpp:70
#1  0x00007ff6962839ed in complete ()
    at /mnt/data/workspace/ceph_win_latest/build.deps/mingw/boost/include/boost/asio/detail/win_iocp_operation.hpp:47
#2  do_one ()
    at /mnt/data/workspace/ceph_win_latest/build.deps/mingw/boost/include/boost/asio/detail/impl/win_iocp_io_context.ipp:475
#3  0x00007ff696283383 in run ()
    at /mnt/data/workspace/ceph_win_latest/build.deps/mingw/boost/include/boost/asio/detail/impl/win_iocp_io_context.ipp:206
#4  0x00007ff69627f829 in run ()
    at /mnt/data/workspace/ceph_win_latest/build.deps/mingw/boost/include/boost/asio/impl/io_context.ipp:64
#5  0x00007ff6962659b3 in TestBody () at /mnt/data/workspace/ceph_win_latest/src/test/librados/asio.cc:427
#6  0x00007ff6962dd8da in HandleSehExceptionsInMethodIfSupported<testing::Test, void> ()
    at /mnt/data/workspace/ceph_win_latest/src/googletest/googletest/src/gtest.cc:2605
#7  HandleExceptionsInMethodIfSupported<testing::Test, void> ()
    at /mnt/data/workspace/ceph_win_latest/src/googletest/googletest/src/gtest.cc:2641
#8  0x00007ff6962b6c05 in Run () at /mnt/data/workspace/ceph_win_latest/src/googletest/googletest/src/gtest.cc:2680
#9  0x00007ff6962b8644 in Run () at /mnt/data/workspace/ceph_win_latest/src/googletest/googletest/src/gtest.cc:2858
#10 0x00007ff6962b9152 in Run () at /mnt/data/workspace/ceph_win_latest/src/googletest/googletest/src/gtest.cc:3012
#11 0x00007ff6962c9cf0 in RunAllTests ()
    at /mnt/data/workspace/ceph_win_latest/src/googletest/googletest/src/gtest.cc:5723
#12 0x00007ff6962de89a in HandleSehExceptionsInMethodIfSupported<testing::internal::UnitTestImpl, bool> ()
    at /mnt/data/workspace/ceph_win_latest/src/googletest/googletest/src/gtest.cc:2605
#13 HandleExceptionsInMethodIfSupported<testing::internal::UnitTestImpl, bool> ()
    at /mnt/data/workspace/ceph_win_latest/src/googletest/googletest/src/gtest.cc:2641
#14 0x00007ff6962c94aa in Run () at /mnt/data/workspace/ceph_win_latest/src/googletest/googletest/src/gtest.cc:5306
#15 0x00007ff696267c70 in RUN_ALL_TESTS ()
    at /mnt/data/workspace/ceph_win_latest/src/googletest/googletest/include/gtest/gtest.h:2486
#16 main () at /mnt/data/workspace/ceph_win_latest/src/test/librados/asio.cc:525
#17 0x00007ff696261315 in __tmainCRTStartup () at ../crt/crtexe.c:272
#18 0x00007ff696261366 in mainCRTStartup () at ../crt/crtexe.c:193

@cbodley
cbodley force-pushed the wip-librados-cancellation branch from 3185b11 to f11d704 Compare October 30, 2024 14:09
@cbodley

cbodley commented Oct 30, 2024

Copy link
Copy Markdown
Contributor Author

Thread 1 received signal SIGILL, Illegal instruction.

i don't know what to make of this. i've disabled these new tests on windows

@cbodley

cbodley commented Oct 30, 2024

Copy link
Copy Markdown
Contributor Author

https://jenkins.ceph.com/job/ceph-windows-pull-requests/49129/

+ echo 'Downloading VM image from https://cloud-images.ubuntu.com/minimal/releases/jammy/release/ubuntu-22.04-minimal-cloudimg-amd64.img'
Downloading VM image from https://cloud-images.ubuntu.com/minimal/releases/jammy/release/ubuntu-22.04-minimal-cloudimg-amd64.img
+ curl -s -L https://cloud-images.ubuntu.com/minimal/releases/jammy/release/ubuntu-22.04-minimal-cloudimg-amd64.img -o /home/jenkins-build/build/workspace/ceph-windows-pull-requests/libvirt/ceph-ubuntu-vstart.qcow2
Build step 'Execute shell' marked build as failure

does that mean the download failed?

@cbodley cbodley changed the title librados/asio: forward asio cancellations to IoCtx::aio_cancel() librados/asio: forward asio cancellations to AioCompletion::cancel() Nov 12, 2024
Comment thread src/librados/librados_asio.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.

Would it make sense to pass this by value rather than by reference? That way it would be explicit that we are doing a copy. (And they can std::move if they want to avoid 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.

thanks @adamemerson. there was an intermediate version of this PR that had to stash a copy of the IoCtx in order to call ioctx.aio_cancel(), but the current version relies on the new AioCompletion::cancel() to avoid copies altogether

i do have a related pr #60576 that does need to copy this IoCtx argument when the completion token is deferred or use_awaitable, because their calls to ioctx.aio_operate() may happen in a different scope

and while there are cases like rgw::Aio that do extra work to manage the IoCtx's lifetime, the vast majority of rgw's uses go through rgw_rados_operate() which doesn't - we're either blocking on a synchronous call to ioctx.operate() or suspending a stackful coroutine until librados::async_operate()'s completion, both of which can safely refer to an IoCtx on the stack

so i think it's best for these asio wrappers to leave lifetime management to the callers the same way librados' aio functions do

@cbodley

cbodley commented Nov 13, 2024

Copy link
Copy Markdown
Contributor Author

jenkins retest this please

@cbodley

cbodley commented Nov 13, 2024

Copy link
Copy Markdown
Contributor Author

@cbodley

cbodley commented Nov 13, 2024

Copy link
Copy Markdown
Contributor Author

jenkins test make check

Comment thread src/librados/librados_cxx.cc Resolved
Comment thread src/librados/librados_cxx.cc Resolved
Comment thread src/include/rados/librados.hpp Resolved
Comment thread src/include/rados/librados.hpp Resolved
Comment thread src/include/rados/librados.hpp Resolved
Comment thread src/include/rados/librados.hpp Resolved
Comment thread src/include/rados/librados.hpp Resolved
Comment thread src/include/rados/librados.hpp Resolved
Comment thread src/test/librados/aio_cxx.cc Resolved
Comment thread src/test/librados/aio.cc Resolved
Comment thread src/test/librados/aio_cxx.cc Resolved
Comment thread src/test/librados/aio_cxx.cc Resolved
Comment thread src/test/librados/aio_cxx.cc Resolved
Comment thread src/test/librados/aio.cc Resolved
Comment thread src/test/librados/aio.cc Resolved
Comment thread src/test/librados/aio_cxx.cc Resolved
Comment thread src/test/librados/aio_cxx.cc Resolved
Comment thread src/test/librados/asio.cc Resolved
Comment thread src/test/librados/asio.cc Resolved
Comment thread src/test/librados/asio.cc Resolved
Comment thread src/librados/librados_asio.h Resolved
Comment thread src/test/librados/aio_cxx.cc Resolved
if the completion handler has a cancellation slot connected, construct a
cancellation handler for it that calls AioCompletion::cancel()

read operations can support more cancellation types than writes. see the
table of cancellation types and their associated requirements/guarantees:

https://www.boost.org/doc/libs/1_85_0/doc/html/boost_asio/overview/core/cancellation.html#boost_asio.overview.core.cancellation.t0

Signed-off-by: Casey Bodley <[email protected]>
@cbodley

cbodley commented Dec 6, 2024

Copy link
Copy Markdown
Contributor Author

jenkins test make check

@cbodley

cbodley commented Dec 6, 2024

Copy link
Copy Markdown
Contributor Author

jenkins test api

@cbodley

cbodley commented Dec 9, 2024

Copy link
Copy Markdown
Contributor Author

@cbodley

cbodley commented Dec 9, 2024

Copy link
Copy Markdown
Contributor Author

jenkins test make check

@cbodley

cbodley commented Dec 9, 2024

Copy link
Copy Markdown
Contributor Author

@amathuria

Copy link
Copy Markdown
Contributor

@cbodley

cbodley commented Jan 7, 2025

Copy link
Copy Markdown
Contributor Author

jenkins test make check

@cbodley

cbodley commented Jan 7, 2025

Copy link
Copy Markdown
Contributor Author

@cbodley

cbodley commented Jan 7, 2025

Copy link
Copy Markdown
Contributor Author

jenkins test make check

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.

6 participants