Docker + postgreSQL : OOM killing in a large Group by operation

2018-04-05 Thread Jorge Daniel
ge_transaction"."xmin"
;
2018-04-05 09:07:25.605 PDT rhost= app=:user=:db=:LOG:  terminating any other 
active server processes
2018-04-05 09:07:25.605 PDT rhost= app=:user=:db=:WARNING:  terminating 
connection because of crash of another server process


Monitoring the /proc/*/status of the running client process ,I've noticed this :

VmData: 7944 kB
VmData: 7944 kB
VmData: 7944 kB
VmData:29788 kB
VmData:30696 kB
VmData:31724 kB
...
VmData:33776 kB
...
VmData:37876 kB
...
VmData:46072 kB
...
VmData:55272 kB
VmData:67568 kB
VmData:76032 kB
VmData:76484 kB
VmData:78156 kB
...
...
VmData:80208 kB
...
VmData:84308 kB
VmData:92504 kB
VmData:   198972 kB
VmData:   354620 kB
VmData:   495208 kB
...
VmData:   682364 kB
VmData:   788988 kB
VmData:   821756 kB
VmData:   887292 kB
...
VmData:   961020 kB
...
VmData:   993788 kB
...
VmData: 1001980 kB


For sure if the GROUP BY the one that causes this OOM (when I removed it, the 
query finish ok ) , so I've change the query-plan to avoid the HashAggregate:

telecom=# show enable_hashagg ;
 enable_hashagg
 
  off

  But the explain still shows:

 HashAggregate  (cost=19768044.56..20039932.00 rows=27188744 width=152)
   Group Key: changelog_change_transaction.changelog_change_transactionid, 
changelog_change_transaction.epoch, 
changelog_change_transaction.changelog_change_groupid, 
changelog_change_transaction.started_at, 
changelog_change_transaction.duration_microseconds, 
changelog_change_transaction.changed_items, changelog_change_transaction.xmin

   Any help or light on this will be really appreciated!

Regards

Jorge Daniel Fernandez


Re: ERROR: unexpected chunk number 0 (expected 1) for toast value 76753264 in pg_toast_10920100

2018-01-16 Thread Jorge Daniel
Hi Adam , I've been seeing this same  kind of Error in my clusters for a while .

Is this running on postgresql 9.4.8? Because mine was fixed upgrading to 9.4.11 
, a bug indeed .



Kind regards



Jorge Daniel Fernandez



From: Adam Sjøgren 
Sent: Tuesday, January 16, 2018 7:18 AM
To: pgsql-gene...@postgresql.org
Subject: Re: ERROR: unexpected chunk number 0 (expected 1) for toast value 
76753264 in pg_toast_10920100

We are seeing these "ERROR:  unexpected chunk number 0 (expected 1) for
toast value 1498303849 in pg_toast_10919630" in increasing numbers again¹.

An observation is that they seem to only happen for tsvector fields.

Here is an example sequence of queries for a record (we have more than a
handful of these currently), which exhibits the problem.

First we get two other fields, 'sequence' is large enough to be toast'ed:

  2018-01-16 08:51:17.362 efam=# select id,sequence from efam.sequence where id 
= 164504550;
  Time: 1.150 ms

No problem.

Then we also fetch the tsvector field:

  2018-01-16 08:51:27.773 efam=# select id,sequence,fts from efam.sequence 
where id = 164504550;
  ERROR:  unexpected chunk number 0 (expected 1) for toast value 1498303849 in 
pg_toast_10919630
  Time: 0.912 ms

And we get the error.

Getting the id and the tsvector:

  2018-01-16 08:51:34.174 efam=# select id,fts from efam.sequence where id = 
164504550;
  ERROR:  unexpected chunk number 0 (expected 1) for toast value 1498303849 in 
pg_toast_10919630
  Time: 6.138 ms

gives the error.

Just getting the tsvector:

  2018-01-16 08:51:40.066 efam=# select fts from efam.sequence where id = 
164504550;
  ERROR:  unexpected chunk number 0 (expected 1) for toast value 1498303849 in 
pg_toast_10919630
  Time: 1.805 ms

Gives the error.

Field definitions:

   id| integer |
   sequence  | text|
   fts   | tsvector|

Maybe the observation that this only happens (for us) on tsvector rings
a bell for someone?


  Best regards,

Adam


¹ As reported back in June, 2017, starting here:
  https://www.postgresql.org/message-id/7pefuv53dl.fsf%40novozymes.com
  (I have to admit I never got around to trying to revert the commit
  Alvaro Herrera suggested we try without
  
(https://www.postgresql.org/message-id/20170611033840.hruqadsk47qcdrqb%40alvherre.pgsql))

--
 "No more than that, but very powerful all theAdam Sjøgren
  same; simple things are good."a...@novozymes.com