mirror of
https://github.com/MariaDB/server.git
synced 2025-01-22 23:04:20 +01:00
#2738 refs[t:2738] merge dbufio bug fix to main
git-svn-id: file:///svn/toku/tokudb@21260 c7de825b-a66e-492c-adef-691d508d4ae1
This commit is contained in:
parent
76dcd3fe21
commit
c37567705f
4 changed files with 21 additions and 25 deletions
|
@ -1688,6 +1688,8 @@ static int merge_some_files (const BOOL to_q, FIDX dest_data, QUEUE q, int n_sou
|
||||||
}
|
}
|
||||||
|
|
||||||
if (bfs!=NULL) {
|
if (bfs!=NULL) {
|
||||||
|
if (result != 0)
|
||||||
|
(void) panic_dbufio_fileset(bfs, result);
|
||||||
int r = destroy_dbufio_fileset(bfs);
|
int r = destroy_dbufio_fileset(bfs);
|
||||||
if (r!=0 && result==0) result=r;
|
if (r!=0 && result==0) result=r;
|
||||||
bfs = NULL;
|
bfs = NULL;
|
||||||
|
|
|
@ -149,7 +149,10 @@ static void* io_thread (void *v)
|
||||||
{
|
{
|
||||||
int r = toku_pthread_mutex_lock(&bfs->mutex);
|
int r = toku_pthread_mutex_lock(&bfs->mutex);
|
||||||
if (r!=0) { panic(bfs, r); return 0; }
|
if (r!=0) { panic(bfs, r); return 0; }
|
||||||
if (paniced(bfs)) return 0;
|
if (paniced(bfs)) {
|
||||||
|
toku_pthread_mutex_unlock(&bfs->mutex); // ignore any error
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
// Now that we have the mutex, we can decrement n_not_done (if applicable) and set second_buf_ready
|
// Now that we have the mutex, we can decrement n_not_done (if applicable) and set second_buf_ready
|
||||||
if (readcode<=0) {
|
if (readcode<=0) {
|
||||||
|
@ -267,6 +270,14 @@ int create_dbufio_fileset (DBUFIO_FILESET *bfsp, int N, int fds[/*N*/], size_t b
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
int panic_dbufio_fileset(DBUFIO_FILESET bfs, int error) {
|
||||||
|
int r;
|
||||||
|
r = toku_pthread_mutex_lock(&bfs->mutex); assert(r==0);
|
||||||
|
panic(bfs, error);
|
||||||
|
r = toku_pthread_cond_broadcast(&bfs->cond); assert(r==0);
|
||||||
|
r = toku_pthread_mutex_unlock(&bfs->mutex); assert(r==0);
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
int destroy_dbufio_fileset (DBUFIO_FILESET bfs) {
|
int destroy_dbufio_fileset (DBUFIO_FILESET bfs) {
|
||||||
int result = 0;
|
int result = 0;
|
||||||
|
|
|
@ -22,6 +22,8 @@ int destroy_dbufio_fileset(DBUFIO_FILESET);
|
||||||
|
|
||||||
int dbufio_fileset_read (DBUFIO_FILESET bfs, int filenum, void *buf_v, size_t count, size_t *n_read);
|
int dbufio_fileset_read (DBUFIO_FILESET bfs, int filenum, void *buf_v, size_t count, size_t *n_read);
|
||||||
|
|
||||||
|
int panic_dbufio_fileset(DBUFIO_FILESET, int error);
|
||||||
|
|
||||||
C_END
|
C_END
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
|
@ -39,30 +39,11 @@ static void test1 (size_t chars_per_file, size_t bytes_per_read) {
|
||||||
int r = create_dbufio_fileset(&bfs, N, fds, M);
|
int r = create_dbufio_fileset(&bfs, N, fds, M);
|
||||||
assert(r==0);
|
assert(r==0);
|
||||||
}
|
}
|
||||||
#if 0
|
|
||||||
while (n_live>0) {
|
|
||||||
int indirectnum = random()%n_live;
|
|
||||||
int filenum = still_live[indirectnum];
|
|
||||||
char buf[bytes_per_read];
|
|
||||||
size_t n_read_here=0;
|
|
||||||
int r = dbufio_fileset_read(bfs, filenum, buf, bytes_per_read, &n_read_here);
|
|
||||||
//printf("read(%d) -> %d (%ld) (old n_read=%ld)\n", filenum, r, n_read_here, n_read[filenum]);
|
|
||||||
if (r==0) {
|
|
||||||
// did read something
|
|
||||||
assert(n_read_here==bytes_per_read);
|
|
||||||
n_read[filenum]+=n_read_here;
|
|
||||||
//printf(" new n_read=%ld\n", n_read[filenum]);
|
|
||||||
assert(n_read[filenum]<=chars_per_file);
|
|
||||||
} else {
|
|
||||||
assert(r==EOF);
|
|
||||||
assert(n_read[filenum]==chars_per_file);
|
|
||||||
still_live[indirectnum] = still_live[n_live-1];
|
|
||||||
n_live--;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
#else
|
|
||||||
n_live = n_live; bytes_per_read = bytes_per_read;
|
n_live = n_live; bytes_per_read = bytes_per_read;
|
||||||
#endif
|
|
||||||
|
{ int r = panic_dbufio_fileset(bfs, EIO); assert(r == 0); }
|
||||||
|
|
||||||
{
|
{
|
||||||
int r = destroy_dbufio_fileset(bfs);
|
int r = destroy_dbufio_fileset(bfs);
|
||||||
assert(r==0);
|
assert(r==0);
|
||||||
|
@ -76,7 +57,7 @@ static void test1 (size_t chars_per_file, size_t bytes_per_read) {
|
||||||
int r = close(fds[i]);
|
int r = close(fds[i]);
|
||||||
assert(r==0);
|
assert(r==0);
|
||||||
}
|
}
|
||||||
assert(n_read[i]==chars_per_file);
|
assert(n_read[i]==0);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Add table
Reference in a new issue