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

DEOM Damien updated NIFI-8052:
------------------------------
    Description: 
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.

  was:
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.


> 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)

Reply via email to