github-actions[bot] commented on code in PR #68145:
URL: https://github.com/apache/doris/pull/68145#discussion_r4039674696
##########
cloud/test/util_test.cpp:
##########
@@ -141,44 +140,49 @@ TEST(UtilTest, stage_wrapper) {
ASSERT_EQ(0, f());
}
+template <typename T>
+void test_cancel_after_tasks_started(T normal_value, T cancel_value,
+ std::function<bool(const T&)> is_cancel) {
+ auto pool = std::make_shared<SimpleThreadPool>(3);
+ pool->start();
+
+ bthread::CountdownEvent normal_tasks_started(2);
+ bthread::CountdownEvent cancellation_observed(1);
+ SyncExecutor<T> sync_executor(pool, "cancel after tasks started",
[&](const T& value) {
+ bool cancelled = is_cancel(value);
+ if (cancelled) {
+ cancellation_observed.signal();
+ }
+ return cancelled;
+ });
+
+ auto normal_task = [&, normal_value]() {
+ normal_tasks_started.signal();
Review Comment:
[P2] Avoid sharing this CountdownEvent between waiters
Both copies of `normal_task` can execute this `wait()` concurrently (the
start gate is designed to get both callbacks this far). In the pinned brpc
1.4.0 implementation, every
[`CountdownEvent::wait()`](https://github.com/apache/brpc/blob/1.4.0/src/bthread/countdown_event.cpp#L51-L63)
writes the non-atomic
[`_wait_was_invoked`](https://github.com/apache/brpc/blob/1.4.0/src/bthread/countdown_event.h#L50-L53)
member, so these two calls race with each other. This makes the new
deterministic test undefined under the C++ memory model and can trip race
detectors. Please give each normal callback its own release event (or use a
primitive that supports multiple waiters) while retaining the two-count start
gate.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]