diff --git a/storage/innobase/os/os0file.cc b/storage/innobase/os/os0file.cc index c2f01bc..1c3f320 100644 --- a/storage/innobase/os/os0file.cc +++ b/storage/innobase/os/os0file.cc @@ -2537,9 +2553,23 @@ LinuxAIOHandler::collect() m_array->acquire(); slot->ret = events[i].res2; - slot->io_already_done = true; - slot->n_bytes = events[i].res; - + /* + libaio can return events[i].res as negative value as errno, + but we must convert it from ulong to long to catch this. + */ + if ((long)events[i].res >= 0) { + slot->io_already_done = true; + slot->n_bytes = events[i].res; + } else { + // async IO error. + slot->io_already_done = false; + slot->n_bytes = 0; + char errbuf[1024]; + + fprintf(stderr, "Async I/O error (%ld, %s) on slot(%s).", (long)events[i].res, + strerror_r(events[i].res, errbuf, 1024), + slot->to_string().c_str()); + } m_array->release(); }