You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
@@ -1256,7 +1276,7 @@ static int flush_pages(int nosleep){
1256
1276
pthread_mutex_unlock(&cache_mutex);
1257
1277
psync_sql_free_result(res);
1258
1278
psync_sql_commit_transaction();
1259
-
if (!nosleep)
1279
+
if (!nosleep&& !free_page_waiters)
1260
1280
psync_milisleep(1);
1261
1281
psync_sql_start_transaction();
1262
1282
pthread_mutex_lock(&cache_mutex);
@@ -1292,10 +1312,13 @@ static int flush_pages(int nosleep){
1292
1312
psync_list_add_head(&free_pages, &page->list);
1293
1313
cache_pages_free++;
1294
1314
if (nosleep!=1&&updates%64==0){
1315
+
if (free_page_waiters)
1316
+
pthread_cond_broadcast(&free_page_cond);
1295
1317
pthread_mutex_unlock(&cache_mutex);
1296
1318
psync_sql_free_result(res);
1297
1319
psync_sql_commit_transaction();
1298
-
psync_milisleep(1);
1320
+
if (!free_page_waiters) // it is ok if we read a stale value, because we don't hold cache_mutex any more
1321
+
psync_milisleep(1);
1299
1322
psync_sql_start_transaction();
1300
1323
pthread_mutex_lock(&cache_mutex);
1301
1324
res=psync_sql_prep_statement("UPDATE OR IGNORE pagecache SET hash=?, pageid=?, type="NTO_STR(PAGE_TYPE_READ)", lastuse=?, usecnt=?, size=?, crc=? WHERE id=?");
@@ -1320,7 +1343,8 @@ static int flush_pages(int nosleep){
1320
1343
pthread_mutex_unlock(&cache_mutex);
1321
1344
psync_sql_free_result(res);
1322
1345
psync_sql_commit_transaction();
1323
-
psync_milisleep(1);
1346
+
if (!free_page_waiters)
1347
+
psync_milisleep(1);
1324
1348
psync_sql_start_transaction();
1325
1349
pthread_mutex_lock(&cache_mutex);
1326
1350
res=psync_sql_prep_statement("UPDATE pagecache SET lastuse=?, usecnt=usecnt+? WHERE id=?");
@@ -1332,6 +1356,11 @@ static int flush_pages(int nosleep){
1332
1356
lastflush=ctime;
1333
1357
}
1334
1358
flushcacherun=0;
1359
+
flush_page_running--;
1360
+
if (free_page_waiters){
1361
+
debug(D_NOTICE, "finished flushing cache, but there are still free page waiters, broadcasting");
0 commit comments