Commit 0bb0230e authored by Jan Lindström's avatar Jan Lindström

MDEV-6426: Maria DB crashes randomly on creating indexes

Improve OS error messages on Windows.
parent dd1d9212
...@@ -2846,6 +2846,7 @@ os_file_write_func( ...@@ -2846,6 +2846,7 @@ os_file_write_func(
DWORD high; DWORD high;
ulint n_retries = 0; ulint n_retries = 0;
ulint err; ulint err;
DWORD saved_error = 0;
#ifndef UNIV_HOTBACKUP #ifndef UNIV_HOTBACKUP
ulint i; ulint i;
#endif /* !UNIV_HOTBACKUP */ #endif /* !UNIV_HOTBACKUP */
...@@ -2935,8 +2936,10 @@ os_file_write_func( ...@@ -2935,8 +2936,10 @@ os_file_write_func(
} }
if (!os_has_said_disk_full) { if (!os_has_said_disk_full) {
char *winmsg = NULL;
err = (ulint) GetLastError(); saved_error = GetLastError();
err = (ulint) saved_error;
ut_print_timestamp(stderr); ut_print_timestamp(stderr);
...@@ -2953,6 +2956,23 @@ os_file_write_func( ...@@ -2953,6 +2956,23 @@ os_file_write_func(
name, offset, name, offset,
(ulong) n, (ulong) len, (ulong) err); (ulong) n, (ulong) len, (ulong) err);
/* Ask Windows to prepare a standard message for a
GetLastError() */
FormatMessage(FORMAT_MESSAGE_ALLOCATE_BUFFER |
FORMAT_MESSAGE_FROM_SYSTEM |
FORMAT_MESSAGE_IGNORE_INSERTS,
NULL, saved_error,
MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT),
(LPSTR)&winmsg, 0, NULL);
if (winmsg) {
fprintf(stderr,
"InnoDB: FormatMessage: Error number %lu means '%s'.\n",
(ulong) saved_error, winmsg);
LocalFree(winmsg);
}
if (strerror((int) err) != NULL) { if (strerror((int) err) != NULL) {
fprintf(stderr, fprintf(stderr,
"InnoDB: Error number %lu means '%s'.\n", "InnoDB: Error number %lu means '%s'.\n",
...@@ -2980,7 +3000,6 @@ os_file_write_func( ...@@ -2980,7 +3000,6 @@ os_file_write_func(
} }
if (!os_has_said_disk_full) { if (!os_has_said_disk_full) {
ut_print_timestamp(stderr); ut_print_timestamp(stderr);
fprintf(stderr, fprintf(stderr,
......
...@@ -3049,7 +3049,8 @@ os_file_write_func( ...@@ -3049,7 +3049,8 @@ os_file_write_func(
DWORD len; DWORD len;
ulint n_retries = 0; ulint n_retries = 0;
ulint err; ulint err;
OVERLAPPED overlapped; OVERLAPPED overlapped;
DWORD saved_error = 0;
/* On 64-bit Windows, ulint is 64 bits. But offset and n should be /* On 64-bit Windows, ulint is 64 bits. But offset and n should be
no more than 32 bits. */ no more than 32 bits. */
...@@ -3076,7 +3077,7 @@ os_file_write_func( ...@@ -3076,7 +3077,7 @@ os_file_write_func(
if (ret) { if (ret) {
ret = GetOverlappedResult(file, &overlapped, (DWORD *)&len, FALSE); ret = GetOverlappedResult(file, &overlapped, (DWORD *)&len, FALSE);
} }
else if(GetLastError() == ERROR_IO_PENDING) { else if ( GetLastError() == ERROR_IO_PENDING) {
ret = GetOverlappedResult(file, &overlapped, (DWORD *)&len, TRUE); ret = GetOverlappedResult(file, &overlapped, (DWORD *)&len, TRUE);
} }
...@@ -3104,8 +3105,10 @@ os_file_write_func( ...@@ -3104,8 +3105,10 @@ os_file_write_func(
} }
if (!os_has_said_disk_full) { if (!os_has_said_disk_full) {
char *winmsg = NULL;
err = (ulint) GetLastError(); saved_error = GetLastError();
err = (ulint) saved_error;
ut_print_timestamp(stderr); ut_print_timestamp(stderr);
...@@ -3122,6 +3125,23 @@ os_file_write_func( ...@@ -3122,6 +3125,23 @@ os_file_write_func(
name, offset, name, offset,
(ulong) n, (ulong) len, (ulong) err); (ulong) n, (ulong) len, (ulong) err);
/* Ask Windows to prepare a standard message for a
GetLastError() */
FormatMessage(FORMAT_MESSAGE_ALLOCATE_BUFFER |
FORMAT_MESSAGE_FROM_SYSTEM |
FORMAT_MESSAGE_IGNORE_INSERTS,
NULL, saved_error,
MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT),
(LPSTR)&winmsg, 0, NULL);
if (winmsg) {
fprintf(stderr,
"InnoDB: FormatMessage: Error number %lu means '%s'.\n",
(ulong) saved_error, winmsg);
LocalFree(winmsg);
}
if (strerror((int) err) != NULL) { if (strerror((int) err) != NULL) {
fprintf(stderr, fprintf(stderr,
"InnoDB: Error number %lu means '%s'.\n", "InnoDB: Error number %lu means '%s'.\n",
......
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