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

Lars Hofhansl updated PHOENIX-1257:
-----------------------------------
    Attachment: 1257-WIP.txt

[~giacomotaylor] and I worked on a fix today.
The main fix is to make sure the TS of the tableref representing the upsert 
table is set to the TS of the table we select from (in this case these are the 
same table).

Then we ran into the issue that in BaseQueryPlan we have this:
{code}
        if (context.getScanTimeRange() == null) {
          Long scn = connection.getSCN();
          if (scn == null) {
            scn = context.getCurrentTime();
            /*
            // Add one to server time since max of time range is exclusive
            // and we need to account of OSs with lower resolution clocks.
            if (scn < HConstants.LATEST_TIMESTAMP) {
              scn++;
            }
            */
          }
          ScanUtil.setTimeRange(scan, scn);
        } else {
            ScanUtil.setTimeRange(scan, context.getScanTimeRange());
        }
{code}

Due to this the TS of the mutation was still off by one from the TS we use for 
the select.

This W.I.P. comments that part out, but we clearly need to fix this before we 
can commit. With this change it works as expected, though.

[~jeffreyz], any ideas? You added the {{scn++}} part of protect again low TS 
resolution on Windows.

> Strange behavior wirh "upsert into ... select from ..." with sequences
> ----------------------------------------------------------------------
>
>                 Key: PHOENIX-1257
>                 URL: https://issues.apache.org/jira/browse/PHOENIX-1257
>             Project: Phoenix
>          Issue Type: Bug
>            Reporter: Lars Hofhansl
>            Priority: Critical
>         Attachments: 1257-WIP.txt, 1257-test.txt
>
>
> I have the following scenario:
> create sequence keys;
> create table X (pk unsigned_long primary key, val integer);
> upsert into x values (1,1);
> Followed by repeated:
> upsert into x select next value for keys, val from x;
> This works well until 2048 rows are inserted. The next
> upsert into x select next value for keys, val from x;
> That loops forever inserting more and more rows until it is stopped.



--
This message was sent by Atlassian JIRA
(v6.3.4#6332)

Reply via email to