Hey Varun,

I think the issue is that your code starts the second transaction before
the first one has committed (inside the outer @Transactional). Because of
snapshot isolation, the second transaction cannot see the writes from the
first one. I see tw ways to make it work:

1. Remove the @Transactional from insertInner(). That way it is part of the
same transaction and will see the write of obj1.
2. Serialize the transactions. It should work if rewrite your code to
something like this:

void insertBoth(Object obj, Object obj2) throws someException {
insertOuter(obj1);
insertInner(obj1, obj2);
}

@Transactional
void insertOuter(Object obj1, Object obj2) throws SomeException {
// Spring call to insert obj1 into Phoenix transactional table1
}

@Transactional
void insertInner(Object obj) throws SomeException {
checkToEnsureObj1WasInserted() // ** THIS FAILS
... // code to insert object 2
}

Cheers -Andreas.

On Tue, Dec 11, 2018 at 7:05 AM Varun Rao <[email protected]> wrote:

> Hello,
>
> We have an application that issues two sequential inserts within the same
> Phoenix/Tephra transaction.  Before the second insert, a check is performed
> to ensure data from the first insert is available (select ...).  This check
> failed once in production (an intermittent problem which has not been
> reproduced).  Phoenix/Tephra is being accessed through
> Spring (which uses Java Transaction API) with 'read committed' and
> 'propagation.required' options.  The code is similar to the following:
>
> @transactional
> void insertOuter(Object obj1, Object obj2) throws SomeException {
> // Spring call to insert obj1 into Phoenix transactional table1
> insertInner(obj2)
> }
>
> @Transactional
> void insertInner(Object obj) throws SomeException {
> checkToEnsureObj1WasInserted() // ** THIS FAILS
> ... // code to insert object 2
> }
>
> We expect to see that subsequent write operations within the same Phoenix
> transactions are guaranteed to see the results of prior operations (the
> second write will have access to the first write)
>
> 1)  Should Java Spring be compatible with Phoenix/Tephra?
> 2)  Is there a particular Phoenix/Tephra logging configuration that can be
> enabled to capture additional transaction-specific information, such as
> when commits or rollbacks occur?
>
> Thanks very much
>

Reply via email to