More thorough checkpoint.

git-svn-id: https://www.unprompted.com/svn/projects/tildefriends/trunk@4474 ed5197a5-7fde-0310-b194-c3ffbd925b24
This commit is contained in:
Cory McWilliams 2023-09-23 18:49:24 +00:00
parent dd851a2b25
commit 54898d3dbb

View File

@ -1169,6 +1169,23 @@ typedef struct _delete_blobs_work_t
tf_ssb_t* ssb; tf_ssb_t* ssb;
} delete_blobs_work_t; } delete_blobs_work_t;
static void _tf_ssb_rpc_checkpoint(tf_ssb_t* ssb)
{
int64_t checkpoint_start_ms = uv_hrtime();
sqlite3* db = tf_ssb_acquire_db_writer(ssb);
int log = 0;
int checkpointed = 0;
if (sqlite3_wal_checkpoint_v2(db, NULL, SQLITE_CHECKPOINT_TRUNCATE, &log, &checkpointed) == SQLITE_OK)
{
tf_printf("Checkpointed %d frames in %d ms. Log is now %d frames.\n", (int)((uv_hrtime() - checkpoint_start_ms) / 1000000LL), checkpointed, log);
}
else
{
tf_printf("Checkpoint: %s.\n", sqlite3_errmsg(db));
}
tf_ssb_release_db_writer(ssb, db);
}
static void _tf_ssb_rpc_delete_blobs_work(uv_work_t* work) static void _tf_ssb_rpc_delete_blobs_work(uv_work_t* work)
{ {
delete_blobs_work_t* delete = work->data; delete_blobs_work_t* delete = work->data;
@ -1177,6 +1194,7 @@ static void _tf_ssb_rpc_delete_blobs_work(uv_work_t* work)
int64_t age = _get_global_setting_int64(ssb, "blob_expire_age_seconds", -1); int64_t age = _get_global_setting_int64(ssb, "blob_expire_age_seconds", -1);
if (age <= 0) if (age <= 0)
{ {
_tf_ssb_rpc_checkpoint(ssb);
tf_ssb_record_thread_busy(ssb, false); tf_ssb_record_thread_busy(ssb, false);
return; return;
} }
@ -1213,16 +1231,10 @@ static void _tf_ssb_rpc_delete_blobs_work(uv_work_t* work)
{ {
tf_printf("prepare failed: %s\n", sqlite3_errmsg(db)); tf_printf("prepare failed: %s\n", sqlite3_errmsg(db));
} }
int64_t checkpoint_start_ms = uv_hrtime();
int log = 0;
int checkpointed = 0;
if (sqlite3_wal_checkpoint_v2(db, NULL, SQLITE_CHECKPOINT_TRUNCATE, &log, &checkpointed) == SQLITE_OK)
{
tf_printf("Checkpointed %d frames in %d ms. Log is now %d frames.\n", (int)((uv_hrtime() - checkpoint_start_ms) / 1000000LL), checkpointed, log);
}
tf_ssb_release_db_writer(ssb, db); tf_ssb_release_db_writer(ssb, db);
int64_t duration_ms = (uv_hrtime() - start_ns) / 1000000LL; int64_t duration_ms = (uv_hrtime() - start_ns) / 1000000LL;
tf_printf("Deleted %d blobs in %d ms.\n", deleted, (int)duration_ms); tf_printf("Deleted %d blobs in %d ms.\n", deleted, (int)duration_ms);
_tf_ssb_rpc_checkpoint(ssb);
_tf_ssb_rpc_start_delete_blobs(ssb, deleted ? (int)duration_ms : (15 * 60 * 1000)); _tf_ssb_rpc_start_delete_blobs(ssb, deleted ? (int)duration_ms : (15 * 60 * 1000));
tf_ssb_record_thread_busy(ssb, false); tf_ssb_record_thread_busy(ssb, false);
} }