Many hyperlinks are disabled.
Use anonymous login
to enable hyperlinks.
Overview
Comment: | Fix a deadlock in multi-threaded test code. |
---|---|
Downloads: | Tarball | ZIP archive |
Timelines: | family | ancestors | descendants | both | trunk |
Files: | files | file ages | folders |
SHA1: |
e16b04ca69fa131b6a7a370e2afc7879 |
User & Date: | dan 2012-09-27 04:59:26.533 |
Context
2012-09-27
| ||
16:09 | Fix to ensure that the log file is always deleted following a successful system shutdown. check-in: 3d1dacff87 user: dan tags: trunk | |
04:59 | Fix a deadlock in multi-threaded test code. check-in: e16b04ca69 user: dan tags: trunk | |
2012-09-26
| ||
15:38 | Merge rework-flow-control branch with trunk. check-in: cf2ef747ad user: dan tags: trunk | |
Changes
Changes to lsm-test/lsmtest_tdb3.c.
︙ | ︙ | |||
928 929 930 931 932 933 934 | static void *worker_main(void *pArg){ LsmWorker *p = (LsmWorker *)pArg; lsm_db *pWorker; /* Connection to access db through */ pthread_mutex_lock(&p->worker_mutex); while( (pWorker = p->pWorker) ){ | < > > | < < < < > | | | < < < | > > > > > | | | < > > | | < < | > | < < < < < < < < | | | | < | 928 929 930 931 932 933 934 935 936 937 938 939 940 941 942 943 944 945 946 947 948 949 950 951 952 953 954 955 956 957 958 959 960 961 962 963 964 965 966 967 968 969 970 971 972 973 974 975 976 977 978 979 980 981 982 983 984 985 986 987 988 989 990 991 | static void *worker_main(void *pArg){ LsmWorker *p = (LsmWorker *)pArg; lsm_db *pWorker; /* Connection to access db through */ pthread_mutex_lock(&p->worker_mutex); while( (pWorker = p->pWorker) ){ int rc = LSM_OK; int nLimit = -1; int nCkpt = -1; /* Do some work. If an error occurs, exit. */ pthread_mutex_unlock(&p->worker_mutex); lsm_config(pWorker, LSM_CONFIG_WRITE_BUFFER, &nLimit); if( p->bCkpt ){ lsm_ckpt_size(pWorker, &nCkpt); if( nCkpt>(nLimit*2) ){ rc = lsm_checkpoint(pWorker, 0); } }else{ int nWrite = 0; int nAuto = -1; lsm_config(pWorker, LSM_CONFIG_AUTOCHECKPOINT, &nAuto); do { int nSleep = 0; lsm_ckpt_size(pWorker, &nCkpt); while( nAuto==0 && nCkpt>(nLimit*4) ){ usleep(1000); mt_signal_worker(p->pDb, 1); nSleep++; lsm_ckpt_size(pWorker, &nCkpt); } #if 0 if( nSleep ) printf("nLimit=%d nSleep=%d (worker)\n", nLimit, nSleep); #endif rc = lsm_work(pWorker, p->lsm_work_flags, p->lsm_work_npage, &nWrite); if( nAuto==0 && nWrite && rc==LSM_OK ) mt_signal_worker(p->pDb, 1); }while( nWrite ); } pthread_mutex_lock(&p->worker_mutex); if( rc!=LSM_OK && rc!=LSM_BUSY ){ p->worker_rc = rc; break; } /* If the call to lsm_work() indicates that there is nothing more ** to do at this point, wait on the condition variable. The thread will ** wake up when it is signaled either because the client thread has ** flushed an in-memory tree into the db file or when the connection ** is being closed. */ if( p->pWorker && p->bDoWork==0 ){ pthread_cond_wait(&p->worker_cond, &p->worker_mutex); } p->bDoWork = 0; } pthread_mutex_unlock(&p->worker_mutex); return 0; } |
︙ | ︙ | |||
1037 1038 1039 1040 1041 1042 1043 | static void mt_client_work_hook(lsm_db *db, void *pArg){ LsmDb *pDb = (LsmDb *)pArg; /* LsmDb database handle */ int i; /* Iterator variable */ /* Invoke the user level work-hook, if any. */ if( pDb->xWork ) pDb->xWork(db, pDb->pWorkCtx); | < | < | < | 1028 1029 1030 1031 1032 1033 1034 1035 1036 1037 1038 1039 1040 1041 1042 1043 | static void mt_client_work_hook(lsm_db *db, void *pArg){ LsmDb *pDb = (LsmDb *)pArg; /* LsmDb database handle */ int i; /* Iterator variable */ /* Invoke the user level work-hook, if any. */ if( pDb->xWork ) pDb->xWork(db, pDb->pWorkCtx); /* Signal the lsm_work() thread */ mt_signal_worker(pDb, 0); } static void mt_worker_work_hook(lsm_db *db, void *pArg){ LsmDb *pDb = (LsmDb *)pArg; /* LsmDb database handle */ /* Invoke the user level work-hook, if any. */ if( pDb->xWork ) pDb->xWork(db, pDb->pWorkCtx); |
︙ | ︙ | |||
1080 1081 1082 1083 1084 1085 1086 | /* Open the worker connection */ if( rc==0 ) rc = lsm_new(&pDb->env, &p->pWorker); if( zCfg ){ test_lsm_config_str(pDb, p->pWorker, 1, zCfg, 0); } if( rc==0 ) rc = lsm_open(p->pWorker, zFilename); | < | < | 1068 1069 1070 1071 1072 1073 1074 1075 1076 1077 1078 1079 1080 1081 1082 | /* Open the worker connection */ if( rc==0 ) rc = lsm_new(&pDb->env, &p->pWorker); if( zCfg ){ test_lsm_config_str(pDb, p->pWorker, 1, zCfg, 0); } if( rc==0 ) rc = lsm_open(p->pWorker, zFilename); lsm_config_log(p->pWorker, xLog, (void *)"worker"); /* Configure the work-hook */ if( rc==0 ){ lsm_config_work_hook(p->pWorker, mt_worker_work_hook, (void *)pDb); } /* Kick off the worker thread. */ |
︙ | ︙ | |||
1114 1115 1116 1117 1118 1119 1120 | pDb->aWorker = (LsmWorker *)testMalloc(sizeof(LsmWorker) * nWorker); memset(pDb->aWorker, 0, sizeof(LsmWorker) * nWorker); pDb->nWorker = nWorker; if( nWorker==1 ){ int flags = LSM_WORK_FLUSH; | | | | 1100 1101 1102 1103 1104 1105 1106 1107 1108 1109 1110 1111 1112 1113 1114 1115 1116 1117 | pDb->aWorker = (LsmWorker *)testMalloc(sizeof(LsmWorker) * nWorker); memset(pDb->aWorker, 0, sizeof(LsmWorker) * nWorker); pDb->nWorker = nWorker; if( nWorker==1 ){ int flags = LSM_WORK_FLUSH; rc = mt_start_worker(pDb, 0, zFilename, zCfg, flags, 256, 0); }else{ int flags = LSM_WORK_FLUSH; rc = mt_start_worker(pDb, 0, zFilename, zCfg, flags, 256, 0); if( rc==LSM_OK ){ rc = mt_start_worker(pDb, 1, zFilename, zCfg, 0, 0, 1); } } return rc; } |
︙ | ︙ |
Changes to src/lsm_shared.c.
︙ | ︙ | |||
468 469 470 471 472 473 474 | } if( rc==LSM_OK && bInUse==0 ){ iRet = pFree->aEntry[0].iBlk; flRemoveEntry0(pFree); assert( iRet!=0 ); } | | | > > > | 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 | } if( rc==LSM_OK && bInUse==0 ){ iRet = pFree->aEntry[0].iBlk; flRemoveEntry0(pFree); assert( iRet!=0 ); } #ifdef LSM_LOG_BLOCKS lsmLogMessage( pDb, 0, "%s reusing block %d%s", (iRet==0 ? "not " : ""), pFree->aEntry[0].iBlk, bInUse==0 ? "" : bInUse==1 ? " (client)" : " (unsynced)" ); #endif } /* If no block was allocated from the free-list, allocate one at the ** end of the file. */ if( rc==LSM_OK && iRet==0 ){ iRet = ++pDb->pWorker->nBlock; #ifdef LSM_LOG_BLOCKS lsmLogMessage(pDb, 0, "extending file to %d blocks", iRet); #endif } *piBlk = iRet; return LSM_OK; } /* |
︙ | ︙ |
Changes to tool/lsmperf.tcl.
1 2 3 4 5 6 | #!/bin/sh # \ exec tclsh "$0" "$@" proc exec_lsmtest_speed {nSec spec} { | | > > > > > > > > | > > | | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 | #!/bin/sh # \ exec tclsh "$0" "$@" proc exec_lsmtest_speed {nSec spec} { set fd [open [list |./lsmtest speed2 {*}$spec]] set res [list] puts -nonewline "./lsmtest speed2" foreach s $spec { if {[llength $s]==1} { puts -nonewline " $s" } else { puts -nonewline " \"$s\"" } } puts "" set initial [clock seconds] while {![eof $fd] && ($nSec==0 || ([clock second]-$initial)<$nSec)} { set line [gets $fd] set sz 0 catch { set sz [file size testdb.lsm] } puts "$line ([expr $sz/1024])" if {[string range $line 0 0]=="#"} continue if {[llength $line]==0} continue lappend res $line } catch { close $fd } set res } |
︙ | ︙ | |||
154 155 156 157 158 159 160 | append script $data2 append script $data3 append script "pause -1\n" exec_gnuplot_script $script $zPng } | | | | > > > > > | 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 | append script $data2 append script $data3 append script "pause -1\n" exec_gnuplot_script $script $zPng } do_write_test x.png 120 50000 50000 30 { lsm-mt "mmap=1 multi_proc=0 threads=3 autowork=0 autocheckpoint=0" leveldb leveldb } # lsm-mt "mmap=1 multi_proc=0 threads=2 autowork=0 autocheckpoint=8192000" # lsm-mt "mmap=1 multi_proc=0 safety=1 threads=3 autowork=0" # lsm-st "mmap=1 multi_proc=0 safety=1 threads=1 autowork=1" # lsm-mt "mmap=1 multi_proc=0 safety=1 threads=3 autowork=0" # lsm-mt "mmap=1 multi_proc=0 safety=1 threads=3 autowork=0" # LevelDB leveldb # lsm-st "mmap=1 multi_proc=0 safety=1 threads=1 autowork=1" # LevelDB leveldb # SQLite sqlite3 |