This is a discussion on What is happening on buildfarm member baiji? within the pgsql Hackers forums, part of the PostgreSQL category; --> Tom Lane wrote: > Magnus Hagander <magnus@hagander.net> writes: >> + sprintf(mutexName,"postgresql.interlock.%i", portNumber); > > That won't do; it should ...
| |||||||
| Register | FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read |
| ||||
| Tom Lane wrote: > Magnus Hagander <magnus@hagander.net> writes: >> + sprintf(mutexName,"postgresql.interlock.%i", portNumber); > > That won't do; it should be legal for two postmasters to listen on > different IP addresses using the same port number. So you need to > include some representation of the IP address being bound to. > >> + if (GetLastError() == ERROR_ALREADY_EXISTS) >> + ereport(FATAL, >> + (errcode(ERRCODE_LOCK_FILE_EXISTS), >> + errmsg("interlock mutex \"%s\" already exists", mutexName), >> + errhint("Is another postgres listening on port %i", portNumber))); > > ereport(FATAL) is quite inappropriate here. Do the same thing that > bind() failure would do, ie, ereport(LOG) and continue the loop. > Also, you probably need to think about cleaning up the mutex in > case one of the later steps of socket-acquisition fails. We should > only be holding locks on addresses we've successfully bound. I've done some further research on this on Win32, and I've come up with the following: If I set the flag SO_EXCLUSIVEADDRUSE, I get the same behavior as on Unix: Can only create one postmaster at a time on the same addr/port, and if I close the backend with a psql session running I can't create a new one until there is a timeout passed. However, if I just *skip* setting SO_REUSEADDR completely, things seem to work the way we want it. I cannot start more than one postmaster on the same addr/port. If I start a psql, then terminate postmaster, I can restart a new postmaster right away. Given this, I propose we simply #ifdef out the SO_REUSEADDR on win32. Anybody see a problem with this? (A fairly good reference to read up on the options is at http://msdn2.microsoft.com/en-us/library/ms740621.aspx - which specifically talks about the issue seen on Unix as appearing with the SO_EXCLUSIVEADDRUSE parameter, which agrees with my testresults) //Magnus ---------------------------(end of broadcast)--------------------------- TIP 3: Have you checked our extensive FAQ? http://www.postgresql.org/docs/faq |
| |||
| Magnus Hagander wrote: > > However, if I just *skip* setting SO_REUSEADDR completely, things seem > to work the way we want it. I cannot start more than one postmaster on > the same addr/port. If I start a psql, then terminate postmaster, I can > restart a new postmaster right away. > > Given this, I propose we simply #ifdef out the SO_REUSEADDR on win32. > Anybody see a problem with this? > > > Is that true even if the backend crashes? cheers andrew ---------------------------(end of broadcast)--------------------------- TIP 7: You can help support the PostgreSQL project by donating at http://www.postgresql.org/about/donate |
| |||
| Andrew Dunstan <andrew@dunslane.net> writes: > Magnus Hagander wrote: >> Given this, I propose we simply #ifdef out the SO_REUSEADDR on win32. >> Anybody see a problem with this? > Is that true even if the backend crashes? It would take a postmaster crash to make this an issue, and those are pretty doggone rare. Not that the question shouldn't be checked, but we might decide to tolerate the problem if there is one ... regards, tom lane ---------------------------(end of broadcast)--------------------------- TIP 9: In versions below 8.0, the planner will ignore your desire to choose an index scan if your joining column's datatypes do not match |
| |||
| Magnus Hagander <magnus@hagander.net> writes: > Given this, I propose we simply #ifdef out the SO_REUSEADDR on win32. > Anybody see a problem with this? > (A fairly good reference to read up on the options is at > http://msdn2.microsoft.com/en-us/library/ms740621.aspx Hmm ... if accurate, that page says in words barely longer than one syllable that Microsoft entirely misunderstands the intended meaning of SO_REUSEADDR. It looks like SO_EXCLUSIVEADDRUSE might be a bit closer to the standard semantics; should we use that instead on Windoze? regards, tom lane ---------------------------(end of broadcast)--------------------------- TIP 1: if posting/reading through Usenet, please send an appropriate subscribe-nomail command to majordomo@postgresql.org so that your message can get through to the mailing list cleanly |
| |||
| On Sun, Jun 03, 2007 at 11:29:33PM -0400, Tom Lane wrote: > Magnus Hagander <magnus@hagander.net> writes: > > Given this, I propose we simply #ifdef out the SO_REUSEADDR on win32. > > Anybody see a problem with this? > > > (A fairly good reference to read up on the options is at > > http://msdn2.microsoft.com/en-us/library/ms740621.aspx > > Hmm ... if accurate, that page says in words barely longer than one > syllable that Microsoft entirely misunderstands the intended meaning > of SO_REUSEADDR. Yes, that's how I read it as well. > It looks like SO_EXCLUSIVEADDRUSE might be a bit closer to the standard > semantics; should we use that instead on Windoze? I think you're reading something wrong. The way I read it, SO_EXCLUSIVEADDRUSE gives us pretty much the same behavior we have on Unix *without* SO_REUSEADDR. There's a paragraph specificallyi talking about the problem of restarting a server having to wait for a timeout when using this switch. //Magnus ---------------------------(end of broadcast)--------------------------- TIP 5: don't forget to increase your free space map settings |
| |||
| On Sun, Jun 03, 2007 at 10:44:13PM -0400, Tom Lane wrote: > Andrew Dunstan <andrew@dunslane.net> writes: > > Magnus Hagander wrote: > >> Given this, I propose we simply #ifdef out the SO_REUSEADDR on win32. > >> Anybody see a problem with this? > > > Is that true even if the backend crashes? > > It would take a postmaster crash to make this an issue, and those are > pretty doggone rare. Not that the question shouldn't be checked, but > we might decide to tolerate the problem if there is one ... The closest I can get is a kill -9 on postmaster, and that does work. I can't start a new postmaster while the old backend is running - because of the shared memory detection stuff. But the second it's gone I can start a new one, so it doesn't have that wait-until-timeout behavior. Since that's expected behavior and there were no other complaints, I think I'll go ahead an put this one in later today. //Magnus ---------------------------(end of broadcast)--------------------------- TIP 2: Don't 'kill -9' the postmaster |
| ||||
| > > > Given this, I propose we simply #ifdef out the SO_REUSEADDR on win32. I agree, that this is what we should do. > > > (A fairly good reference to read up on the options is at > > > http://msdn2.microsoft.com/en-us/library/ms740621.aspx > > > > Hmm ... if accurate, that page says in words barely longer than one > > syllable that Microsoft entirely misunderstands the intended meaning > > of SO_REUSEADDR. > > Yes, that's how I read it as well. > > > It looks like SO_EXCLUSIVEADDRUSE might be a bit closer to the > > standard semantics; should we use that instead on Windoze? > > I think you're reading something wrong. The way I read it, > SO_EXCLUSIVEADDRUSE gives us pretty much the same behavior we have on Unix > *without* SO_REUSEADDR. There's a paragraph specificallyi > talking about the problem of restarting a server having to > wait for a timeout when using this switch. Yup, that switch is no good eighter. Andreas ---------------------------(end of broadcast)--------------------------- TIP 2: Don't 'kill -9' the postmaster |