Commit d96436c9 authored by Vladislav Vaintroub's avatar Vladislav Vaintroub

MDEV-28935 crash in io_slots::release

Revert "TSAN: data race on vptr (ctor/dtor vs virtual call)"

This reverts commit 78084fa7.

This commit was done to please TSAN, which falsely reported an error
where there was none.
Yet as consequence, it could cause a real error, a crash in os_aio_free on
shutdown
parent f2f18e20
......@@ -79,7 +79,6 @@ Created 10/21/1995 Heikki Tuuri
#include <thread>
#include <chrono>
#include <memory>
/* Per-IO operation environment*/
class io_slots
......@@ -133,8 +132,8 @@ class io_slots
}
};
static std::unique_ptr<io_slots> read_slots;
static std::unique_ptr<io_slots> write_slots;
static io_slots *read_slots;
static io_slots *write_slots;
/** Number of retries for partial I/O's */
constexpr ulint NUM_RETRIES_ON_PARTIAL_IO = 10;
......@@ -3675,10 +3674,6 @@ int os_aio_init()
int max_read_events= int(srv_n_read_io_threads *
OS_AIO_N_PENDING_IOS_PER_THREAD);
int max_events= max_read_events + max_write_events;
read_slots.reset(new io_slots(max_read_events, srv_n_read_io_threads));
write_slots.reset(new io_slots(max_write_events, srv_n_write_io_threads));
int ret;
#if LINUX_NATIVE_AIO
if (srv_use_native_aio && !is_linux_native_aio_supported())
......@@ -3709,12 +3704,11 @@ int os_aio_init()
}
#endif
if (ret)
if (!ret)
{
read_slots.reset();
write_slots.reset();
read_slots= new io_slots(max_read_events, srv_n_read_io_threads);
write_slots= new io_slots(max_write_events, srv_n_write_io_threads);
}
return ret;
}
......@@ -3722,8 +3716,10 @@ int os_aio_init()
void os_aio_free()
{
srv_thread_pool->disable_aio();
read_slots.reset();
write_slots.reset();
delete read_slots;
delete write_slots;
read_slots= nullptr;
write_slots= nullptr;
}
/** Wait until there are no pending asynchronous writes. */
......@@ -3812,7 +3808,7 @@ dberr_t os_aio(const IORequest &type, void *buf, os_offset_t offset, size_t n)
}
compile_time_assert(sizeof(IORequest) <= tpool::MAX_AIO_USERDATA_LEN);
io_slots* slots= type.is_read() ? read_slots.get() : write_slots.get();
io_slots* slots= type.is_read() ? read_slots : write_slots;
tpool::aiocb* cb = slots->acquire();
cb->m_buffer = buf;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment