postgresql-embedded
postgresql-embedded copied to clipboard
Problem brining postgres up on windows 7 using version 1.15
There is a problem with the args which are used in the ProcessBuilder which causes postgres not to launch properly on windows with no errors or any output indicating an issue. Subsequently createdb.exe fails its 3 attempts. This problem occurs using Command.PgCtl as well as Postgres. I tried this on two windows 7 systems (32 and 64 bit) both fail with this same problem. On 'nix systems it works fine.
The issue is the "-o "-p
args.add("-o");
args.add("-p
Here is a snippet of my workaround:
private void start() {
IRuntimeConfig config = new RuntimeConfigBuilder().defaults(Command.PgCtl)
// rewrite args using ICommandLinePostProcessor
.commandLinePostProcessor(new CommandLinePostProcessor(net.port()))
.build();
}
private static class CommandLinePostProcessor implements ICommandLinePostProcessor {
private int port;
public CommandLinePostProcessor(int port) {
this.port = port;
}
@Override
public List<String> process(Distribution distribution, List<String> args) {
String command = args.get(0);
if (!command.contains("pg_ctl")) {
return args;
}
String datadir = args.get(3);
args.clear();
args.add(command);
args.add(format("-o"));
// this is the issue, rewriting fixes the problem
args.add(format("-p %s -h 127.0.0.1", port));
args.add("-D");
args.add(datadir);
args.add("-w");
stopArgs = new ArrayList<String>(args);
args.add("start");
return args;
}
}
I can confirm having the same issue: postgres does not launch properly, there are no errors or any output indicating an issue, and createdb.exe fails its 3 attempts. However, affected versions are different for me: I have the issue only on release 1.16, and everything works fine on 1.15. Tested on both Windows 7 and 10 64 bits.
My workaround was to downgrade to version 1.15.
@zsolt-donca Can you trace the problem in the code? I don't have an ability to test the library on Windows for now, so it would be really helpful.