pg.ddx.io  pgsql-bugs@postgresql.org mailing list archive  
help / color / mirror / Atom feed
BUG #12718: Apparent LWlock Problem Perhaps With Page Cleanup
3+ messages / 3 participants
[nested] [flat]

* BUG #12718: Apparent LWlock Problem Perhaps With Page Cleanup
@ 2015-01-30 22:14  charles.harwood@zuerchertech.com
  0 siblings, 1 reply; 3+ messages in thread

From: charles.harwood@zuerchertech.com @ 2015-01-30 22:14 UTC (permalink / raw)
  To: pgsql-bugs

The following bug has been logged on the website:

Bug reference:      12718
Logged by:          Charles R. Harwood
Email address:      charles.harwood@zuerchertech.com
PostgreSQL version: 9.3.5
Operating system:   Ubuntu  Linux 12.04 Kernel 3.13.0
Description:        

Many postgres worker processes stopped responding.  They continued to be in
state 'active' and not 'waiting' for hours.  Each query was on the table
that an autovacuum process was also hung on processing and was the oldest
active transaction on.

Eventually I had to restart the cluster.

The theory is that somehow the VACUUM got the table in a state such that
certain queries ran against it would get hung trying to wrestle an LWlock
away from it.



This shows a subset of the pg_stat_activity many hours into the problem:
# SELECT NOW() - xact_start AS xact_age, query_start, pid, waiting, state,
SUBSTRING(query, 1, 30) FROM pg_stat_activity WHERE state <> 'idle' ORDER BY
NOW() - xact_start DESC;
        xact_age | query_start | pid | waiting | state | substring
-----------------+-------------------------------+-------+---------+--------+----------------------------------------------------
 20:04:20.469875 | 2015-01-29 17:39:21.520094-06 | 24718 | f | active |
autovacuum: VACUUM public.addr
 19:59:58.066609 | 2015-01-29 17:43:43.92336-06 | 24687 | f | active |
SELECT s0.id AS id, f0, f1, f1
 19:59:40.054033 | 2015-01-29 17:44:01.935936-06 | 21386 | f | active |
SELECT s0.id AS id, f0, f1, f1
 19:59:24.117727 | 2015-01-29 17:44:17.872242-06 | 20370 | f | active |
SELECT s0.id AS id, f0, f1, f1
 19:32:51.946155 | 2015-01-29 18:10:50.064425-06 | 2900 | f | active |
UPDATE addresses...
 19:11:38.715295 | 2015-01-29 18:32:03.274674-06 | 13545 | f | active |
SELECT s0.id AS id, f0, f1, f1
 18:53:00.421641 | 2015-01-29 18:50:41.568328-06 | 2367 | f | active |
SELECT '', '', street, city, s
 12:53:32.658331 | 2015-01-30 00:50:09.331638-06 | 22220 | f | active |
SELECT '', '', street, city, s
 11:46:31.322061 | 2015-01-30 01:57:10.667908-06 | 17054 | f | active |
SELECT addressesid FROM ((SEL
 11:36:33.11271 | 2015-01-30 02:07:08.877259-06 | 22378 | f | active |
SELECT addressesid FROM ((SEL
 07:43:06.642865 | 2015-01-30 06:00:37.139222-06 | 26815 | f | active |
SELECT s0.id AS id, f0, f1, f1
 04:03:57.508697 | 2015-01-30 09:39:44.481272-06 | 19351 | f | active |
SELECT addressesid FROM ((SEL
 03:37:39.971883 | 2015-01-30 10:06:02.018086-06 | 10422 | f | active |
SELECT addressesid FROM ((SEL
 02:39:14.576335 | 2015-01-30 11:04:27.413634-06 | 21364 | f | active |
SELECT addressesid FROM ((SEL
 02:24:00.125199 | 2015-01-30 11:19:41.86477-06 | 14600 | f | active |
SELECT addressesid FROM ((SEL
 02:03:32.915133 | 2015-01-30 11:40:09.074836-06 | 22547 | f | active |
SELECT addressesid FROM ((SEL
 01:53:49.639909 | 2015-01-30 11:49:52.35006-06 | 31567 | f | active |
SELECT s0.id AS id, f0, f1, f1
 01:53:44.700417 | 2015-01-30 11:49:57.289552-06 | 31571 | f | active |
SELECT s0.id AS id, f0, f1, f1
 01:53:39.645157 | 2015-01-30 11:50:02.344812-06 | 31623 | f | active |
SELECT s0.id AS id, f0, f1, f1
 01:53:20.892623 | 2015-01-30 11:50:21.097346-06 | 31887 | f | active |
SELECT s0.id AS id, f0, f1, f1
 01:08:30.519618 | 2015-01-30 12:35:11.470351-06 | 21167 | f | active |
SELECT namesid, name, type, in
 01:06:58.586233 | 2015-01-30 12:36:43.403736-06 | 24513 | f | active |
SELECT data.f5 AS y_id, data.f
 01:06:18.159009 | 2015-01-30 12:37:23.83096-06 | 21047 | f | active |
SELECT namesid, name, type, in


Here is what those processes were up to.  I have full backtraces which I
will attach when this gets to a bugtracker.

 # ps -o pid,s,cmd,wchan=WIDE-WCHAN-COLUMN -p
2367,2900,10422,13545,14600,17054,19351,20370,21047,21167,21364,21386,22220,22378,22547,24513,24687,24718,26815,31567,31571,31623,31887
PID S CMD WIDE-WCHAN-COLUMN 
2367 S postgres: leds leds 164.154 SYSC_semtimedop 
2900 S postgres: leds leds [local] SYSC_semtimedop 
10422 S postgres: leds leds 164.154 SYSC_semtimedop 
13545 S postgres: leds leds 164.154 SYSC_semtimedop 
14600 S postgres: leds leds 164.154 SYSC_semtimedop 
17054 S postgres: leds leds 164.154 SYSC_semtimedop 
19351 S postgres: leds leds 164.154 SYSC_semtimedop 
20370 S postgres: leds leds 164.154 SYSC_semtimedop 
21047 S postgres: leds leds 164.154 SYSC_semtimedop 
21167 S postgres: leds leds 164.154 SYSC_semtimedop 
21364 S postgres: leds leds 164.154 SYSC_semtimedop 
21386 S postgres: leds leds 164.154 SYSC_semtimedop 
22220 S postgres: leds leds 164.154 SYSC_semtimedop 
22378 S postgres: leds leds 164.154 SYSC_semtimedop 
22547 S postgres: leds leds 164.154 SYSC_semtimedop 
24513 R postgres: leds leds 164.154 - 
24687 S postgres: leds leds 164.154 SYSC_semtimedop 
24718 S postgres: autovacuum worker poll_schedule_timeout 
26815 S postgres: leds leds 164.154 SYSC_semtimedop 
31567 S postgres: leds leds 164.154 SYSC_semtimedop 
31571 S postgres: leds leds 164.154 SYSC_semtimedop 
31623 S postgres: leds leds 164.154 SYSC_semtimedop 
31887 S postgres: leds leds 164.154 SYSC_semtimedop


Not sure if it will help finding how this happened, but it has happened
twice, both times on relatively large databases (tens to hundreds of
gigabytes) with several hundred concurrent connectons.  Both times it
happened while running a long-running script that updates each record in the
'addresses' table.  The table contains 1-5 million records, each ~1KB wide
and references several other tables and is itself referenced by a dozen
tables.  

The script starts a transaction, runs 20 single-record UPDATEs in quick
succession, COMMITs, and then briefly sleeps.  So if nothing else, the txid
is going up fairly rapidly and the database is working reasonably hard.

Hardware does not appear to be a factor, but both servers on which this
occurred are Dell rackmount servers with two modern intel chips ~E5-2630s
and 32-128GB of memory.

Again, stack traces will be attached.

Thank you.
-Charles


-- 
Sent via pgsql-bugs mailing list (pgsql-bugs@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-bugs



^ permalink  raw  reply  [nested|flat] 3+ messages in thread

* Re: BUG #12718: Apparent LWlock Problem Perhaps With Page Cleanup
@ 2015-01-31 00:41  Peter Geoghegan <pg@heroku.com>
  parent: charles.harwood@zuerchertech.com
  0 siblings, 1 reply; 3+ messages in thread

From: Peter Geoghegan @ 2015-01-31 00:41 UTC (permalink / raw)
  To: charles.harwood@zuerchertech.com; +Cc: pgsql-bugs

On Fri, Jan 30, 2015 at 2:14 PM,  <charles.harwood@zuerchertech.com> wrote:
> Many postgres worker processes stopped responding.  They continued to be in
> state 'active' and not 'waiting' for hours.  Each query was on the table
> that an autovacuum process was also hung on processing and was the oldest
> active transaction on.


Was pg_upgrade run on this database at some point [1]?

I foresee more problems here...

[1] http://www.postgresql.org/message-id/20140825225029.2536.5315@wrigleys.postgresql.org
-- 
Peter Geoghegan


-- 
Sent via pgsql-bugs mailing list (pgsql-bugs@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-bugs



^ permalink  raw  reply  [nested|flat] 3+ messages in thread

* Re: BUG #12718: Apparent LWlock Problem Perhaps With Page Cleanup
@ 2015-02-02 17:27  Charles R. Harwood <charles.harwood@zuerchertech.com>
  parent: Peter Geoghegan <pg@heroku.com>
  0 siblings, 0 replies; 3+ messages in thread

From: Charles R. Harwood @ 2015-02-02 17:27 UTC (permalink / raw)
  To: Peter Geoghegan <pg@heroku.com>; +Cc: pgsql-bugs

Yes.  It was pg_upgrad-ed from 9.2 almost a year ago (2014-02-27). 
Unfortunately, I do not have the 9.2 data anymore.

It was pg_upgraded with the binaries in postgresql 9.3.1 which I
understand were affected by a bug related to leaving pg_multixact files
behind as per
http://www.postgresql.org/docs/9.4/static/release-9-3-5.html.  But the
query associated with the offsets/0000 bug, if I understand it, doesn't
seem to apply because offset 0000 doesn't exist in my case and therefore
the associated query returns False.

I'm afraid my grasp of MultiXacts isn't up to the task of understand
exactly what's going on.  By the time this issue is resolved I'm sure
I'll understand them better than I ever wanted to.  I'll attempt to
supply the same information as was requested in the referenced thread.



Here is the pg_controldata output:

pg_control version number:            937
Catalog version number:               201306121
Database system identifier:           5985061615841541596
Database cluster state:               in production
pg_control last modified:             Mon 02 Feb 2015 10:50:00 AM CST
Latest checkpoint location:           43A/607AD468
Prior checkpoint location:            43A/5DBA9040
Latest checkpoint's REDO location:    43A/5FF7A3C8
Latest checkpoint's REDO WAL file:    000000010000043A0000005F
Latest checkpoint's TimeLineID:       1
Latest checkpoint's PrevTimeLineID:   1
Latest checkpoint's full_page_writes: on
Latest checkpoint's NextXID:          0/487855284
Latest checkpoint's NextOID:          134556810
Latest checkpoint's NextMultiXactId:  1183038
Latest checkpoint's NextMultiOffset:  2584953
Latest checkpoint's oldestXID:        289465105
Latest checkpoint's oldestXID's DB:   16414
Latest checkpoint's oldestActiveXID:  487855284
Latest checkpoint's oldestMultiXid:   1
Latest checkpoint's oldestMulti's DB: 16414
Time of latest checkpoint:            Mon 02 Feb 2015 10:47:30 AM CST
Fake LSN counter for unlogged rels:   0/1
Minimum recovery ending location:     0/0
Min recovery ending loc's timeline:   0
Backup start location:                0/0
Backup end location:                  0/0
End-of-backup record required:        no
Current wal_level setting:            hot_standby
Current max_connections setting:      1000
Current max_prepared_xacts setting:   0
Current max_locks_per_xact setting:   128
Maximum data alignment:               8
Database block size:                  8192
Blocks per segment of large relation: 131072
WAL block size:                       8192
Bytes per WAL segment:                16777216
Maximum length of identifiers:        64
Maximum columns in an index:          32
Maximum size of a TOAST chunk:        1996
Date/time type storage:               64-bit integers
Float4 argument passing:              by value
Float8 argument passing:              by value
Data page checksum version:           0



leds=# SELECT datname, datfrozenxid, datminmxid FROM pg_database WHERE
datname = 'leds';
 datname | datfrozenxid | datminmxid
---------+--------------+------------
 leds    |    289465105 |          1
(1 row)



leds=# SELECT oid::regclass, relnamespace, relfrozenxid, relminmxid FROM
pg_class WHERE relname = 'addresses' AND relnamespace = 2200;
    oid    | relnamespace | relfrozenxid | relminmxid
-----------+--------------+--------------+------------
 addresses |         2200 |    354953499 |     261502



The oldest file in the cluster's pg_multixact/offsets directory is 0003
which as a modify time within an hour of pg_upgrade on 2014-02-27.

^ permalink  raw  reply  [nested|flat] 3+ messages in thread


end of thread, other threads:[~2015-02-02 17:27 UTC | newest]

Thread overview: 3+ messages (download: mbox mbox.gz follow: Atom feed)
-- links below jump to the message on this page --
2015-01-30 22:14 BUG #12718: Apparent LWlock Problem Perhaps With Page Cleanup charles.harwood@zuerchertech.com
2015-01-31 00:41 ` Peter Geoghegan <pg@heroku.com>
2015-02-02 17:27   ` Charles R. Harwood <charles.harwood@zuerchertech.com>

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