-C Add\sin-process\sblocking\slocks\sto\sos_win.c\susing\sa\ssimilar\stechnique.
-D 2021-07-20T21:02:43.412
+C Fix\sa\sproblem\sin\sthe\snew\sos_unix.c\scode.\sRefine\sthe\sthreadtest3\stest\scase\ssome.
+D 2021-07-22T10:44:31.628
F .fossil-settings/empty-dirs dbb81e8fc0401ac46a1491ab34a7f2c7c0452f2f06b54ebb845d024ca8283ef1
F .fossil-settings/ignore-glob 35175cdfcf539b2318cb04a9901442804be81cd677d8b889fcc9149c21f239ea
F LICENSE.md df5091916dbb40e6e9686186587125e1b2ff51f022cc334e886c19a0e9982724
F src/os.h 26890f540b475598cd9881dcc68931377b8d429d3ea3e2eeb64470cde64199f8
F src/os_common.h b2f4707a603e36811d9b1a13278bffd757857b85
F src/os_setup.h 0dbaea40a7d36bf311613d31342e0b99e2536586
-F src/os_unix.c aea96704db0860b61ad95272bd9cb3fc3a4910e6d68506cc6c48d5d8f7922d0b
+F src/os_unix.c b28ab4bc1320fde00495f5dce41544fc7de9f5b801f82afe3b1429614f487ed8
F src/os_win.c 03017ffbfa230d833421667a02edca8baab76ff8446533e796206a04c618b2d6
F src/os_win.h 7b073010f1451abe501be30d12f6bc599824944a
F src/pager.c 95c255256b13827caf038c8f963d334784073f38ab6ef9d70371d9d04f3c43e0
F test/thread_common.tcl 334639cadcb9f912bf82aa73f49efd5282e6cadd
F test/threadtest1.c 6029d9c5567db28e6dc908a0c63099c3ba6c383b
F test/threadtest2.c a70a8e94bef23339d34226eb9521015ef99f4df8
-F test/threadtest3.c 7d68734b4a1697f851db18c79ae5182909deed80f44205c7d2b7bed5059a8d59
+F test/threadtest3.c 9cada9dfdc405310f8f3802e54a45e1d85449f0a15ac081e05f175c1386c82f1
F test/threadtest4.c c1e67136ceb6c7ec8184e56ac61db28f96bd2925
F test/threadtest5.c 9b4d782c58d8915d7e955ff8051f3d03628bda0d33b82971ea8c0f2f2808c421
F test/time-wordcount.sh 8e0b0f8109367827ad5d58f5cc849705731e4b90
F vsixtest/vsixtest.vcxproj.data 2ed517e100c66dc455b492e1a33350c1b20fbcdc
F vsixtest/vsixtest.vcxproj.filters 37e51ffedcdb064aad6ff33b6148725226cd608e
F vsixtest/vsixtest_TemporaryKey.pfx e5b1b036facdb453873e7084e1cae9102ccc67a0
-P 85fd18d7a2ea96d40fc1d59778ad5eabd0a42f775c417ece183b230eea57a993
-R 86dd5c706e5b2d8a1aff71102b4d56d3
+P b67c157fd89f73078e3bf4e3d6e8d77fa59ef1ec5c3a9d0e3af955362d751960
+R 969567a5ddcecbed0f31287f4ee2f6dc
U dan
-Z e4f62272e7587bffc54dda28167a17c7
+Z 94f6a6af08448cd4cddc3bdd1340b73f
-b67c157fd89f73078e3bf4e3d6e8d77fa59ef1ec5c3a9d0e3af955362d751960
\ No newline at end of file
+2039d447b717abf6b536eb2e5e41abacb6bedbccf738a929d1ee3ee6f565c5d4
\ No newline at end of file
#ifdef SQLITE_ENABLE_SETLK_TIMEOUT
int bRetry;
struct timespec sTimespec;
+ memset(&sTimespec, 0, sizeof(sTimespec));
#endif
assert( pShmNode==pDbFd->pInode->pShmNode );
&& (ofst!=0 || (p->exclMask|p->sharedMask)<3)
&& (ofst<3 || (p->exclMask|p->sharedMask)<(1<<ofst))
));
-
- if( pDbFd->iBusyTimeout ){
- struct timeval tm;
- memset(&sTimespec, 0, sizeof(sTimespec));
- gettimeofday(&tm, 0);
- TIMEVAL_TO_TIMESPEC(&tm, &sTimespec);
- sTimespec.tv_sec += pDbFd->iBusyTimeout / 1000;
- sTimespec.tv_nsec += (pDbFd->iBusyTimeout % 1000) * 1000000;
- if( sTimespec.tv_nsec>(1000*1000000) ){
- sTimespec.tv_sec++;
- sTimespec.tv_nsec -= (1000*1000000);
- }
- }
#endif
mask = (1<<(ofst+n)) - (1<<ofst);
if( bRetry ){
int prc;
assert( rc==SQLITE_BUSY );
+
+ /* If the timeout is still zero, calculate it now. */
+ if( sTimespec.tv_sec==0 ){
+ static const sqlite3_int64 unixEpoch = 24405875*(sqlite3_int64)8640000;
+ i64 iAbs;
+ pDbFd->pVfs->xCurrentTimeInt64(pDbFd->pVfs, &iAbs);
+ iAbs -= unixEpoch;
+ iAbs += pDbFd->iBusyTimeout;
+ memset(&sTimespec, 0, sizeof(sTimespec));
+ sTimespec.tv_sec = iAbs / 1000;
+ sTimespec.tv_nsec = (iAbs % 1000) * 1000000;
+ }
+
prc = pthread_cond_timedwait(
&pShmNode->shmcond, &pShmNode->shmmutex, &sTimespec
);
if( prc==0 ){
rc = SQLITE_OK;
}else{
- /* printf("prc=%d (%s)\n", prc, strerror(prc)); */
bRetry = 0;
}
}
return rc;
}
-static char *walthread6_thread(int iTid, void *pArg){
+static char *contention1_thread(int iTid, void *pArg){
Error err = {0};
Sqlite db = {0};
int nBlk = 0;
closedb(&err, &db);
print_and_free_err(&err);
return sqlite3_mprintf(
- "%d transactions (%d busy) in %d blocks, max-wal-size=%d frames",
- res.nInsert, res.nBusy, nBlk, res.nMaxFrame
+ "%d transactions in %d runs (%d busy), max-wal-size=%d frames",
+ res.nInsert, nBlk, res.nBusy, res.nMaxFrame
);
}
/*
+** Test case "contention1".
+**
+** Start with a database in wal mode containing a single table. Then run
+** two threads in a loop as follows:
+**
+** while( not-finished ){
+** BEGIN IMMEDIATE;
+** INSERT INTO tbl ...
+** sleep( 10ms );
+** COMMIT;
+** sleep( 1ms );
+** }
**
+** Each thread is configured with sqlite3_busy_timeout(1000ms). Each
+** thread reports:
+**
+** * the number of successful inserts,
+** * the number of runs the inserts are separated into (a run is a
+** series of contiguous inserts not interrupted by an insert from
+** the other thread), and
+** * the number of SQLITE_BUSY errors.
*/
-static void walthread6(int nMs){
+static void contention1(int nMs){
Error err = {0};
Sqlite db = {0};
Threadset threads = {0};
setstoptime(&err, nMs);
for(i=0; i<nThread; i++){
- launch_thread(&err, &threads, walthread6_thread, 0);
+ launch_thread(&err, &threads, contention1_thread, 0);
}
join_all_threads(&err, &threads);
{ walthread4, "walthread4", 20000 },
{ walthread5, "walthread5", 1000 },
- { walthread6, "walthread6", 5000 },
+ { contention1, "contention1", 10000 },
{ cgt_pager_1, "cgt_pager_1", 0 },
{ dynamic_triggers, "dynamic_triggers", 20000 },