pg.ddx.io  pgsql-hackers@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Bernd Helmle <mailings@oopsware.de>
To: Konstantin Knizhnik <k.knizhnik@postgrespro.ru>
To: pgsql-hackers@postgresql.org
Subject: Re: Deadlock in XLogInsert at AIX
Date: Mon, 30 Jan 2017 15:26:20 +0100
Message-ID: <1485786380.3084.2.camel@oopsware.de> (raw)
In-Reply-To: <100ec553-b398-7730-c676-57a5e375cb68@postgrespro.ru>
References: <a72cfcb0-37d0-de2f-b3ec-f38ad8d6a8cc@postgrespro.ru>
	<100ec553-b398-7730-c676-57a5e375cb68@postgrespro.ru>
List-Unsubscribe: <mailto:majordomo@postgresql.org?body=unsub%20pgsql-hackers>

Hi Konstantin,

We had observed exactly the same issues on a customer system with the
same environment and PostgreSQL 9.5.5. Additionally, we've tested on
Linux with XL/C 12 and 13 with exactly the same deadlock behavior. 

So we assumed that this is somehow a compiler issue.

Am Dienstag, den 24.01.2017, 19:26 +0300 schrieb Konstantin Knizhnik:
> More information about the problem - Postgres log contains several
> records:
> 
> 2017-01-24 19:15:20.272 MSK [19270462] LOG:  request to flush past
> end 
> of generated WAL; request 6/AAEBE000, currpos 6/AAEBC2B0
> 
> and them correspond to the time when deadlock happen.

Yeah, the same logs here:

LOG:  request to flush past end of generated WAL; request 1/1F4C6000,
currpos 1/1F4C40E0
STATEMENT:  UPDATE pgbench_accounts SET abalance = abalance + -2653
WHERE aid = 3662494;


> There is the following comment in xlog.c concerning this message:
> 
>      /*
>       * No-one should request to flush a piece of WAL that hasn't
> even been
>       * reserved yet. However, it can happen if there is a block with
> a 
> bogus
>       * LSN on disk, for example. XLogFlush checks for that situation
> and
>       * complains, but only after the flush. Here we just assume that
> to 
> mean
>       * that all WAL that has been reserved needs to be finished. In
> this
>       * corner-case, the return value can be smaller than 'upto'
> argument.
>       */
> 
> So looks like it should not happen.
> The first thing to suspect is spinlock implementation which is
> different 
> for GCC and XLC.
> But ... if I rebuild Postgres without spinlocks, then the problem is 
> still reproduced.

Before we got the results from XLC on Linux (where Postgres show the
same behavior) i had a look into the spinlock implementation. If i got
it right, XLC doesn't use the ppc64 specific ones, but the fallback
implementation (system monitoring on AIX also has shown massive calls
for signal(0)...). So i tried the following patch:

diff --git a/src/include/port/atomics/arch-ppc.h
b/src/include/port/atomics/arch-ppc.h
new file mode 100644
index f901a0c..028cced
inline patch 1: src/include/port/atomics/arch-ppc.h (+0/-0 lines) download inline-1.patch*** a/src/include/port/atomics/arch-ppc.h --- b/src/include/port/atomics/arch-ppc.h *************** *** 23,26 **** --- 23,33 ----
  #define pg_memory_barrier_impl()      __asm__ __volatile__ ("sync" : : : "memory")   #define pg_read_barrier_impl()                __asm__ __volatile__ ("lwsync" : : : "memory")   #define pg_write_barrier_impl()               __asm__ __volatile__ ("lwsync" : : : "memory") + + #elif defined(__IBMC__) || defined(__IBMCPP__) + + #define pg_memory_barrier_impl()      __asm__ __volatile__ (" sync \n" ::: "memory") + #define pg_read_barrier_impl()                __asm__ __volatile__ (" lwsync \n" ::: "memory") + #define pg_write_barrier_impl()               __asm__ __volatile__ (" lwsync \n" ::: "memory") +   #endif This didn't change the picture, though. -- Sent via pgsql-hackers mailing list (pgsql-hackers@postgresql.org) To make changes to your subscription: http://www.postgresql.org/mailpref/pgsql-hackers

view thread (51+ messages)  latest in thread

Message-ID: <1485786380.3084.2.camel@oopsware.de>
Permalink:  ../1485786380.3084.2.camel@oopsware.de/
Also on:    postgresql.org/message-id/1485786380.3084.2.camel@oopsware.de

 ·  · 

reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients from your mail client; the link fills in
  the headers below: reply via email
  Some clients, webmail especially, drop In-Reply-To and References from
  a link, and the reply then starts a new thread: use the mbox below.

  To: pgsql-hackers@postgresql.org
  Cc: mailings@oopsware.de, k.knizhnik@postgrespro.ru
  Subject: Re: Deadlock in XLogInsert at AIX
  In-Reply-To: <1485786380.3084.2.camel@oopsware.de>
  References: <a72cfcb0-37d0-de2f-b3ec-f38ad8d6a8cc@postgrespro.ru> <100ec553-b398-7730-c676-57a5e375cb68@postgrespro.ru> <1485786380.3084.2.camel@oopsware.de>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

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