Received: from makus.postgresql.org (makus.postgresql.org [98.129.198.125]) by mail.postgresql.org (Postfix) with ESMTP id 895C519BA3A5 for ; Thu, 31 May 2012 05:09:34 -0300 (ADT) Received: from mailout-de.gmx.net ([213.165.64.22]) by makus.postgresql.org with smtp (Exim 4.72) (envelope-from ) id 1Sa0Rl-0001BK-6l for pgsql-bugs@postgresql.org; Thu, 31 May 2012 08:09:33 +0000 Received: (qmail invoked by alias); 31 May 2012 08:09:15 -0000 Received: from a88-115-214-103.elisa-laajakaista.fi (EHLO [10.0.0.104]) [88.115.214.103] by mail.gmx.net (mp028) with SMTP; 31 May 2012 10:09:15 +0200 X-Authenticated: #495269 X-Provags-ID: V01U2FsdGVkX1+VR8U/Rm2V73E1cXZzx1D2soyB5ltU/DlJfEo6r2 KIhE6JTbLWlXJ7 Message-ID: <1338451752.22408.7.camel@vanquo.pezone.net> Subject: Re: overwriting an existing .so while being used crashes the server process From: Peter Eisentraut To: Tomas Vondra Cc: Tom Lane , pgsql-bugs@postgresql.org Date: Thu, 31 May 2012 11:09:12 +0300 In-Reply-To: <4FC69487.7000106@fuzzy.cz> References: <4FC6833C.6080501@fuzzy.cz> <8227.1338410155@sss.pgh.pa.us> <4FC68C3B.4060609@fuzzy.cz> <9187.1338412749@sss.pgh.pa.us> <4FC69487.7000106@fuzzy.cz> Content-Type: text/plain; charset="UTF-8" X-Mailer: Evolution 3.2.2-1 Content-Transfer-Encoding: 7bit Mime-Version: 1.0 X-Y-GMX-Trusted: 0 X-Pg-Spam-Score: -1.9 (-) X-Archive-Number: 201205/235 X-Sequence-Number: 33206 On ons, 2012-05-30 at 23:43 +0200, Tomas Vondra wrote: > On 30.5.2012 23:19, Tom Lane wrote: > > I suspect it depends on how you install the new version of the library, > > too. I would somewhat expect it to work as you're thinking if the > > install consists of "rename old file out of the way, copy new file into > > place, unlink old file" or equivalent. If you are actually > > *overwriting* the file in place, a crash does not seem especially > > surprising --- it would make perfect sense if the kernel expects the > > file to be usable as backing store for the in-memory image, which is not > > exactly unreasonable. IOW, if the in-memory bits we're executing are > > just an mmap'd image of the .so file, changing the .so file could > > entirely be expected to lead to a crash. > > Aha! That might be the culprit - I've just tested that deleting the olf > file and copying new version (thus not overwriting it) did not cause a > crash. Funny. That's one of the reasons why one normally uses "install" rather than "cp" to install files. So this shouldn't be a problem in practice if people use the provided pgxs infrastructure or something similar. GNU cp has the --remove-destination option, which should also work for this purpose.