Skip to content
Permalink
Browse files
MDEV-28935 crash in io_slots::release
Revert "TSAN: data race on vptr (ctor/dtor vs virtual call)"

This reverts commit 78084fa.

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
  • Loading branch information
vaintroub committed Jun 23, 2022
1 parent f2f18e2 commit d96436c
Showing 1 changed file with 10 additions and 14 deletions.
@@ -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,21 +3704,22 @@ 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;
}


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;

0 comments on commit d96436c

Please sign in to comment.