OLD | NEW |
1 /* | 1 /* |
2 ** 2001 September 15 | 2 ** 2011-02-02 |
3 ** | 3 ** |
4 ** The author disclaims copyright to this source code. In place of | 4 ** The author disclaims copyright to this source code. In place of |
5 ** a legal notice, here is a blessing: | 5 ** a legal notice, here is a blessing: |
6 ** | 6 ** |
7 ** May you do good and not evil. | 7 ** May you do good and not evil. |
8 ** May you find forgiveness for yourself and forgive others. | 8 ** May you find forgiveness for yourself and forgive others. |
9 ** May you share freely, never taking more than you give. | 9 ** May you share freely, never taking more than you give. |
10 ** | 10 ** |
11 ************************************************************************* | 11 ************************************************************************* |
12 ** This file is part of the test program "threadtest3". Despite being a C | 12 ** This file is part of the test program "threadtest3". Despite being a C |
(...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
59 CheckpointStarvationCtx *p = (CheckpointStarvationCtx *)pCtx; | 59 CheckpointStarvationCtx *p = (CheckpointStarvationCtx *)pCtx; |
60 if( nFrame>p->nMaxFrame ){ | 60 if( nFrame>p->nMaxFrame ){ |
61 p->nMaxFrame = nFrame; | 61 p->nMaxFrame = nFrame; |
62 } | 62 } |
63 if( nFrame>=CHECKPOINT_STARVATION_FRAMELIMIT ){ | 63 if( nFrame>=CHECKPOINT_STARVATION_FRAMELIMIT ){ |
64 sqlite3_wal_checkpoint_v2(db, zDb, p->eMode, 0, 0); | 64 sqlite3_wal_checkpoint_v2(db, zDb, p->eMode, 0, 0); |
65 } | 65 } |
66 return SQLITE_OK; | 66 return SQLITE_OK; |
67 } | 67 } |
68 | 68 |
69 static char *checkpoint_starvation_reader(int iTid, int iArg){ | 69 static char *checkpoint_starvation_reader(int iTid, void *pArg){ |
70 Error err = {0}; | 70 Error err = {0}; |
71 Sqlite db = {0}; | 71 Sqlite db = {0}; |
72 | 72 |
73 opendb(&err, &db, "test.db", 0); | 73 opendb(&err, &db, "test.db", 0); |
74 while( !timetostop(&err) ){ | 74 while( !timetostop(&err) ){ |
75 i64 iCount1, iCount2; | 75 i64 iCount1, iCount2; |
76 sql_script(&err, &db, "BEGIN"); | 76 sql_script(&err, &db, "BEGIN"); |
77 iCount1 = execsql_i64(&err, &db, "SELECT count(x) FROM t1"); | 77 iCount1 = execsql_i64(&err, &db, "SELECT count(x) FROM t1"); |
78 usleep(CHECKPOINT_STARVATION_READMS*1000); | 78 usleep(CHECKPOINT_STARVATION_READMS*1000); |
79 iCount2 = execsql_i64(&err, &db, "SELECT count(x) FROM t1"); | 79 iCount2 = execsql_i64(&err, &db, "SELECT count(x) FROM t1"); |
(...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
139 | 139 |
140 static void checkpoint_starvation_2(int nMs){ | 140 static void checkpoint_starvation_2(int nMs){ |
141 Error err = {0}; | 141 Error err = {0}; |
142 CheckpointStarvationCtx ctx = { SQLITE_CHECKPOINT_RESTART, 0 }; | 142 CheckpointStarvationCtx ctx = { SQLITE_CHECKPOINT_RESTART, 0 }; |
143 checkpoint_starvation_main(nMs, &ctx); | 143 checkpoint_starvation_main(nMs, &ctx); |
144 if( ctx.nMaxFrame>CHECKPOINT_STARVATION_FRAMELIMIT+10 ){ | 144 if( ctx.nMaxFrame>CHECKPOINT_STARVATION_FRAMELIMIT+10 ){ |
145 test_error(&err, "WAL grew too large - %d frames", ctx.nMaxFrame); | 145 test_error(&err, "WAL grew too large - %d frames", ctx.nMaxFrame); |
146 } | 146 } |
147 print_and_free_err(&err); | 147 print_and_free_err(&err); |
148 } | 148 } |
149 | |
150 | |
OLD | NEW |