-
Notifications
You must be signed in to change notification settings - Fork 2k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Receiving notifications about transaction lifecycle #5092
Comments
The transaction orchestration (interactions between transaction agents, managers, and resources) is extensible but the surface is still in flux. The manager logic and resource logic are setup by the transactional state, with the extensions being primarily bridging logic for distributed calls. A transaction participant can act as a transaction manager, resource, or both. This is dictated by the SupportedRoles property in the participantId. For instance, if you wanted a transactional state that only performed as a resource, and not as a manager, the custom transactional state would need only set the supported roles to Role.Resource to indicate this. For examples of how to provide your own transactional logic with custom manager or resource logic, please check out the TOC implementation. We added a TransactionCommitter which uses a service to perform the final commit operation rather than storage. To do this we added a new facet (ITransactionCommitter) and an implementation (TransactionCommitter) which is marked as a primary transaction manager (meaning there can be only one of these in a transaction and it will be selected as manager even if other participants support that behavior). Since the TransactionCommitter is not a resource no resource logic was configured, and the manager logic was customized for the desired behavior. |
@jason-bragg thanks! I'll take a look at the TOC implementation and let you know if I have further questions. |
@jason-bragg did you mean that the TOC implementation can provide this solution or that we should use it as a reference to build our own? I hooked up an I did run into an interesting problem when the grain with the Thanks! |
I mentioned the TOC as a reference implementation. I do not think it will address your needs as is, but can inform the developement of a custom solution. TransactionalState and TransactionCommitter are both stateful. They are not intended to work within stateless workers. :/ |
I've manged to get something (sort of) working along the lines of the TOC implementation. I had to use a local build of Orleans with ContextResourceFactoryExtensions and Another, perhaps more straightforward, question: although I'm only adding resources to the transaction, I'm concerned that I might need to add a manager as well in case the the grain having the observation facet I added is nominated as the transaction manager (either because the transaction has no other participants or because the first participant is selected as the manager if no resources are have the priority manager role). Is this the case? |
@jason-bragg any thoughts on the above? |
Unfortunatly some of the transaction orchestration has changed. ContextResourceFactoryExtensions is gone in 2.2 beta. I suggest updating to that. You 'shouldn't' need access to any internals for what you're doing. If you don't want the facet you're adding to be selected as a manager, set it's supported role only to Resource in it's ParticipantId. |
@jason-bragg I work with @jjmason. We finally got a chance to revisit this on our side and have a few more findings and questions. ContextResourceFactoryExtensions certainly appears to be a necessary part of implementing custom transactional resources. Both In general it would be great to not need to know about (or have access to) to the low level transaction pieces to simply register a hook into the transaction lifecycle. Another question that isn't quite clear: Is it even possible to have a I think we'll be able to use the |
Re: ContextResourceFactoryExtensions - I was in error. Yeah, this is still required and internal, sorry I missed that. Also,I agree that replacing the TransactionalResourceExtension and TransactionManagerExtension is not a good solution. Re: TransactionQueue - Is the internals of the current implementation and is not really part of the extensibility pattern for transaction orchestration. IMO, it's very fragile and unintuitive code that I don't recommend playing with. We've plans to significantly refactor it to improve testability and maintainability.
It does that for normal grains, but not stateless workers, as stateless workers are always considered local to the caller. I think the best one can do in the current system is to use PreferLocalPlacement. This will create a normal grain but try to place it on the same silo as the caller. Thanks for the feedback, and I understand your frustrations. This is the first release of the transaction system and only the grain facing portions of the pattern (Transaction attribution and ITransactionalState) are being locked down this release. The orchestration patterns (ITransactionReasource, ITransactionManager, and related extensions) are still subject to change and the patterns we use there are not settled. I clarify this not to excuse the issues you’ve encountered, only to communicate that the extensibility points you’re working with have not been completely vetted yet. For early adopter efforts like yours, I’d suggest forking the orleans repository, making changes to the transaction orchestration needed for you to implement your patterns, use custom nugets built from your fork, and create pull requests back to Orleans for the changes you’ve made. This will allow you to move forward faster, while integrating the changes you need back into Orleans. Once Orleans releases catch up with your fork, you can switch back to the released Orleans nugets. |
We were able to get the Thanks again for the suggestion. |
Thanks for contacting us. We believe that the question you've raised has been answered. If you still feel a need to continue the discussion, feel free to reopen the issue and add your comments. |
Hi,
I'm looking for a way to send information about changes to grain state to an external service, but only after the transaction in which those changes were made is committed. To do this I'd like to be able to receive a notification (in each silo where the information was reported) after a transaction is confirmed or aborted.
It looks like there is some work around separating transaction management and participation, specifically in #4810, #4820 and #4860. From what I can understand, the idea is to add an
ITransactionalResource
orITransactionalResourceExtension
as a participant in transactions I'm interested in, but it's not clear what the "right" way to do this is.I've run into a few issues going down this route - in particular when a reference to
ITransactionalResourceExtension
is a transaction participant, it is sometimes assumed to also be anITransactionManagerExtension
(for example when it is the first participant added to the transaction).Is separation of transaction management and participation intended to support this kind of use case? If so, is that support ready in version
2.1.0
, and could you point me to some resources as to how to use it?The text was updated successfully, but these errors were encountered: