[
https://issues.apache.org/jira/browse/PHOENIX-2510?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel
]
Siddhi Mehta updated PHOENIX-2510:
----------------------------------
Attachment: PHOENIX-2510.patch
[~giacomotaylor] Thanks for noticing the issue.
Bad cleanup for the last commit
I made the following changes
1. Remove creating a connection member per invocation.It will not create it
once per task for the first invocation
2. Remove the finally from the exec() method to close connection. Connection
will be close in the finish() method.
3. Updated the test to call udf.finish() to close the connection
> ReserveNSequence opens new connection per invocation
> ----------------------------------------------------
>
> Key: PHOENIX-2510
> URL: https://issues.apache.org/jira/browse/PHOENIX-2510
> Project: Phoenix
> Issue Type: Bug
> Reporter: James Taylor
> Assignee: Siddhi Mehta
> Fix For: 4.7.0
>
> Attachments: PHOENIX-2510.patch
>
>
> Happened to be looking at this code and I noticed that a connection member
> variable is set for each call to exec by calling
> ConnectionUtil.getOutputConnection regardless of the initialization code
> above it. Doesn't look right to me.
> {code}
> @Override
> public Long exec(Tuple input) throws IOException {
> Preconditions.checkArgument(input != null && input.size() >= 2,
> INVALID_TUPLE_MESSAGE);
> Long numToReserve = (Long)(input.get(0));
> Preconditions.checkArgument(numToReserve > 0, INVALID_NUMBER_MESSAGE);
> String sequenceName = (String)input.get(1);
> Preconditions.checkNotNull(sequenceName, EMPTY_SEQUENCE_NAME_MESSAGE);
> // It will create a connection when called for the first Tuple per
> task.
> // The connection gets cleaned up in finish() method
> if (connection == null) {
> initConnection();
> }
> ResultSet rs = null;
> try {
> connection = ConnectionUtil.getOutputConnection(configuration);
> String sql =
> getNextNSequenceSelectStatement(Long.valueOf(numToReserve), sequenceName);
> rs = connection.createStatement().executeQuery(sql);
> {code}
--
This message was sent by Atlassian JIRA
(v6.3.4#6332)