apache/shardingsphere · error · InvalidRuleConfigurationException
0
0
Error message
Invalid 'Transaction' rule, error message is: Unsupported transaction type `%s`
What it means
AlterTransactionRuleExecutor validates ALTER TRANSACTION RULE DistSQL before applying it and calls TransactionType.valueOf on DEFAULT_TYPE. If the value is not exactly LOCAL, XA, or BASE (case-insensitive), valueOf throws IllegalArgumentException, which is wrapped into InvalidRuleConfigurationException with the message 'Invalid Transaction rule, error message is: Unsupported transaction type `<type>`'.
Source
Thrown at kernel/transaction/distsql/handler/src/main/java/org/apache/shardingsphere/transaction/distsql/handler/update/AlterTransactionRuleExecutor.java:51
/**
* Alter transaction rule executor.
*/
public final class AlterTransactionRuleExecutor implements GlobalRuleDefinitionExecutor<AlterTransactionRuleStatement, TransactionRule> {
@Override
public void checkBeforeUpdate(final AlterTransactionRuleStatement sqlStatement) {
checkTransactionType(sqlStatement);
TransactionType transactionType = TransactionType.valueOf(sqlStatement.getDefaultType().toUpperCase());
if (TransactionType.LOCAL != transactionType) {
checkTransactionManager(sqlStatement, transactionType);
}
}
private void checkTransactionType(final AlterTransactionRuleStatement statement) {
try {
TransactionType.valueOf(statement.getDefaultType().toUpperCase());
} catch (final IllegalArgumentException ignored) {
throw new InvalidRuleConfigurationException("Transaction", String.format("Unsupported transaction type `%s`", statement.getDefaultType()));
}
}
private void checkTransactionManager(final AlterTransactionRuleStatement statement, final TransactionType transactionType) {
Collection<ShardingSphereDistributedTransactionManager> distributedTransactionManagers = ShardingSphereServiceLoader.getServiceInstances(ShardingSphereDistributedTransactionManager.class);
Optional<ShardingSphereDistributedTransactionManager> distributedTransactionManager =
distributedTransactionManagers.stream().filter(each -> transactionType == each.getTransactionType()).findFirst();
ShardingSpherePreconditions.checkState(distributedTransactionManager.isPresent(),
() -> new InvalidRuleConfigurationException("Transaction", String.format("No transaction manager with type `%s`", statement.getDefaultType())));
if (TransactionType.XA == transactionType) {
checkTransactionManagerProviderType(distributedTransactionManager.get(), statement.getProvider().getProviderType());
}
}
private void checkTransactionManagerProviderType(final ShardingSphereDistributedTransactionManager distributedTransactionManager, final String providerType) {
ShardingSpherePreconditions.checkState(distributedTransactionManager.containsProviderType(providerType),
() -> new InvalidRuleConfigurationException("Transaction", String.format("No transaction manager provider with type `%s`", providerType)));
}View on GitHub (pinned to e952770a21)
Solutions
- Use one of the supported DEFAULT_TYPE values: LOCAL, XA, or BASE (case-insensitive).
- If you intended a specific XA provider, keep DEFAULT_TYPE=XA and put the provider in the PROVIDER clause, e.g. ALTER TRANSACTION RULE ... DEFAULT_TYPE=XA, PROVIDER(TYPE=Narayana).
- Check for typos, extra quotes, or whitespace in the DistSQL string before resubmitting.
- Run SHOW TRANSACTION RULES first to confirm the current rule and syntax on your version.
Example fix
-- before ALTER TRANSACTION RULE DEFAULT_TYPE="XA_ATOMIKOS", PROVIDER(TYPE=Atomikos); -- after ALTER TRANSACTION RULE DEFAULT_TYPE=XA, PROVIDER(TYPE=Atomikos);
Defensive patterns
Strategy: validation
Validate before calling
Set<String> VALID = Set.of("LOCAL", "XA", "BASE");
String t = defaultType.trim().toUpperCase(Locale.ROOT);
if (!VALID.contains(t)) throw new IllegalArgumentException("DEFAULT_TYPE must be one of LOCAL, XA, BASE: " + defaultType); Try / catch
try { proxy.executeSql("ALTER TRANSACTION RULE DEFAULT_TYPE=" + type + ";"); } catch (final InvalidRuleConfigurationException ex) { /* surface message listing supported types; fix DEFAULT_TYPE */ } Prevention
- Whitelist DEFAULT_TYPE to LOCAL/XA/BASE in any tooling that generates DistSQL.
- Do not put provider names (Atomikos/Narayana/Bitronix) in DEFAULT_TYPE; they belong in PROVIDER(TYPE=...).
- Run SHOW TRANSACTION RULES to confirm syntax before ALTER.
When it happens
Trigger: Executing ALTER TRANSACTION RULE ... DEFAULT_TYPE=<value> through ShardingSphere proxy DistSQL where <value> is something like 'XA_MYSQL', 'jdbc', 'none', 'local_trx', or misspelled; checkTransactionType catches the IllegalArgumentException and rethrows the InvalidRuleConfigurationException.
Common situations: Confusing the transaction provider name (e.g. Atomikos, Narayana, Bitronix) with the transaction type; copying example DistSQL with a made-up type; older/newer docs using different type names; trailing whitespace or quotes in the value.
Related errors
- Either key generator name or algorithm segment must be provi
- 12010
- 1
- 1
- 'chunk-size' is not a valid number: `${chunkSizeText}`
AI-assisted analysis of apache/shardingsphere@e952770a21 (2026-08-14).
Data as JSON: /api/errors/d3b9465a70e4fa93.
Report an issue: GitHub.