pg.ddx.io pgsql-general@postgresql.org mailing list archive
help / color / mirror / Atom feedWindows 10 got stuck with PostgreSQL at starting up. Adding delay lets it avoid.
4+ messages / 2 participants
[nested] [flat]
* Windows 10 got stuck with PostgreSQL at starting up. Adding delay lets it avoid.
@ 2018-06-29 06:03 TAKATSUKA Haruka <harukat@sraoss.co.jp>
2018-06-29 06:34 ` Re: Windows 10 got stuck with PostgreSQL at starting up. Adding delay lets it avoid. Thomas Kellerer <spam_eater@gmx.net>
0 siblings, 1 reply; 4+ messages in thread
From: TAKATSUKA Haruka @ 2018-06-29 06:03 UTC (permalink / raw)
To: pgsql-general
I got a trouble in PostgreSQL 9.3.x on Windows 10.
I would like to add new delay code as an official build option.
Windows 10 sometime (approximately once in 300 tries) hung up
at OS starting up. The logs say it happened while the PostgreSQL
service was starting. When OS stopped, some postgres auxiliary
process were started and some were not started yet.
The Windows dump say some threads of the postgres auxiliary process
are waiting OS level locks and the logon processes$B!G(Bthread are
also waiting a lock. MS help desk said that PostgreSQL$B!G(Bs OS level
deadlock caused OS freeze. I think it is strange story. But,
in fact, it not happened in repeated tests when I got rid of
PostgreSQL from the initial auto-starting services.
I tweaked PostgreSQL 9.3.x (the newest from the repository) to add
0.5 or 3.0 seconds delay after each sub process starts.
And then the hung up was gone. This test patch is attached.
It is only implemented for Windows. Also, I did not use existing
pg_usleep because it contains locking codes (e.g. WaitForSingleObject
and Enter/LeaveCriticalSection).
Although Windows OS may have some problems, I think we should have
a means to avoid it. Can PostgreSQL be accepted such delay codes
as build-time options by preprocessor variables?
Thanks,
Takatsuka Haruka
Attachments:
postmaster.c_0619_win32delay.diff (text/plain, 1.8K) download
diff --git a/src/backend/postmaster/postmaster.c b/src/backend/postmaster/postmaster.c
index d6fc2ed..ff03ebd 100644
--- a/src/backend/postmaster/postmaster.c
+++ b/src/backend/postmaster/postmaster.c
@@ -398,6 +398,30 @@ extern int optreset; /* might not be declared by system headers */
static DNSServiceRef bonjour_sdref = NULL;
#endif
+#define USE_AFTER_AUX_FORK_SLEEP 3000
+
+#ifdef USE_AFTER_AUX_FORK_SLEEP
+#ifndef WIN32
+#define AFTER_AUX_FORK_SLEEP()
+#else
+#define AFTER_AUX_FORK_SLEEP() do { SleepEx(USE_AFTER_AUX_FORK_SLEEP, FALSE); } while(0)
+#endif
+#else
+#define AFTER_AUX_FORK_SLEEP()
+#endif
+
+#define USE_AFTER_BACKEND_FORK_SLEEP 500
+
+#ifdef USE_AFTER_BACKEND_FORK_SLEEP
+#ifndef WIN32
+#define AFTER_BACKEND_FORK_SLEEP()
+#else
+#define AFTER_BACKEND_FORK_SLEEP() do { SleepEx(USE_AFTER_BACKEND_FORK_SLEEP, FALSE); } while(0)
+#endif
+#else
+#define AFTER_BACKEND_FORK_SLEEP()
+#endif
+
/*
* postmaster.c - function prototypes
*/
@@ -1709,6 +1733,7 @@ ServerLoop(void)
*/
StreamClose(port->sock);
ConnFree(port);
+ AFTER_BACKEND_FORK_SLEEP();
}
}
}
@@ -2801,11 +2826,20 @@ reaper(SIGNAL_ARGS)
* situation, some of them may be alive already.
*/
if (!IsBinaryUpgrade && AutoVacuumingActive() && AutoVacPID == 0)
+ {
AutoVacPID = StartAutoVacLauncher();
+ AFTER_AUX_FORK_SLEEP();
+ }
if (XLogArchivingActive() && PgArchPID == 0)
+ {
PgArchPID = pgarch_start();
+ AFTER_AUX_FORK_SLEEP();
+ }
if (PgStatPID == 0)
+ {
PgStatPID = pgstat_start();
+ AFTER_AUX_FORK_SLEEP();
+ }
/* some workers may be scheduled to start now */
maybe_start_bgworker();
@@ -5259,6 +5293,7 @@ StartChildProcess(AuxProcType type)
/*
* in parent, successful fork
*/
+ AFTER_AUX_FORK_SLEEP();
return pid;
}
^ permalink raw reply [nested|flat] 4+ messages in thread
* Re: Windows 10 got stuck with PostgreSQL at starting up. Adding delay lets it avoid.
2018-06-29 06:03 Windows 10 got stuck with PostgreSQL at starting up. Adding delay lets it avoid. TAKATSUKA Haruka <harukat@sraoss.co.jp>
@ 2018-06-29 06:34 ` Thomas Kellerer <spam_eater@gmx.net>
2018-06-29 08:04 ` Re: Windows 10 got stuck with PostgreSQL at starting up. Adding delay lets it avoid. TAKATSUKA Haruka <harukat@sraoss.co.jp>
0 siblings, 1 reply; 4+ messages in thread
From: Thomas Kellerer @ 2018-06-29 06:34 UTC (permalink / raw)
To: pgsql-general
TAKATSUKA Haruka schrieb am 29.06.2018 um 08:03:
> I got a trouble in PostgreSQL 9.3.x on Windows 10.
> I would like to add new delay code as an official build option.
>
> Windows 10 sometime (approximately once in 300 tries) hung up
> at OS starting up. The logs say it happened while the PostgreSQL
> service was starting. When OS stopped, some postgres auxiliary
> process were started and some were not started yet.
>
> The Windows dump say some threads of the postgres auxiliary process
> are waiting OS level locks and the logon processes’thread are
> also waiting a lock. MS help desk said that PostgreSQL’s OS level
> deadlock caused OS freeze. I think it is strange story. But,
> in fact, it not happened in repeated tests when I got rid of
> PostgreSQL from the initial auto-starting services.
>
> I tweaked PostgreSQL 9.3.x (the newest from the repository) to add
> 0.5 or 3.0 seconds delay after each sub process starts.
> And then the hung up was gone. This test patch is attached.
> It is only implemented for Windows. Also, I did not use existing
> pg_usleep because it contains locking codes (e.g. WaitForSingleObject
> and Enter/LeaveCriticalSection).
>
> Although Windows OS may have some problems, I think we should have
> a means to avoid it. Can PostgreSQL be accepted such delay codes
> as build-time options by preprocessor variables?
Did you try setting the service to "delayed start"?
^ permalink raw reply [nested|flat] 4+ messages in thread
* Re: Windows 10 got stuck with PostgreSQL at starting up. Adding delay lets it avoid.
2018-06-29 06:03 Windows 10 got stuck with PostgreSQL at starting up. Adding delay lets it avoid. TAKATSUKA Haruka <harukat@sraoss.co.jp>
2018-06-29 06:34 ` Re: Windows 10 got stuck with PostgreSQL at starting up. Adding delay lets it avoid. Thomas Kellerer <spam_eater@gmx.net>
@ 2018-06-29 08:04 ` TAKATSUKA Haruka <harukat@sraoss.co.jp>
2018-07-03 10:01 ` Re: Windows 10 got stuck with PostgreSQL at starting up. Adding delay lets it avoid. TAKATSUKA Haruka <harukat@sraoss.co.jp>
0 siblings, 1 reply; 4+ messages in thread
From: TAKATSUKA Haruka @ 2018-06-29 08:04 UTC (permalink / raw)
To: pgsql-general
On Fri, 29 Jun 2018 08:34:18 +0200
Thomas Kellerer <spam_eater@gmx.net> wrote:
> Did you try setting the service to "delayed start"?
We didn't try it yet. Thanks to give an idea. I think that
MS would advise us already if it were a just solution for this case.
Anyway, we will try and confirm it.
Thanks,
Takatsuka Haruka
> TAKATSUKA Haruka schrieb am 29.06.2018 um 08:03:
> > I got a trouble in PostgreSQL 9.3.x on Windows 10.
> > I would like to add new delay code as an official build option.
> >
> > Windows 10 sometime (approximately once in 300 tries) hung up
> > at OS starting up. The logs say it happened while the PostgreSQL
> > service was starting. When OS stopped, some postgres auxiliary
> > process were started and some were not started yet.
> >
> > The Windows dump say some threads of the postgres auxiliary process
> > are waiting OS level locks and the logon processes$B!G(Bthread are
> > also waiting a lock. MS help desk said that PostgreSQL$B!G(Bs OS level
> > deadlock caused OS freeze. I think it is strange story. But,
> > in fact, it not happened in repeated tests when I got rid of
> > PostgreSQL from the initial auto-starting services.
> >
> > I tweaked PostgreSQL 9.3.x (the newest from the repository) to add
> > 0.5 or 3.0 seconds delay after each sub process starts.
> > And then the hung up was gone. This test patch is attached.
> > It is only implemented for Windows. Also, I did not use existing
> > pg_usleep because it contains locking codes (e.g. WaitForSingleObject
> > and Enter/LeaveCriticalSection).
> >
> > Although Windows OS may have some problems, I think we should have
> > a means to avoid it. Can PostgreSQL be accepted such delay codes
> > as build-time options by preprocessor variables?
^ permalink raw reply [nested|flat] 4+ messages in thread
* Re: Windows 10 got stuck with PostgreSQL at starting up. Adding delay lets it avoid.
2018-06-29 06:03 Windows 10 got stuck with PostgreSQL at starting up. Adding delay lets it avoid. TAKATSUKA Haruka <harukat@sraoss.co.jp>
2018-06-29 06:34 ` Re: Windows 10 got stuck with PostgreSQL at starting up. Adding delay lets it avoid. Thomas Kellerer <spam_eater@gmx.net>
2018-06-29 08:04 ` Re: Windows 10 got stuck with PostgreSQL at starting up. Adding delay lets it avoid. TAKATSUKA Haruka <harukat@sraoss.co.jp>
@ 2018-07-03 10:01 ` TAKATSUKA Haruka <harukat@sraoss.co.jp>
0 siblings, 0 replies; 4+ messages in thread
From: TAKATSUKA Haruka @ 2018-07-03 10:01 UTC (permalink / raw)
To: pgsql-general
> On Fri, 29 Jun 2018 08:34:18 +0200
> Thomas Kellerer <spam_eater@gmx.net> wrote:
>
> > Did you try setting the service to "delayed start"?
>
> We didn't try it yet. Thanks to give an idea. I think that
> MS would advise us already if it were a just solution for this case.
> Anyway, we will try and confirm it.
We tried it. "Delayed start" was ineffective.
Also setting a script that start the PostgreSQL service
on the "startup" folder was ineffective.
It has not been solved except by PostgreSQL code modification (inserting delay).
Thanks,
Haruka Takatsuka
> > TAKATSUKA Haruka schrieb am 29.06.2018 um 08:03:
> > > I got a trouble in PostgreSQL 9.3.x on Windows 10.
> > > I would like to add new delay code as an official build option.
> > >
> > > Windows 10 sometime (approximately once in 300 tries) hung up
> > > at OS starting up. The logs say it happened while the PostgreSQL
> > > service was starting. When OS stopped, some postgres auxiliary
> > > process were started and some were not started yet.
> > >
> > > The Windows dump say some threads of the postgres auxiliary process
> > > are waiting OS level locks and the logon processes$B!G(Bthread are
> > > also waiting a lock. MS help desk said that PostgreSQL$B!G(Bs OS level
> > > deadlock caused OS freeze. I think it is strange story. But,
> > > in fact, it not happened in repeated tests when I got rid of
> > > PostgreSQL from the initial auto-starting services.
> > >
> > > I tweaked PostgreSQL 9.3.x (the newest from the repository) to add
> > > 0.5 or 3.0 seconds delay after each sub process starts.
> > > And then the hung up was gone. This test patch is attached.
> > > It is only implemented for Windows. Also, I did not use existing
> > > pg_usleep because it contains locking codes (e.g. WaitForSingleObject
> > > and Enter/LeaveCriticalSection).
> > >
> > > Although Windows OS may have some problems, I think we should have
> > > a means to avoid it. Can PostgreSQL be accepted such delay codes
> > > as build-time options by preprocessor variables?
^ permalink raw reply [nested|flat] 4+ messages in thread
end of thread, other threads:[~2018-07-03 10:01 UTC | newest]
Thread overview: 4+ messages (download: mbox mbox.gz follow: Atom feed)
-- links below jump to the message on this page --
2018-06-29 06:03 Windows 10 got stuck with PostgreSQL at starting up. Adding delay lets it avoid. TAKATSUKA Haruka <harukat@sraoss.co.jp>
2018-06-29 06:34 ` Thomas Kellerer <spam_eater@gmx.net>
2018-06-29 08:04 ` TAKATSUKA Haruka <harukat@sraoss.co.jp>
2018-07-03 10:01 ` TAKATSUKA Haruka <harukat@sraoss.co.jp>
This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox