qpid-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "jiraposter@reviews.apache.org (JIRA)" <j...@apache.org>
Subject [jira] [Commented] (QPID-3079) message.accept command should be completed on a per-dequeue basis
Date Wed, 01 Jun 2011 20:22:47 GMT

    [ https://issues.apache.org/jira/browse/QPID-3079?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13042400#comment-13042400
] 

jiraposter@reviews.apache.org commented on QPID-3079:
-----------------------------------------------------


-----------------------------------------------------------
This is an automatically generated e-mail. To reply, visit:
https://reviews.apache.org/r/820/
-----------------------------------------------------------

Review request for Alan Conway and Gordon Sim.


Summary
-------

Here's my attempt to implement a solution to qpid-3079 - with an eye towards allowing async
completion of various commands.  I've integrated the existing async Message.Transfer completion
code to use this new design.

The implementation seems too "codey" - I had hoped that this would've resulted in a simpler
implementation, but I've found that C++ is a harsh mistress.

I'd like some early feedback - particularly suggestions for reducing the amount of code/simplifying
the design if possible.

There are two major functional changes involved:

1) changes to the Queue:dequeue() method to allow a callback if the dequeue is asynchronous.
 Since the caller does not know ahead of time whether the dequeue is sync or async, Queue::dequeue()
now takes a functor parameter supplied by the caller.  The purpose of the functor is to allocate
a context to track the dequeue completion only if necessary.  See Queue.h/cpp and the SemanticState::accepted()
changes for detail

2) - and this is the one aspect I'd like to improve - changes to the SessionState/SessionContext/SemanticState
interface to allow a command to complete asynchronously.   My understanding of the code is
that the SessionContext defines an abstract interface to the SessionState.  The SemanticState
uses this interface for getting session-related information.

The changes involve creating an abstract class within the SessionContext class that represents
the context for a single outstanding asynchronous command.  This class is abstract - the intent
is for SemanticState to subclass it and add any state it needs in order to asynchronously
process a particular command (see the class AsyncMessageAcceptCmd in SemanticState for an
example of a derivation used for asynchronous Message.Accept).  My intent was to have SemanticState
allocate one of these contexts should a command require async completion - and use this context
to retain state while the command executes.

Then the SemanticState would register the context with the SessionState via the SessionContext's
registerAsyncCommand() method.  The SessionContext would store information that it needs when
the command completes (right now: sequence #, isSync bit set, and acceptRequired in the case
of message.transfer).

What I particularly do not like is the exposure of the AsyncCommandManager context into the
SessionContext interface.  This command manager was created when I added support for async
Message.Transfer - it provided a context that would track all outstanding message.transfer
commands that were in flight should the SessionState be destroyed.   The command manager context
is reference-counted, and each outstanding command references it - guaranteeing that some
context is present when the command completes, even if the session has been destroyed.

It would be great if I could hide this manager context from being exported by SessionContext.
 And I'd like a better way of tracking the command seq #, isSync, and requiresAccept rather
than just jamming them into the command context when it is registered...

Regardless, please give me your impressions before I go too far down the testing path, if
possible.   Thanks.


This addresses bug qpid-3079.
    https://issues.apache.org/jira/browse/qpid-3079


Diffs
-----

  /branches/qpid-3079/qpid/cpp/src/qpid/broker/AsyncCompletion.h 1124901 
  /branches/qpid-3079/qpid/cpp/src/qpid/broker/DeliveryRecord.h 1124901 
  /branches/qpid-3079/qpid/cpp/src/qpid/broker/DeliveryRecord.cpp 1124901 
  /branches/qpid-3079/qpid/cpp/src/qpid/broker/Message.h 1124901 
  /branches/qpid-3079/qpid/cpp/src/qpid/broker/Message.cpp 1124901 
  /branches/qpid-3079/qpid/cpp/src/qpid/broker/MessageStore.h 1124901 
  /branches/qpid-3079/qpid/cpp/src/qpid/broker/MessageStoreModule.h 1124901 
  /branches/qpid-3079/qpid/cpp/src/qpid/broker/MessageStoreModule.cpp 1124901 
  /branches/qpid-3079/qpid/cpp/src/qpid/broker/NullMessageStore.h 1124901 
  /branches/qpid-3079/qpid/cpp/src/qpid/broker/NullMessageStore.cpp 1124901 
  /branches/qpid-3079/qpid/cpp/src/qpid/broker/PersistableMessage.h 1124901 
  /branches/qpid-3079/qpid/cpp/src/qpid/broker/PersistableMessage.cpp 1124901 
  /branches/qpid-3079/qpid/cpp/src/qpid/broker/PersistableQueue.h 1124901 
  /branches/qpid-3079/qpid/cpp/src/qpid/broker/Queue.h 1124901 
  /branches/qpid-3079/qpid/cpp/src/qpid/broker/Queue.cpp 1124901 
  /branches/qpid-3079/qpid/cpp/src/qpid/broker/SemanticState.cpp 1124901 
  /branches/qpid-3079/qpid/cpp/src/qpid/broker/SessionContext.h 1124901 
  /branches/qpid-3079/qpid/cpp/src/qpid/broker/SessionState.h 1124901 
  /branches/qpid-3079/qpid/cpp/src/qpid/broker/SessionState.cpp 1124901 
  /branches/qpid-3079/qpid/cpp/src/tests/QueueTest.cpp 1124901 
  /branches/qpid-3079/qpid/cpp/src/tests/TestMessageStore.h 1124901 

Diff: https://reviews.apache.org/r/820/diff


Testing
-------

None - it compiles.


Thanks,

Kenneth



> message.accept command should be completed on a per-dequeue basis
> -----------------------------------------------------------------
>
>                 Key: QPID-3079
>                 URL: https://issues.apache.org/jira/browse/QPID-3079
>             Project: Qpid
>          Issue Type: Bug
>          Components: C++ Broker
>    Affects Versions: 0.8, 0.9
>            Reporter: Ken Giusti
>            Assignee: Ken Giusti
>             Fix For: 0.11
>
>         Attachments: proposal.txt
>
>
> ** Overview
> Asynchronous completion means that command execution is initiated in one thread
> (a client connection thread) and completed in a different thread.
> When the async store is loaded, message.transfer commands are
> completed by a store thread that does the async write.
> ** Issues with asynchronous completion code as of revision r1029686
> *** Not really asynchronous
> IncompleteMessageList::process blocks the connection thread till all
> outstanding async commands (messages) for the session are complete.
> With the new cluster, this could deadlock since it is blocking a Poller thread.
> *** Race condition for message.transfer
>     
> Sketch of the current code:
> // Called in connection thread 
> PersistableMessage::enqueueAsync { ++counter; } 
> // Called in store thread once message is written.
> PersistableMessage::enqueueComplete { if (--counter == 0) notifyCompleted(); }
> The intent is that notify be called once per message, after the
> message has been written to each queue it was routed to.
> However of a message is routed to N queues, it's possible for
> notifyCompleted to be called up to N times. The store thread could
> call notifyCompleted for the first queue before the connection thread
> has called enqueueAsync for the second queue, and so on.
> *** No asynchronous completion for message.accept
> We do not currently delay completion of message.accept until the
> message is deleted from the async store. This could cause duplicate
> delivery if the broker crashes after completing the message but 
> before it is removed from store.
> There is code in PersistableMessage to maintain a counter for dequeues
> analogous to to the async enqueue code but this is incorrect. 
> Completion of transfer is triggered when all enqueues for a message are complete.
> Completion of accept is triggered for *each* dequeue from a queue independently.
> Furthermore a single accept can reference many messages, so it can't be associated with
a message.
> ** New requirements
> The new cluster design will need to participate in async completion, e.g.
> an accept cannot be comlpeted until the message is 
> - removed from store (if present) AND
> - replicated to the cluster (if present) as dequeued
> The new cluster also needs to asynchronously complete binding commands
> (declare, bind, delete) when they are replicated to the cluster.

--
This message is automatically generated by JIRA.
For more information on JIRA, see: http://www.atlassian.com/software/jira

---------------------------------------------------------------------
Apache Qpid - AMQP Messaging Implementation
Project:      http://qpid.apache.org
Use/Interact: mailto:dev-subscribe@qpid.apache.org


Mime
View raw message