-
Notifications
You must be signed in to change notification settings - Fork 2.7k
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
Allow configuring the Narayana transaction log to be stored in a Datasource #31066
Comments
P.S. obviously when enabling this capability, we'll need to require assignment of a Transactionmanager node identifier; ideally this could be set by an operator, but that's hypothetical: we don't want to require such an operator. |
I've made the appropriate changes to Narayana but I now need to update the narayana-jta extension so that it can look at the config and, if required, create a DataSource (and pass it to the Narayana for use with the JDBCStore). Are there any examples of how I should do this, Sanne said that creating datasources directly is an "anti-pattern" and we should be using some other mechanism for it. Can someone, such as @Sanne for example, advise on how best to proceed, thanks. |
@gsmet or @yrodiere can either of you help? Narayana needs a reference to a datasource to be used to store the transaction logs. I expect it to grab a reference to the default datasource when there's a single one or no configuration is provided, or it to allow being pointed to a particular datasource by name - very similar to other components. |
@mmusgrov I concur: you should have a configuration property in your extension that the user can set to point to a particular datasource, and if relevant use the default datasource. The Hibernate ORM extension does something similar here: Lines 1229 to 1248 in 4bbc70e
In your case, I guess you will have to:
Don't hesitate to ping me if that's not enough to get you going; perhaps it would be easier to discuss this on Zulip. |
@mmusgrov @Sanne if I understand correctly, I suppose that Otherwise, we need to introduce a |
We will be providing an option to configure a datasource for the JDBC Store so yes, if the user configures one then it will used otherwise we will still fallback to using the file system. @yrodiere thanks for your detailed explanation of what I need to do but, to be honest I'm not that familiar with this kind of set up, for example what's the relationship between the |
None whatsoever, at the moment. You will introduce the relationship: users put a datasource name in
In
That being said, the default datasource doesn't have a name, so if you want the selection of a datasource to be explicit, this won't work:
So it would indeed be a good idea to introduce a switch that doesn't involve selecting a datasource:
There are, but they are more complex than what you need, so... If you're ready for some digging, see: Lines 23 to 29 in 13a496a
Lines 1225 to 1244 in 75b8ad4
` |
IIRC, the default datasource name would be Lines 8 to 12 in 75b8ad4
But I agree that @mmusgrov I can help you to setup these |
@zhfeng That is a most kind offer, thank you Amos. And I have a question; if the datasource needs to be defined in the application properties file wouldn't that mean the user wants to use the JDBCStore in which case requiring him to also define a store type might introduce ambiguity. That said, there are two file system store types (the default ShadowingStore one and the journal based one) so we also need a way to disambiguate those two alternatives. |
You can implement whatever behavior you want:
When implementing such dynamic defaults, the convention is general to define the corresponding config property as an |
Thanks @yrodiere and I prefer to the simple one with hardcodes default type at this time. @mmusgrov WDYT? @Sanne do we need to backport this one to 2.16.x ? |
@zhfeng no I wouldn't backport at this stage. We can certainly take that in consideration in the future if there's need for it, but let's give it some time first. |
Unfortunately there is cycle dependent between agroal and narayana-jta extension currently
agroal produces So we need to have some changes
|
@mmusgrov I'm not sure it is feasible for narayana with these changes. We need a further discussion |
From what I understand, the cycle is caused by the (artificial) dependency of Agroal on I'd need to understand why that artificial dependency ( If it's only to ensure things happen in the correct order during static/runtime init (i.e. in recorders), then we may have other solutions than just introducing dependencies between build items. If it's actually some build-time dependency, we might be able to solve the problem by splitting Can someone explain what the |
I suppose that was the explanation:
Though I'm not sure if which of those are build-time dependencies and which are runtime dependencies. If it's exclusively a runtime problem (e.g. |
We already need a release of Narayana to facilitate this work so it's no problem adding more changes to Narayana. |
Yeah, that's exactly my proposal to introduce a lazy initialization of |
Now I'm blocked by JBTM-3760 to test my idea with the Narayana 6.0.1-SNAPSHOT. |
Is this fixed with #31729? |
It is, thanks for the heads-up. |
Description
The Narayana project has the capability to store the transaction logs into a JDBC Datasource; this should be our recommendation for users needing transaction recovery capabilities, especially when running in volatile containers.
We currently don't seemt to expose the configuration properties to enable this component and bind it to a Datasource managed by Quarkus; also Narayana is only exposing an API which accepts a JDBC URL while we would highly prefer to inject the Datasource by instance. Allowing the
Datasource
to be injected is most likely trivial but will need to be patched at the Narayana side first: we don't want to start additional connections which could bypass the connection pool limits and risk resource starvation.Secondarily, schema creation control would need to be configurable. Currently Narayana will always check for the existence of the expected tables and attempt to create them when missing; it would be preferrable to expose some more flexibility, such as to log/generate the SQL scripts to create them instead, to allow controlling such aspects with schema evolution tools and/or potentially with different user credentials than the ones used at runtime.
The text was updated successfully, but these errors were encountered: