[
https://issues.apache.org/jira/browse/PHOENIX-1943?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=14522164#comment-14522164
]
James Taylor commented on PHOENIX-1943:
---------------------------------------
[~samarthjain] - MutatingParallelIteratorFactory creates a new Connection, so
the MutationState will be different for each of them:
{code}
@Override
public PeekingResultIterator newIterator(StatementContext context,
ResultIterator iterator, Scan scan) throws SQLException {
final PhoenixConnection connection = new
PhoenixConnection(this.connection);
{code}
> UPSERT SELECT is not thread safe
> --------------------------------
>
> Key: PHOENIX-1943
> URL: https://issues.apache.org/jira/browse/PHOENIX-1943
> Project: Phoenix
> Issue Type: Bug
> Reporter: Samarth Jain
> Assignee: Samarth Jain
>
> When UPSERT SELECT is run on the client side, we use the
> UpsertingParallelIteratorFactory where every iterator returned by
> newIterator() method calls the UpsertSelect method. Each of these mutating
> iterators are called from different threads in parallel. However, the
> upsertSelect() method called from each of these iterators uses the same
> mutationState instance which is not thread safe.
> In particular this code in UpsertCompiler#upsertSelect
> {code}
> PhoenixStatement statement = context.getStatement();
> PhoenixConnection connection = statement.getConnection();
> .....
> .....
> // Commit a batch if auto commit is true and we're at our batch size
> if (isAutoCommit && rowCount % batchSize == 0) {
> MutationState state = new MutationState(tableRef,
> mutation, 0, maxSize, connection);
> connection.getMutationState().join(state);
> connection.commit();
> mutation.clear();
> }
> {code}
> [~rajeshbabu] - I will try and get a fix for this by EOD today.
> FYI [~jamestaylor]
--
This message was sent by Atlassian JIRA
(v6.3.4#6332)