Fossil SCM

More details on the g.zPhase markings for backoffice processing, to help track down reports of hung backoffice processes that appear in the error log from time to time.

drh 2025-03-30 23:25 trunk
Commit cd532394c6fa8eae731f70efb56bde5ccac65b74f424b8c1b8139d9656ef1e20
1 file changed +5 -1
--- src/backoffice.c
+++ src/backoffice.c
@@ -485,11 +485,11 @@
485485
int warningDelay = 30;
486486
static int once = 0;
487487
488488
if( sqlite3_db_readonly(g.db, 0) ) return;
489489
if( db_is_protected(PROTECT_READONLY) ) return;
490
- g.zPhase = "backoffice";
490
+ g.zPhase = "backoffice-pending";
491491
backoffice_error_check_one(&once);
492492
idSelf = backofficeProcessId();
493493
while(1){
494494
tmNow = time(0);
495495
db_begin_write();
@@ -514,10 +514,11 @@
514514
x.tmNext = 0;
515515
backofficeWriteLease(&x);
516516
db_end_transaction(0);
517517
backofficeTrace("/***** Begin Backoffice Processing %d *****/\n",
518518
GETPID());
519
+ g.zPhase = "backoffice-work";
519520
backoffice_work();
520521
break;
521522
}
522523
if( backofficeNoDelay || db_get_boolean("backoffice-nodelay",0) ){
523524
/* If the no-delay flag is set, exit immediately rather than queuing
@@ -642,14 +643,17 @@
642643
backofficeBlob = &log;
643644
blob_appendf(&log, "%s %s", db_text(0, "SELECT datetime('now')"), zName);
644645
}
645646
646647
/* Here is where the actual work of the backoffice happens */
648
+ g.zPhase = "backoffice-alerts";
647649
nThis = alert_backoffice(0);
648650
if( nThis ){ backoffice_log("%d alerts", nThis); nTotal += nThis; }
651
+ g.zPhase = "backoffice-hooks";
649652
nThis = hook_backoffice();
650653
if( nThis ){ backoffice_log("%d hooks", nThis); nTotal += nThis; }
654
+ g.zPhase = "backoffice-close";
651655
652656
/* Close the log */
653657
if( backofficeFILE ){
654658
if( nTotal || backofficeLogDetail ){
655659
if( nTotal==0 ) backoffice_log("no-op");
656660
--- src/backoffice.c
+++ src/backoffice.c
@@ -485,11 +485,11 @@
485 int warningDelay = 30;
486 static int once = 0;
487
488 if( sqlite3_db_readonly(g.db, 0) ) return;
489 if( db_is_protected(PROTECT_READONLY) ) return;
490 g.zPhase = "backoffice";
491 backoffice_error_check_one(&once);
492 idSelf = backofficeProcessId();
493 while(1){
494 tmNow = time(0);
495 db_begin_write();
@@ -514,10 +514,11 @@
514 x.tmNext = 0;
515 backofficeWriteLease(&x);
516 db_end_transaction(0);
517 backofficeTrace("/***** Begin Backoffice Processing %d *****/\n",
518 GETPID());
 
519 backoffice_work();
520 break;
521 }
522 if( backofficeNoDelay || db_get_boolean("backoffice-nodelay",0) ){
523 /* If the no-delay flag is set, exit immediately rather than queuing
@@ -642,14 +643,17 @@
642 backofficeBlob = &log;
643 blob_appendf(&log, "%s %s", db_text(0, "SELECT datetime('now')"), zName);
644 }
645
646 /* Here is where the actual work of the backoffice happens */
 
647 nThis = alert_backoffice(0);
648 if( nThis ){ backoffice_log("%d alerts", nThis); nTotal += nThis; }
 
649 nThis = hook_backoffice();
650 if( nThis ){ backoffice_log("%d hooks", nThis); nTotal += nThis; }
 
651
652 /* Close the log */
653 if( backofficeFILE ){
654 if( nTotal || backofficeLogDetail ){
655 if( nTotal==0 ) backoffice_log("no-op");
656
--- src/backoffice.c
+++ src/backoffice.c
@@ -485,11 +485,11 @@
485 int warningDelay = 30;
486 static int once = 0;
487
488 if( sqlite3_db_readonly(g.db, 0) ) return;
489 if( db_is_protected(PROTECT_READONLY) ) return;
490 g.zPhase = "backoffice-pending";
491 backoffice_error_check_one(&once);
492 idSelf = backofficeProcessId();
493 while(1){
494 tmNow = time(0);
495 db_begin_write();
@@ -514,10 +514,11 @@
514 x.tmNext = 0;
515 backofficeWriteLease(&x);
516 db_end_transaction(0);
517 backofficeTrace("/***** Begin Backoffice Processing %d *****/\n",
518 GETPID());
519 g.zPhase = "backoffice-work";
520 backoffice_work();
521 break;
522 }
523 if( backofficeNoDelay || db_get_boolean("backoffice-nodelay",0) ){
524 /* If the no-delay flag is set, exit immediately rather than queuing
@@ -642,14 +643,17 @@
643 backofficeBlob = &log;
644 blob_appendf(&log, "%s %s", db_text(0, "SELECT datetime('now')"), zName);
645 }
646
647 /* Here is where the actual work of the backoffice happens */
648 g.zPhase = "backoffice-alerts";
649 nThis = alert_backoffice(0);
650 if( nThis ){ backoffice_log("%d alerts", nThis); nTotal += nThis; }
651 g.zPhase = "backoffice-hooks";
652 nThis = hook_backoffice();
653 if( nThis ){ backoffice_log("%d hooks", nThis); nTotal += nThis; }
654 g.zPhase = "backoffice-close";
655
656 /* Close the log */
657 if( backofficeFILE ){
658 if( nTotal || backofficeLogDetail ){
659 if( nTotal==0 ) backoffice_log("no-op");
660

Keyboard Shortcuts

Open search /
Next entry (timeline) j
Previous entry (timeline) k
Open focused entry Enter
Show this help ?
Toggle theme Top nav button