Commit Graph

22 Commits

Author SHA1 Message Date
Michael Stack 1d03904ea3
Revert "Hold `ThreadReturnPromiseStream` reference when sending value/error" (#12050)
We crash with rocksdb storage when bulkloading at scale
with this change in place. Removing for now.

This reverts commit 55edaf5ed1.

Co-authored-by: stack <stack@duboce.com>
2025-03-25 14:55:09 -07:00
Vishesh Yadav bc4dec8e5d Fix use-after-move issue in AsyncTaskExecutor
`getFuture()` should be called before post as `send`/`sendError`
operation in `ThreadReturnPromise` moves the underlying Promise to
`tagAndForward()`.

Ideally, `ThreadReturnPromise` behavior should stay consistent with the
`Promise`. However, the problem is that it relies on the invariant that
there will always be one owner of its internal `Promise` which is either
itself or `tagOrForward`  -- which is necessary to ensure that only one
thread can operate on the Promise's internal state (ref count, flags
etc) and avoid race conditions.

This patch (1) makes sure that in case of `post()` function we get
future before, (2) adds an ASSERT as this should never happen, (3)
documentation for future users and (4) a test case for potentially
fixing this in future.
2025-03-14 14:11:22 -07:00
Vishesh Yadav 55edaf5ed1 Hold `ThreadReturnPromiseStream` reference when sending value/error
When a value/error is sent via `ThreadReturnPromiseStream` we assume that the underlying
`PromiseStream` will be alive when the client waits. However, if the last
`ThreadReturnPromiseStream` gets destroyed after sending values/end_of_stream(), the underlying
`PromiseStream` will as well resulting in `broken_promise`. This happens because the actual work of
sending the value/error is deferred on the main thread.

This is likely to happen because the sender did its work and it isn't supposed to check if client
got the value. Hence, little reason to keep the promise. Meanwhile, client is free to read values
from its future whenever it needs to.

This patch just holds the reference to underlying `NotifiedQueue` by copying `PromiseStream` until
the value/error is sent. The test added would fail without this patch.
2025-03-06 02:00:34 -08:00
Syed Paymaan Raza c3e7542cda Update end year in copyright header 2024-08-02 09:40:11 -07:00
Xiaoge Su c11c48fa3f Extract ChaosMetrics out from network.h 2023-01-24 14:47:48 -08:00
sfc-gh-tclinkenbeard 1aabbb07d2 Add missing copyright headers 2022-03-16 11:25:02 -07:00
Yao Xiao c605226a56
Add error handling in RocksDB KVS. (#6277) 2022-01-25 13:59:25 -08:00
helium f445d94baf Comments resolved. 2021-08-11 17:01:12 -07:00
helium e988ac53d9 clang-format 2021-08-11 16:21:06 -07:00
helium c043b21974 Added test for sending error 2021-08-11 11:37:12 -07:00
helium f8edf6e1f2 Switched to a separate test ThreadPoolReceiver 2021-08-11 10:47:51 -07:00
helium 15d050ece5 Added unit test, and bug fixes. 2021-08-09 16:26:29 -07:00
sfc-gh-tclinkenbeard f4d03562f4 Merge remote-tracking branch 'origin/master' into fix-clang-warnings 2021-07-26 13:38:36 -07:00
Mohamed Oulmahdi c405bb5cd0 Fix flow build issue on Windows 2021-07-23 12:03:25 +02:00
sfc-gh-tclinkenbeard e62e6503ac Fix most delete-non-virtual-dtor clang warnings 2021-07-21 23:32:44 -07:00
Markus Pilman 8f6b048e22 fix macOS build 2021-07-20 11:52:57 -06:00
Daniel Smith acfd0b6c1c Don't check the random number generator state at the end 2021-07-08 19:19:02 -04:00
Daniel Smith 3fbd6b6143 Enable IThreadPool in simulation 2021-07-08 18:51:01 -04:00
Daniel Smith 0df49e1bee
Run IThreadPool naming test outside simulation 2021-06-30 15:06:58 -04:00
Daniel Smith 299eaef858
Update flow/IThreadPoolTest.actor.cpp
Co-authored-by: A.J. Beamon <aj.beamon@snowflake.com>
2021-06-29 16:39:50 -04:00
Daniel Smith ac01e5bcfd
Update flow/IThreadPoolTest.actor.cpp
Co-authored-by: A.J. Beamon <aj.beamon@snowflake.com>
2021-06-29 16:37:06 -04:00
Daniel Smith f58c7fd8bc Fix IThreadPool thread naming 2021-06-29 16:27:37 -04:00