Обсуждение: java.lang.OutOfMemoryError: GC overhead limit exceeded

Поиск
Список
Период
Сортировка

java.lang.OutOfMemoryError: GC overhead limit exceeded

От
Christophe combet
Дата:
Hello,

We upgraded PostgreSQL JDBC Driver 42.2.8 to PostgreSQL JDBC Driver 42.2.14 on July 15th and launched our workflow. It ended prematurely yesterday with Exception in thread "main" java.lang.OutOfMemoryError: GC overhead limit exceeded. The subprocess giving the exception died after ~20 minutes  (it should take 1-2 days).

We tried 42.2.12, it gave the same end with the same running time. 

We tried 42.2.10 and it is working for more than1 hour at the time of writing this message.

Our PostgreSQL database does not change between the runs (it is frozen for several months).

We are running PostgreSQL 10.13 on CentOS Linux release 7.8.2003 (Core) (kernel 3.10.0-1127.13.1.el7.x86_64 and OpenJDK Runtime Environment (build 1.8.0_252-b09)/OpenJDK 64-Bit Server VM (build 25.252-b09, mixed mode)

Is there a change in 42.2.11 or 42.2.12 that could explain the exception raised ?

Thank you for your help.

All the best.

--

42.2.14:
Exception in thread "main" java.lang.OutOfMemoryError: GC overhead limit exceeded
at java.lang.String.replace(String.java:2078)
at java.util.ResourceBundle$Control.toResourceName(ResourceBundle.java:2961)
at java.util.ResourceBundle$Control.toResourceName0(ResourceBundle.java:2970)
at java.util.ResourceBundle$Control.newBundle(ResourceBundle.java:2670)
at java.util.ResourceBundle.loadBundle(ResourceBundle.java:1518)
at java.util.ResourceBundle.findBundle(ResourceBundle.java:1482)
at java.util.ResourceBundle.findBundle(ResourceBundle.java:1436)
at java.util.ResourceBundle.getBundleImpl(ResourceBundle.java:1370)
at java.util.ResourceBundle.getBundle(ResourceBundle.java:782)
at org.postgresql.util.GT.<init>(GT.java:33)
at org.postgresql.util.GT.<clinit>(GT.java:21)
at org.postgresql.core.v3.QueryExecutorImpl.processResults(QueryExecutorImpl.java:2240)
at org.postgresql.core.v3.QueryExecutorImpl.execute(QueryExecutorImpl.java:312)
at org.postgresql.jdbc.PgStatement.executeInternal(PgStatement.java:448)
at org.postgresql.jdbc.PgStatement.execute(PgStatement.java:369)
at org.postgresql.jdbc.PgStatement.executeWithFlags(PgStatement.java:310)
at org.postgresql.jdbc.PgStatement.executeCachedSql(PgStatement.java:296)
at org.postgresql.jdbc.PgStatement.executeWithFlags(PgStatement.java:273)
at org.postgresql.jdbc.PgStatement.executeQuery(PgStatement.java:226)
at our code here

42.2.12:
Exception in thread "main" java.lang.OutOfMemoryError: GC overhead limit exceeded
(nothing else)


Re: java.lang.OutOfMemoryError: GC overhead limit exceeded

От
Vladimir Sitnikov
Дата:
Do you have a heap dump? Have you reviewed to identify the cause of the memory consumption?

Is it the case that you fetch a very large resultset in a non-transactional (autocommit=true) manner?

Vladimir

Re: java.lang.OutOfMemoryError: GC overhead limit exceeded

От
Christophe combet
Дата:
Dear Vladimir,

Thank you for your reply.

We forgot to mention the command line we used:
   java -Duser.language=en -Duser.region=US -XX:ParallelGCThreads=1 -Xms8g -Xmx8g -jar our.jar jar_parameters

We generated a heap dump with 42.2.14  by adding  -XX:+HeapDumpOnOutOfMemoryError -XX:HeapDumpPath=/tmp/mydump.hprof in the command line,  the dump file size is 9GB and contains not shareable data.

We are doing a "SELECT column1 FROM table1 ODER BY column1;" (column1 is   varchar(14) and the table contains 130,080,790 rows), when the exception occurs.

We tried 42.2.14 with the previous version of the database with 128,748,634 rows, the exception occurred to (it worked with 42.2.8). The exception is not linked to the increase in number of rows.

Yes, your are right, this a fetch of a very large resultset in a non-transactional manner (Autocommit:true).

Best.


Le jeudi 23 juillet 2020 à 11:28:25 UTC+2, Vladimir Sitnikov <sitnikov.vladimir@gmail.com> a écrit :


Do you have a heap dump? Have you reviewed to identify the cause of the memory consumption?

Is it the case that you fetch a very large resultset in a non-transactional (autocommit=true) manner?

Vladimir

Re: java.lang.OutOfMemoryError: GC overhead limit exceeded

От
Vladimir Sitnikov
Дата:
>Yes, your are right, this a fetch of a very large resultset in a non-transactional manner (Autocommit:true).

Well, if you use autocommit=true, then the driver has to buffer all the data.
Can you try switching to autocommit=false?

Vladimir


чт, 23 июл. 2020 г. в 14:06, Christophe combet <chrisc_pro@yahoo.fr>:
Dear Vladimir,

Thank you for your reply.

We forgot to mention the command line we used:
   java -Duser.language=en -Duser.region=US -XX:ParallelGCThreads=1 -Xms8g -Xmx8g -jar our.jar jar_parameters

We generated a heap dump with 42.2.14  by adding  -XX:+HeapDumpOnOutOfMemoryError -XX:HeapDumpPath=/tmp/mydump.hprof in the command line,  the dump file size is 9GB and contains not shareable data.

We are doing a "SELECT column1 FROM table1 ODER BY column1;" (column1 is   varchar(14) and the table contains 130,080,790 rows), when the exception occurs.

We tried 42.2.14 with the previous version of the database with 128,748,634 rows, the exception occurred to (it worked with 42.2.8). The exception is not linked to the increase in number of rows.

Yes, your are right, this a fetch of a very large resultset in a non-transactional manner (Autocommit:true).

Best.


Le jeudi 23 juillet 2020 à 11:28:25 UTC+2, Vladimir Sitnikov <sitnikov.vladimir@gmail.com> a écrit :


Do you have a heap dump? Have you reviewed to identify the cause of the memory consumption?

Is it the case that you fetch a very large resultset in a non-transactional (autocommit=true) manner?

Vladimir

Re: java.lang.OutOfMemoryError: GC overhead limit exceeded

От
Vladimir Sitnikov
Дата:
>can you try switching to autocommit=false?

+ you probably need to configure fetchSize as well.

Vladimir

Re: java.lang.OutOfMemoryError: GC overhead limit exceeded

От
Christophe combet
Дата:

Thank you for pointing the link between auto commit an buffering.

autocommit=false: same exception.

We try fetchSize.

Thanks.
Le jeudi 23 juillet 2020 à 13:47:14 UTC+2, Vladimir Sitnikov <sitnikov.vladimir@gmail.com> a écrit :


>can you try switching to autocommit=false?

+ you probably need to configure fetchSize as well.

Vladimir

Re: java.lang.OutOfMemoryError: GC overhead limit exceeded

От
Christophe combet
Дата:

autocommit=false & fetchSize=100 or 10000 : same exception.

42.2.10 still running.
Le jeudi 23 juillet 2020 à 14:30:56 UTC+2, Christophe combet <chrisc_pro@yahoo.fr> a écrit :



Thank you for pointing the link between auto commit an buffering.

autocommit=false: same exception.

We try fetchSize.

Thanks.
Le jeudi 23 juillet 2020 à 13:47:14 UTC+2, Vladimir Sitnikov <sitnikov.vladimir@gmail.com> a écrit :


>can you try switching to autocommit=false?

+ you probably need to configure fetchSize as well.

Vladimir

Re: java.lang.OutOfMemoryError: GC overhead limit exceeded

От
Dave Cramer
Дата:


On Thu, 23 Jul 2020 at 09:21, Christophe combet <chrisc_pro@yahoo.fr> wrote:

autocommit=false & fetchSize=100 or 10000 : same exception.

42.2.10 still running.

Is there a very large column in there 


Dave Cramer
www.postgres.rocks



 
Le jeudi 23 juillet 2020 à 14:30:56 UTC+2, Christophe combet <chrisc_pro@yahoo.fr> a écrit :



Thank you for pointing the link between auto commit an buffering.

autocommit=false: same exception.

We try fetchSize.

Thanks.
Le jeudi 23 juillet 2020 à 13:47:14 UTC+2, Vladimir Sitnikov <sitnikov.vladimir@gmail.com> a écrit :


>can you try switching to autocommit=false?

+ you probably need to configure fetchSize as well.

Vladimir

Re: java.lang.OutOfMemoryError: GC overhead limit exceeded

От
Rob Sargent
Дата:

On 7/23/20 6:30 AM, Christophe combet wrote:
> 
> Thank you for pointing the link between auto commit an buffering.
> 
> autocommit=false: same exception.
> 
> We try fetchSize.
> 
> Thanks.
> Le jeudi 23 juillet 2020 à 13:47:14 UTC+2, Vladimir Sitnikov 
> <sitnikov.vladimir@gmail.com> a écrit :
> 
> 
>  >can you try switching to autocommit=false?
> 
> + you probably need to configure fetchSize as well.
> 
> Vladimir
> 
You set the 8G limit on the java process but did you tell up the 
available RAM?  This query would require that about 3G be available to 
hold all the data. Can you use jConsole to establish how much memory is 
available at the time of issuing the query?



Re: java.lang.OutOfMemoryError: GC overhead limit exceeded

От
Vladimir Sitnikov
Дата:
Could you open a heapdump and figure out what is consuming the memory?

It is kind of hard to guess without having a reproducer.

Vladimir

Re: java.lang.OutOfMemoryError: GC overhead limit exceeded

От
Jorge Solórzano
Дата:
The only change that could affect between 42.2.10 (which works based
on your first message), and 42.2.11+ is the introduction of the tuple
abstraction.

The autocommit=false + fetchSize combo should help with large tables:
https://jdbc.postgresql.org/documentation/head/query.html#fetchsize-example


On Thu, Jul 23, 2020 at 4:19 PM Christophe combet <chrisc_pro@yahoo.fr> wrote:
>
> Dear Dave,
>
> The table definition is:
>
> CREATE TABLE mytable (
>     column1 character varying(14) NOT NULL,
>     column2 integer NOT NULL,
>     column3 bytea NOT NULL
> );
>
> ALTER TABLE ONLY mytable
>     ADD CONSTRAINT mytable_pkey PRIMARY KEY (column1);
>
> Column column3 contains zipped data (BLOB and toast table).
>
> The full dump of the table (pg_dump as SQL text) is 24GB.
>
> Thanks.
> Le jeudi 23 juillet 2020 à 15:24:54 UTC+2, Dave Cramer <davecramer@postgres.rocks> a écrit :
>
>
>
>
> On Thu, 23 Jul 2020 at 09:21, Christophe combet <chrisc_pro@yahoo.fr> wrote:
>
>
> autocommit=false & fetchSize=100 or 10000 : same exception.
>
> 42.2.10 still running.
>
>
> Is there a very large column in there
>
>
> Dave Cramer
> www.postgres.rocks
>
>
>
>
>
> Le jeudi 23 juillet 2020 à 14:30:56 UTC+2, Christophe combet <chrisc_pro@yahoo.fr> a écrit :
>
>
>
> Thank you for pointing the link between auto commit an buffering.
>
> autocommit=false: same exception.
>
> We try fetchSize.
>
> Thanks.
> Le jeudi 23 juillet 2020 à 13:47:14 UTC+2, Vladimir Sitnikov <sitnikov.vladimir@gmail.com> a écrit :
>
>
> >can you try switching to autocommit=false?
>
> + you probably need to configure fetchSize as well.
>
> Vladimir
>



Re: java.lang.OutOfMemoryError: GC overhead limit exceeded

От
Christophe combet
Дата:
Dear Rob,

Total RAM is 512GB.

Runtime.getRuntime().freeMemory() says: 7,630,918,904 at the time of issuing the query.

jConsole timed out and it is impossible to reconnect. I did a screen capture at the time of the freeze.

Le jeudi 23 juillet 2020 à 15:33:34 UTC+2, Rob Sargent <robjsargent@gmail.com> a écrit :




On 7/23/20 6:30 AM, Christophe combet wrote:
>
> Thank you for pointing the link between auto commit an buffering.
>
> autocommit=false: same exception.
>
> We try fetchSize.
>
> Thanks.
> Le jeudi 23 juillet 2020 à 13:47:14 UTC+2, Vladimir Sitnikov
> <sitnikov.vladimir@gmail.com> a écrit :
>
>
>  >can you try switching to autocommit=false?
>
> + you probably need to configure fetchSize as well.
>
> Vladimir

>
You set the 8G limit on the java process but did you tell up the
available RAM?  This query would require that about 3G be available to
hold all the data. Can you use jConsole to establish how much memory is
available at the time of issuing the query?



Вложения

Re: java.lang.OutOfMemoryError: GC overhead limit exceeded

От
Rob Sargent
Дата:

On 7/23/20 8:33 AM, Christophe combet wrote:
> Dear Rob,
> 
> Total RAM is 512GB.
> 
> Runtime.getRuntime().freeMemory() says: 7,630,918,904 at the time of 
> issuing the query.
> 
> jConsole timed out and it is impossible to reconnect. I did a screen 
> capture at the time of the freeze.
> 
> Le jeudi 23 juillet 2020 à 15:33:34 UTC+2, Rob Sargent 
> <robjsargent@gmail.com> a écrit :
> 
> 
> 
> 
> On 7/23/20 6:30 AM, Christophe combet wrote:
>  >
>  > Thank you for pointing the link between auto commit an buffering.
>  >
>  > autocommit=false: same exception.
>  >
>  > We try fetchSize.
>  >
>  > Thanks.
>  > Le jeudi 23 juillet 2020 à 13:47:14 UTC+2, Vladimir Sitnikov
>  > <sitnikov.vladimir@gmail.com <mailto:sitnikov.vladimir@gmail.com>> a 
> écrit :
>  >
>  >
>  >  >can you try switching to autocommit=false?
>  >
>  > + you probably need to configure fetchSize as well.
>  >
>  > Vladimir
> 
>  >
> You set the 8G limit on the java process but did you tell up the
> available RAM?  This query would require that about 3G be available to
> hold all the data. Can you use jConsole to establish how much memory is
> available at the time of issuing the query?
> 
> 
> 
Upthread the select statement returned only "column1"
* We are doing a "SELECT column1 FROM table1 ODER BY column1;" (column1 
* is   varchar(14) and the table contains 130,080,790 rows), when the * 
* exception occurs.
Are you reading in the bytea column as well?

And does it finish if you add more memory to the jvm (just for testing 
purposes).




Re: java.lang.OutOfMemoryError: GC overhead limit exceeded

От
Christophe combet
Дата:
chat is running for a long time on many processors...
Not enough RAM on my laptop. Will try again later.

Le jeudi 23 juillet 2020 à 15:38:45 UTC+2, Vladimir Sitnikov <sitnikov.vladimir@gmail.com> a écrit :


Could you open a heapdump and figure out what is consuming the memory?

It is kind of hard to guess without having a reproducer.

Vladimir

Re: java.lang.OutOfMemoryError: GC overhead limit exceeded

От
Christophe combet
Дата:

No we are not reading  the bytea column.

With  -Xms32g -Xmx32g : yes (in 2 minutes)
Le jeudi 23 juillet 2020 à 17:33:07 UTC+2, Rob Sargent <robjsargent@gmail.com> a écrit :




On 7/23/20 8:33 AM, Christophe combet wrote:
> Dear Rob,
>
> Total RAM is 512GB.
>
> Runtime.getRuntime().freeMemory() says: 7,630,918,904 at the time of
> issuing the query.
>
> jConsole timed out and it is impossible to reconnect. I did a screen
> capture at the time of the freeze.
>
> Le jeudi 23 juillet 2020 à 15:33:34 UTC+2, Rob Sargent
> <robjsargent@gmail.com> a écrit :
>
>
>
>
> On 7/23/20 6:30 AM, Christophe combet wrote:
>  >
>  > Thank you for pointing the link between auto commit an buffering.
>  >
>  > autocommit=false: same exception.
>  >
>  > We try fetchSize.
>  >
>  > Thanks.
>  > Le jeudi 23 juillet 2020 à 13:47:14 UTC+2, Vladimir Sitnikov
>  > <sitnikov.vladimir@gmail.com <mailto:sitnikov.vladimir@gmail.com>> a

> écrit :
>  >
>  >
>  >  >can you try switching to autocommit=false?
>  >
>  > + you probably need to configure fetchSize as well.
>  >
>  > Vladimir
>
>  >
> You set the 8G limit on the java process but did you tell up the
> available RAM?  This query would require that about 3G be available to
> hold all the data. Can you use jConsole to establish how much memory is
> available at the time of issuing the query?

>
>
>
Upthread the select statement returned only "column1"
* We are doing a "SELECT column1 FROM table1 ODER BY column1;" (column1
* is  varchar(14) and the table contains 130,080,790 rows), when the *
* exception occurs.
Are you reading in the bytea column as well?

And does it finish if you add more memory to the jvm (just for testing
purposes).


Re: java.lang.OutOfMemoryError: GC overhead limit exceeded

От
Dave Cramer
Дата:


On Thu, 23 Jul 2020 at 11:42, Christophe combet <chrisc_pro@yahoo.fr> wrote:
Dear Jorge,

Thank you for the explanation and the pointer to the doc.

Indeed, the autocommit=false + fetchSize combo is working. I did a mistake when trying the first time as suggested by Vladimir: I used createStatement(ResultSet.TYPE_SCROLL_INSENSITIVE,ResultSet.CONCUR_READ_ONLY) which are not the good parameters to be used (bad copy/paste).

With createStatement()+fetchSize+autocommit=false the exception disappeared.

Thank you very much.

Le jeudi 23 juillet 2020 à 16:31:06 UTC+2, Jorge Solórzano <jorsol@gmail.com> a écrit :


The only change that could affect between 42.2.10 (which works based
on your first message), and 42.2.11+ is the introduction of the tuple
abstraction.

The autocommit=false + fetchSize combo should help with large tables:
https://jdbc.postgresql.org/documentation/head/query.html#fetchsize-example


Glad this works


Dave Cramer
www.postgres.rocks

Re: java.lang.OutOfMemoryError: GC overhead limit exceeded

От
Christophe combet
Дата:
jhat no chat.

Used  -Xms2g -Xmx2g to produce a light heap dump analysed with MAT

Le jeudi 23 juillet 2020 à 17:37:03 UTC+2, Christophe combet <chrisc_pro@yahoo.fr> a écrit :


chat is running for a long time on many processors...
Not enough RAM on my laptop. Will try again later.

Le jeudi 23 juillet 2020 à 15:38:45 UTC+2, Vladimir Sitnikov <sitnikov.vladimir@gmail.com> a écrit :


Could you open a heapdump and figure out what is consuming the memory?

It is kind of hard to guess without having a reproducer.

Vladimir

Вложения

Re: java.lang.OutOfMemoryError: GC overhead limit exceeded

От
Thomas Kellerer
Дата:
Christophe combet schrieb am 23.07.2020 um 17:41:
> Indeed, the autocommit=false + fetchSize combo is working. I did a
> mistake when trying the first time as suggested by Vladimir: I used
> createStatement(ResultSet.TYPE_SCROLL_INSENSITIVE,ResultSet.CONCUR_READ_ONLY)
> which are not the good parameters to be used (bad copy/paste).

You would need

    createStatement(ResultSet.TYPE_FORWARD_ONLY, ResultSet.CONCUR_READ_ONLY)

Thomas



Re: java.lang.OutOfMemoryError: GC overhead limit exceeded

От
Vladimir Sitnikov
Дата:
>heap dump analysed with MAT

Thank you.

Even though the preferred solution is to buffer data rather than fetch all the rows to the heap, it looks like Tuple costs 30% or so of the heap :-/
Just in case, the columns are "number of objects", "shallow heap" (==heap consumption by the object itself), "retained heap" (==heap consumption of the object+all its references).
We might want to revise the addition of Tuple.

Vladimir