Skip to content

Commit

Permalink
Make PostgreSQL Dev Services compatible with XA by default
Browse files Browse the repository at this point in the history
By setting --max_prepared_transactions=100 if max_prepared_transactions
is not present in the command.

Fixes #36934
  • Loading branch information
gsmet committed Dec 28, 2024
1 parent 0d3fee5 commit 0fa9369
Showing 1 changed file with 13 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,9 @@ public class PostgresqlDevServicesProcessor {

private static final Logger LOG = Logger.getLogger(PostgresqlDevServicesProcessor.class);

private static final String MAX_PREPARED_TRANSACTIONS = "max_prepared_transactions";
private static final String DEFAULT_MAX_PREPARED_TRANSACTIONS = "--" + MAX_PREPARED_TRANSACTIONS + "=100";

@BuildStep
ConsoleCommandBuildItem psqlCommand(DevServicesLauncherConfigResultBuildItem devServices) {
return new ConsoleCommandBuildItem(new PostgresCommand(devServices));
Expand Down Expand Up @@ -75,7 +78,16 @@ public RunningDevServicesDatasource startDatabase(Optional<String> username, Opt
container.withEnv(containerConfig.getContainerEnv());

containerConfig.getAdditionalJdbcUrlProperties().forEach(container::withUrlParam);
containerConfig.getCommand().ifPresent(container::setCommand);
String augmentedCommand;
if (containerConfig.getCommand().isPresent()) {
String originalCommand = containerConfig.getCommand().get();
augmentedCommand = originalCommand.contains(MAX_PREPARED_TRANSACTIONS) ? originalCommand
: originalCommand + " " + DEFAULT_MAX_PREPARED_TRANSACTIONS;
} else {
augmentedCommand = DEFAULT_MAX_PREPARED_TRANSACTIONS;
}
container.setCommand(augmentedCommand);

containerConfig.getInitScriptPath().ifPresent(container::withInitScript);
if (containerConfig.isShowLogs()) {
container.withLogConsumer(new JBossLoggingConsumer(LOG));
Expand Down

0 comments on commit 0fa9369

Please sign in to comment.