Re: Connection leaks with PostgreSQL instance

2019-01-21 Thread Jonathan Perron
Dear all, It happened again on Friday morning: You can see a baseline in the connection amount from the 16th to the 18th. Looking at the pg_stat_activity, all connections are used, even when the pipeline is not used at 100 % (my use case is processing data from a platform which is not used a

Re: Connection leaks with PostgreSQL instance

2019-01-17 Thread Kenneth Knowles
My mistake - using @Teardown in this way is a good approach. It may not be executed sometimes, but like Reuven says it means the process died. Kenn On Thu, Jan 17, 2019 at 9:31 AM Jean-Baptiste Onofré wrote: > Hi, > > I don't think we have connection leak in normal behavior. > > The actual SQL

Re: Connection leaks with PostgreSQL instance

2019-01-17 Thread Jean-Baptiste Onofré
Hi, I don't think we have connection leak in normal behavior. The actual SQL statement is executed in @FinishBundle, where the connection is closed. The processElement adds record to process. Does it mean that an Exception occurs in the batch addition ? Regards JB On 17/01/2019 12:41, Alexey

Re: Connection leaks with PostgreSQL instance

2019-01-17 Thread Reuven Lax
But I think it will be called unless the process crashes though. On Thu, Jan 17, 2019, 7:05 AM Ismaël Mejía Couldn't this be related also to the fact that @Teardown is > best-effort in Dataflow? > > On Thu, Jan 17, 2019 at 12:41 PM Alexey Romanenko > wrote: > > > > Kenn, > > > > I’m not sure

Re: Connection leaks with PostgreSQL instance

2019-01-17 Thread Ismaël Mejía
Couldn't this be related also to the fact that @Teardown is best-effort in Dataflow? On Thu, Jan 17, 2019 at 12:41 PM Alexey Romanenko wrote: > > Kenn, > > I’m not sure that we have a connection leak in JdbcIO since new connection is > being obtained from an instance of javax.sql.DataSource

Re: Connection leaks with PostgreSQL instance

2019-01-17 Thread Alexey Romanenko
Kenn, I’m not sure that we have a connection leak in JdbcIO since new connection is being obtained from an instance of javax.sql.DataSource (created in @Setup) and which is org.apache.commons.dbcp2.BasicDataSource by default. BasicDataSource uses connection pool and closes all idle connections

Re: Connection leaks with PostgreSQL instance

2019-01-16 Thread Jonathan Perron
Hi Kenneth, Thank you for your reply. I find out that the leak was coming somehow from my individual DoFns. I replaced all the connections by a connection pooling and I haven't seen connection leaks since. I will keep monitoring the pipeline state and if I see new leaks, I would investigate

Re: Connection leaks with PostgreSQL instance

2019-01-14 Thread Kenneth Knowles
Hi Jonathan, JdbcIO.write() just invokes this DoFn: https://github.com/apache/beam/blob/master/sdks/java/io/jdbc/src/main/java/org/apache/beam/sdk/io/jdbc/JdbcIO.java#L765 It establishes a connection in @StartBundle and then in @FinishBundle it commits a batch and closes the connection. If an

Connection leaks with PostgreSQL instance

2019-01-14 Thread Jonathan Perron
Hello ! My question is maybe mainly GCP-oriented, so I apologize if it is not fully related to the Beam community. We have a streaming pipeline running on Dataflow which writes data to a PostgreSQL instance hosted on Cloud SQL. This database is suffering from connection leak spikes on a