Fix race on Context::async_insert_queue#59082
Conversation
|
This is an automated comment for commit d190ee8 with description of existing statuses. It's updated for the latest CI running ❌ Click here to open a full report in a separate page
Successful checks
|
jkartseva
left a comment
There was a problem hiding this comment.
This has caught my attention as I've been working on the asynchronous queue in #58486
Looks good to me, thanks for the fix!
Just curious, have you considered using std::atomic<std::shared_ptr> instead of locking the mutex?
|
Why doesn't it have a |
Because it's nearly impossible to provide a user-readable changelog entry for this fix |
AFAIK there's a spinlock inside atomic shared pointer, so there's no big difference. Also, we use this mutex to protect other fields of |
src/Interpreters/Context.cpp
Outdated
| std::shared_ptr<AsynchronousInsertQueue> delete_async_insert_queue; | ||
| { | ||
| std::lock_guard lock(mutex); | ||
| delete_async_insert_queue = std::move(async_insert_queue); | ||
| } | ||
| delete_async_insert_queue.reset(); |
There was a problem hiding this comment.
Hm, and this is also wrong because other threads still can get a raw pointer from getAsynchronousInsertQueue() and continue using it after reset()
c04fecb to
1913466
Compare
| } | ||
|
|
||
| AsynchronousInsertQueue::~AsynchronousInsertQueue() | ||
| void AsynchronousInsertQueue::flushAndShutdown() |
There was a problem hiding this comment.
Please comment that an external entity (Context) is responsible for flushing the queue since it's not happening in the destructor anymore.
|
AST fuzzer (msan) - #61771 |
Changelog category (leave one):
https://s3.amazonaws.com/clickhouse-test-reports/39507/fe1e326701b0566881dc7d51793125a911faa07e/integration_tests__tsan__[4_6].html
Introduced in #53547