Commit db98464a authored by Geoff Simmons's avatar Geoff Simmons

Fix VSM re-attach for error handling.

Only attempt to re-attach if the management process stopped. On
errors such as overrun or log abandoned, the VSL API considers
the client as still attached, and VSM_Attach() throws an assertion.
parent fac6c276
...@@ -884,14 +884,16 @@ CHILD_Main(int readconfig) ...@@ -884,14 +884,16 @@ CHILD_Main(int readconfig)
break; break;
} }
} }
if (flush && !term) { if (flush && !term) {
LOG_Log0(LOG_NOTICE, "Flushing transactions"); LOG_Log0(LOG_NOTICE, "Flushing transactions");
take_free(); take_free();
do {} do {}
while (VSLQ_Flush(vslq, dispatch, NULL) != DISPATCH_RETURN_OK); while (VSLQ_Flush(vslq, dispatch, NULL) != DISPATCH_RETURN_OK);
flush = 0; flush = 0;
if (EMPTY(config.varnish_bindump) && status != DISPATCH_CLOSED if (!restart && EMPTY(config.varnish_bindump)
&& status != DISPATCH_OVERRUN && status != DISPATCH_IOERR) && status != DISPATCH_CLOSED && status != DISPATCH_OVERRUN
&& status != DISPATCH_IOERR)
continue; continue;
VSLQ_Delete(&vslq); VSLQ_Delete(&vslq);
AZ(vslq); AZ(vslq);
...@@ -900,6 +902,7 @@ CHILD_Main(int readconfig) ...@@ -900,6 +902,7 @@ CHILD_Main(int readconfig)
mgt_restart++; mgt_restart++;
LOG_Log0(LOG_ALERT, LOG_Log0(LOG_ALERT,
"Varnish management process status changed"); "Varnish management process status changed");
VTIM_sleep(0.1);
for (;;) { for (;;) {
VSM_Destroy(&vsm); VSM_Destroy(&vsm);
vsm = VSM_New(); vsm = VSM_New();
...@@ -914,6 +917,13 @@ CHILD_Main(int readconfig) ...@@ -914,6 +917,13 @@ CHILD_Main(int readconfig)
if (!(VSM_Status(vsm) & VSM_MGT_RUNNING)) if (!(VSM_Status(vsm) & VSM_MGT_RUNNING))
LOG_Log0(LOG_ALERT, LOG_Log0(LOG_ALERT,
"Varnish management process not running"); "Varnish management process not running");
if (VSM_Attach(vsm, -1) < 0) {
LOG_Log(LOG_CRIT, "Log re-attach failed: %s\n",
VSM_Error(vsm));
VSM_ResetError(vsm);
VTIM_sleep(1);
continue;
}
break; break;
} }
LOG_Log0(LOG_NOTICE, "Shared memory attach re-initialized"); LOG_Log0(LOG_NOTICE, "Shared memory attach re-initialized");
...@@ -924,10 +934,6 @@ CHILD_Main(int readconfig) ...@@ -924,10 +934,6 @@ CHILD_Main(int readconfig)
while (vslq == NULL) { while (vslq == NULL) {
AN(vsm); AN(vsm);
VTIM_sleep(0.1); VTIM_sleep(0.1);
if (VSM_Attach(vsm, -1) < 0) {
VSM_ResetError(vsm);
continue;
}
cursor = VSL_CursorVSM(vsl, vsm, cursor = VSL_CursorVSM(vsl, vsm,
VSL_COPT_TAIL | VSL_COPT_BATCH); VSL_COPT_TAIL | VSL_COPT_BATCH);
if (cursor == NULL) { if (cursor == NULL) {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment