mirror of
https://github.com/MariaDB/server.git
synced 2025-02-02 03:51:50 +01:00
Fixes #2124 closes[t:2124] On disk full, we print an error and abort (fail assert).
git-svn-id: file:///svn/toku/tokudb.2037b@15676 c7de825b-a66e-492c-adef-691d508d4ae1
This commit is contained in:
parent
94fa27990c
commit
a761b42336
3 changed files with 62 additions and 6 deletions
57
linux/file.c
57
linux/file.c
|
@ -1,5 +1,42 @@
|
|||
#include <toku_portability.h>
|
||||
#include <unistd.h>
|
||||
#include <errno.h>
|
||||
#include <assert.h>
|
||||
#include <stdio.h>
|
||||
|
||||
//Print any necessary errors
|
||||
//Return whether we should try the write again.
|
||||
static int
|
||||
try_again_after_handling_write_error(int fd, size_t len, ssize_t r_write) {
|
||||
int try_again = 0;
|
||||
|
||||
if (r_write==-1) {
|
||||
int errno_write = errno;
|
||||
assert(errno_write != 0);
|
||||
switch (errno_write) {
|
||||
case EINTR: { //The call was interrupted by a signal before any data was written; see signal(7).
|
||||
char err_msg[sizeof("Write of [] bytes to fd=[] interrupted. Retrying.") + 20+10]; //64 bit is 20 chars, 32 bit is 10 chars
|
||||
snprintf(err_msg, sizeof(err_msg), "Write of [%"PRIu64"] bytes to fd=[%d] interrupted. Retrying.", len, fd);
|
||||
perror(err_msg);
|
||||
fflush(stdout);
|
||||
try_again = 1;
|
||||
break;
|
||||
}
|
||||
case ENOSPC: {
|
||||
char err_msg[sizeof("Failed write of [] bytes to fd=[].") + 20+10]; //64 bit is 20 chars, 32 bit is 10 chars
|
||||
snprintf(err_msg, sizeof(err_msg), "Failed write of [%"PRIu64"] bytes to fd=[%d].", len, fd);
|
||||
perror(err_msg);
|
||||
fflush(stdout);
|
||||
int out_of_disk_space = 1;
|
||||
assert(!out_of_disk_space); //Give an error message that might be useful if this is the only one that survives.
|
||||
}
|
||||
default:
|
||||
break;
|
||||
}
|
||||
errno = errno_write;
|
||||
}
|
||||
return try_again;
|
||||
}
|
||||
|
||||
static ssize_t (*t_pwrite)(int, const void *, size_t, off_t) = 0;
|
||||
|
||||
|
@ -11,11 +48,16 @@ toku_set_func_pwrite (ssize_t (*pwrite_fun)(int, const void *, size_t, off_t)) {
|
|||
|
||||
ssize_t
|
||||
toku_os_pwrite (int fd, const void *buf, size_t len, off_t off) {
|
||||
ssize_t r;
|
||||
again:
|
||||
if (t_pwrite) {
|
||||
return t_pwrite(fd, buf, len, off);
|
||||
r = t_pwrite(fd, buf, len, off);
|
||||
} else {
|
||||
return pwrite(fd, buf, len, off);
|
||||
r = pwrite(fd, buf, len, off);
|
||||
}
|
||||
if (try_again_after_handling_write_error(fd, len, r))
|
||||
goto again;
|
||||
return r;
|
||||
}
|
||||
|
||||
static ssize_t (*t_write)(int, const void *, size_t) = 0;
|
||||
|
@ -28,12 +70,15 @@ toku_set_func_write (ssize_t (*write_fun)(int, const void *, size_t)) {
|
|||
|
||||
ssize_t
|
||||
toku_os_write (int fd, const void *buf, size_t len) {
|
||||
ssize_t r;
|
||||
again:
|
||||
if (t_pwrite) {
|
||||
return t_write(fd, buf, len);
|
||||
r = t_write(fd, buf, len);
|
||||
} else {
|
||||
return write(fd, buf, len);
|
||||
r = write(fd, buf, len);
|
||||
}
|
||||
if (try_again_after_handling_write_error(fd, len, r))
|
||||
goto again;
|
||||
return r;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
|
|
@ -157,6 +157,7 @@ TDB_TESTS_THAT_SHOULD_FAIL= \
|
|||
test944 \
|
||||
test_truncate_txn_abort \
|
||||
test_db_no_env \
|
||||
diskfull \
|
||||
#\ ends prev line
|
||||
#ifneq ($(OS_CHOICE),windows)
|
||||
# TDB_TESTS_THAT_SHOULD_FAIL+= \
|
||||
|
|
|
@ -52,6 +52,16 @@ pwrite(int fildes, const void *buf, size_t nbyte, int64_t offset) {
|
|||
r = WriteFile(filehandle, buf, nbyte, &bytes_written, &win_offset);
|
||||
if (!r) {
|
||||
errno = GetLastError();
|
||||
if (errno == ERROR_HANDLE_DISK_FULL ||
|
||||
errno == ERROR_DISK_FULL) {
|
||||
char err_msg[sizeof("Failed write of [] bytes to fd=[].") + 20+10]; //64 bit is 20 chars, 32 bit is 10 chars
|
||||
snprintf(err_msg, sizeof(err_msg), "Failed write of [%"PRIu64"] bytes to fd=[%d].", len, fd);
|
||||
perror(err_msg);
|
||||
fflush(stdout);
|
||||
int out_of_disk_space = 1;
|
||||
assert(!out_of_disk_space); //Give an error message that might be useful if this is the only one that survives.
|
||||
}
|
||||
|
||||
r = -1;
|
||||
}
|
||||
else r = bytes_written;
|
Loading…
Add table
Reference in a new issue