You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@nifi.apache.org by "DEOM Damien (Jira)" <ji...@apache.org> on 2020/11/30 15:12:00 UTC

[jira] [Resolved] (NIFI-8052) Groovy: SQL inserts crashes DBCPConnectionPool

     [ https://issues.apache.org/jira/browse/NIFI-8052?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

DEOM Damien resolved NIFI-8052.
-------------------------------
    Resolution: Fixed

I forgot to close connection ...

 

conn?.close()

> Groovy: SQL inserts crashes DBCPConnectionPool
> ----------------------------------------------
>
>                 Key: NIFI-8052
>                 URL: https://issues.apache.org/jira/browse/NIFI-8052
>             Project: Apache NiFi
>          Issue Type: Bug
>    Affects Versions: 1.11.4
>            Reporter: DEOM Damien
>            Priority: Blocker
>
> Following this tutorial
> [http://funnifi.blogspot.com/2016/04/sql-in-nifi-with-executescript.html]
> I could read the database, but writing to it crashes my DBCPConnectionPool with the following error:
> {quote}PutSQL[id=a2c741f9-947d-137e-0000-000058ffcc56] org.apache.nifi.processors.standard.PutSQL$$Lambda$1891/0x0000000842eb4440@5c63d8ac failed to process due to java.sql.SQLException: Cannot get a connection, pool error Timeout waiting for idle object; rolling back session: org.apache.nifi.processor.exception.ProcessException: java.sql.SQLException: Cannot get a connection, pool error Timeout waiting for idle object
> {quote}
> I'm forced to restart the controller after each execution.
> My (simple) code:
>  
> import java.nio.charset.StandardCharsets
> import org.apache.nifi.controller.ControllerService
> import groovy.sql.Sql
> def lookup = context.controllerServiceLookup
> def dbServiceName = DatabaseConnectionPoolName.value
> def dbcpServiceId = lookup.getControllerServiceIdentifiers(ControllerService).find { 
>  cs -> lookup.getControllerServiceName(cs) == dbServiceName
> }
> def conn = lookup.getControllerService(dbcpServiceId)?.getConnection()
> def sql = new Sql(conn)
> def insertSql = 'INSERT INTO test (a) VALUES (?)'
> def params = ['Jon']
> def keys = sql.executeInsert insertSql, params
> assert keys[0] == [1]
> def flowFile = session.get()
> if(!flowFile) return
>  
> Note that the problem only occurs when using Groovy. The PutSQL processor works just fine.



--
This message was sent by Atlassian Jira
(v8.3.4#803005)