You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@activemq.apache.org by Viliam Durina <vi...@hazelcast.com> on 2019/11/26 09:53:26 UTC

Transaction interleaving

I'm doing these steps:

    Xid xid1, xid2;
    XASession session = ...;
    MessageConsumer consumer = ...;
    XAResource xaRes = session.getXAResource();

    xaRes.start(xid1, TMNOFLAGS);
    consumer.receive();
    xaRes.end(xid1, TMSUCCESS);
    // prepare the xid1, continue with xid2
    xaRes.prepare(xid1);
    xaRes.start(xid2);
    // receive one more item
    consumer.receive();
    // commit the first transaction
    xaRes.commit(xid1, false);

The issue is that the last `commit` should commit only the first received
message. But it commits also the message received using the xid2
transaction.

As far as I can tell the above behavior is legal. That's why the `commit`
method has the `Xid` argument: to tell which transaction are we committing.
The `receive` method uses the transaction associated currently with the
session. It also works with ActiveMQ Artemis.

Viliam

Re: Transaction interleaving

Posted by Tim Bain <tb...@alumni.duke.edu>.
Great, thank you for doing that.

Tim

On Wed, Nov 27, 2019, 1:36 AM Viliam Durina <vi...@hazelcast.com> wrote:

> Done: https://issues.apache.org/jira/browse/AMQ-7354
>
> On Wed, 27 Nov 2019 at 07:44, Tim Bain <tb...@alumni.duke.edu> wrote:
>
> > This sounds like a valid bug. Could you please submit a bug report for it
> > in JIRA?
> >
> > Thanks,
> > Tim
> >
> > On Tue, Nov 26, 2019 at 2:53 AM Viliam Durina <vi...@hazelcast.com>
> > wrote:
> >
> > > I'm doing these steps:
> > >
> > >     Xid xid1, xid2;
> > >     XASession session = ...;
> > >     MessageConsumer consumer = ...;
> > >     XAResource xaRes = session.getXAResource();
> > >
> > >     xaRes.start(xid1, TMNOFLAGS);
> > >     consumer.receive();
> > >     xaRes.end(xid1, TMSUCCESS);
> > >     // prepare the xid1, continue with xid2
> > >     xaRes.prepare(xid1);
> > >     xaRes.start(xid2);
> > >     // receive one more item
> > >     consumer.receive();
> > >     // commit the first transaction
> > >     xaRes.commit(xid1, false);
> > >
> > > The issue is that the last `commit` should commit only the first
> received
> > > message. But it commits also the message received using the xid2
> > > transaction.
> > >
> > > As far as I can tell the above behavior is legal. That's why the
> `commit`
> > > method has the `Xid` argument: to tell which transaction are we
> > committing.
> > > The `receive` method uses the transaction associated currently with the
> > > session. It also works with ActiveMQ Artemis.
> > >
> > > Viliam
> > >
> >
>

Re: Transaction interleaving

Posted by Viliam Durina <vi...@hazelcast.com>.
Done: https://issues.apache.org/jira/browse/AMQ-7354

On Wed, 27 Nov 2019 at 07:44, Tim Bain <tb...@alumni.duke.edu> wrote:

> This sounds like a valid bug. Could you please submit a bug report for it
> in JIRA?
>
> Thanks,
> Tim
>
> On Tue, Nov 26, 2019 at 2:53 AM Viliam Durina <vi...@hazelcast.com>
> wrote:
>
> > I'm doing these steps:
> >
> >     Xid xid1, xid2;
> >     XASession session = ...;
> >     MessageConsumer consumer = ...;
> >     XAResource xaRes = session.getXAResource();
> >
> >     xaRes.start(xid1, TMNOFLAGS);
> >     consumer.receive();
> >     xaRes.end(xid1, TMSUCCESS);
> >     // prepare the xid1, continue with xid2
> >     xaRes.prepare(xid1);
> >     xaRes.start(xid2);
> >     // receive one more item
> >     consumer.receive();
> >     // commit the first transaction
> >     xaRes.commit(xid1, false);
> >
> > The issue is that the last `commit` should commit only the first received
> > message. But it commits also the message received using the xid2
> > transaction.
> >
> > As far as I can tell the above behavior is legal. That's why the `commit`
> > method has the `Xid` argument: to tell which transaction are we
> committing.
> > The `receive` method uses the transaction associated currently with the
> > session. It also works with ActiveMQ Artemis.
> >
> > Viliam
> >
>

Re: Transaction interleaving

Posted by Tim Bain <tb...@alumni.duke.edu>.
This sounds like a valid bug. Could you please submit a bug report for it
in JIRA?

Thanks,
Tim

On Tue, Nov 26, 2019 at 2:53 AM Viliam Durina <vi...@hazelcast.com> wrote:

> I'm doing these steps:
>
>     Xid xid1, xid2;
>     XASession session = ...;
>     MessageConsumer consumer = ...;
>     XAResource xaRes = session.getXAResource();
>
>     xaRes.start(xid1, TMNOFLAGS);
>     consumer.receive();
>     xaRes.end(xid1, TMSUCCESS);
>     // prepare the xid1, continue with xid2
>     xaRes.prepare(xid1);
>     xaRes.start(xid2);
>     // receive one more item
>     consumer.receive();
>     // commit the first transaction
>     xaRes.commit(xid1, false);
>
> The issue is that the last `commit` should commit only the first received
> message. But it commits also the message received using the xid2
> transaction.
>
> As far as I can tell the above behavior is legal. That's why the `commit`
> method has the `Xid` argument: to tell which transaction are we committing.
> The `receive` method uses the transaction associated currently with the
> session. It also works with ActiveMQ Artemis.
>
> Viliam
>