Skip to content

Commit

Permalink
Rework quarkus.transaction-manager.unsafe-multiple-last-resources t…
Browse files Browse the repository at this point in the history
…o accept `warn-first` and `warn-each`
  • Loading branch information
yrodiere committed May 14, 2024
1 parent d5c2ed5 commit 3b008a8
Show file tree
Hide file tree
Showing 4 changed files with 24 additions and 8 deletions.
10 changes: 7 additions & 3 deletions docs/src/main/asciidoc/datasource.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -579,9 +579,13 @@ could possibly be applied to only some of the non-XA datasources,
with other non-XA datasources having already committed their changes,
leaving your overall system in an inconsistent state.
Setting this property to `warn` leads to the same unsafe behavior,
but with a warning being logged on each offending transaction,
instead of a single one on startup.
Alternatively, you can allow the same unsafe behavior,
but with warnings when it is taken advantage of:
* setting the property to `warn-each`
would result in logging a warning on *each* offending transaction.
* setting the property to `warn-first`
would result in logging a warning on the *first* offending transaction.
We do not recommend using this configuration property,

Check warning on line 590 in docs/src/main/asciidoc/datasource.adoc

View workflow job for this annotation

GitHub Actions / Linting with Vale

[vale] reported by reviewdog 🐶 [Quarkus.Fluff] Depending on the context, consider using 'using more direct instructions' rather than 'recommend'. Raw Output: {"message": "[Quarkus.Fluff] Depending on the context, consider using 'using more direct instructions' rather than 'recommend'.", "location": {"path": "docs/src/main/asciidoc/datasource.adoc", "range": {"start": {"line": 590, "column": 1}}}, "severity": "INFO"}

Check warning on line 590 in docs/src/main/asciidoc/datasource.adoc

View workflow job for this annotation

GitHub Actions / Linting with Vale

[vale] reported by reviewdog 🐶 [Quarkus.TermsSuggestions] Depending on the context, consider using 'by using' or 'that uses' rather than 'using'. Raw Output: {"message": "[Quarkus.TermsSuggestions] Depending on the context, consider using 'by using' or 'that uses' rather than 'using'.", "location": {"path": "docs/src/main/asciidoc/datasource.adoc", "range": {"start": {"line": 590, "column": 10}}}, "severity": "INFO"}
and we plan to remove it in the future,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -182,7 +182,14 @@ public void allowUnsafeMultipleLastResources(NarayanaJtaRecorder recorder,
logCleanupFilters.produce(
new LogCleanupFilterBuildItem("com.arjuna.ats.arjuna", "ARJUNA012139", "ARJUNA012141", "ARJUNA012142"));
}
case WARN -> {
case WARN_FIRST -> {
recorder.allowUnsafeMultipleLastResources(capabilities.isPresent(Capability.AGROAL), true);
// we will handle the warnings ourselves at runtime init when the option is set explicitly
// but we still want Narayana to produce a warning on the first offending transaction
logCleanupFilters.produce(
new LogCleanupFilterBuildItem("com.arjuna.ats.arjuna", "ARJUNA012139", "ARJUNA012142"));
}
case WARN_EACH -> {
recorder.allowUnsafeMultipleLastResources(capabilities.isPresent(Capability.AGROAL), false);
// we will handle the warnings ourselves at runtime init when the option is set explicitly
// but we still want Narayana to produce one warning per offending transaction
Expand All @@ -199,7 +206,7 @@ public void nativeImageFeature(TransactionManagerBuildTimeConfig transactionMana
BuildProducer<NativeImageFeatureBuildItem> nativeImageFeatures) {
switch (transactionManagerBuildTimeConfig.unsafeMultipleLastResources
.orElse(UnsafeMultipleLastResourcesMode.DEFAULT)) {
case ALLOW, WARN -> {
case ALLOW, WARN_FIRST, WARN_EACH -> {
nativeImageFeatures.produce(new NativeImageFeatureBuildItem(DisableLoggingFeature.class));
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@
import java.util.Arrays;
import java.util.Collections;
import java.util.List;
import java.util.Locale;
import java.util.Map;
import java.util.Properties;
import java.util.Set;
Expand All @@ -30,6 +29,7 @@
import io.quarkus.runtime.ShutdownContext;
import io.quarkus.runtime.annotations.Recorder;
import io.quarkus.runtime.configuration.ConfigurationException;
import io.quarkus.runtime.util.StringUtil;

@Recorder
public class NarayanaJtaRecorder {
Expand Down Expand Up @@ -132,7 +132,7 @@ public void logUnsafeMultipleLastResourcesOnStartup(
TransactionManagerBuildTimeConfig.UnsafeMultipleLastResourcesMode mode) {
log.warnf(
"Setting quarkus.transaction-manager.unsafe-multiple-last-resources to '%s' makes adding multiple resources to the same transaction unsafe.",
mode.name().toLowerCase(Locale.ROOT));
StringUtil.hyphenate(mode.name()).replace('_', '-'));
}

private void setObjectStoreDir(String name, TransactionManagerConfiguration config) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,11 +42,16 @@ public enum UnsafeMultipleLastResourcesMode {
* but not on each use of multiple XA unaware resources in the same transactional demarcation.
*/
ALLOW,
/**
* Allow using multiple XA unaware resources in the same transactional demarcation,
* but log a warning on the first occurrence.
*/
WARN_FIRST,
/**
* Allow using multiple XA unaware resources in the same transactional demarcation,
* but log a warning on each occurrence.
*/
WARN,
WARN_EACH,
/**
* Allow using multiple XA unaware resources in the same transactional demarcation,
* but log a warning on each occurrence.
Expand Down

0 comments on commit 3b008a8

Please sign in to comment.