pgAgent does not start with message “ERROR: Couldn't register event handle.”

2018-05-18 Thread Arturas Mazeika
Dear postgres Folk,

I am able to start the pgAgent in debug mode on a windows (server 2016)
machine with the help of

C:\Program Files (x86)\pgAgent\bin>pgagent.exe DEBUG "host=localhost
port=5432 user=postgres dbname=postgres password="

I also tested that I can start jobs through pgAdmin III.

Starting a service from services in Windows fails with a generic message.
If I login as postgres user

runas /user:postgres cmd

and then try to start the service there using the same command as in
services:

C:\Program Files (x86)\pgAgent\bin>pgagent.exe RUN pgAgent
"host=localhost port=5432 user=postgres dbname=postgres password=***"

I get an error

ERROR: Couldn't register event handle.

(which is what I suppose the service does) How can I solve the issue?

(supplying a password over command line is not a problem. We have
successfully tested different approaches including pgpass and pg_hba
successfully. I am trying to nail down why the service does not start in a
regular way here).

I believe that the version of pgAgent is 1.22.

I posted this question also on

https://dba.stackexchange.com/questions/207067/pgagent-does-not-start-with-message-error-couldnt-register-event-handle

Cheers,
Arturas


Fwd: pgAgent: ERROR: Couldn't register event handle.

2018-06-11 Thread Arturas Mazeika
Hi PG-Admin Supporters,

maybe you could help me with this issue?

I am overseeing a few hundred/thousand  postgres/pgagent installations and
on one installation the pgAgent does not start with a message as a service
on a Windows Server:

ERROR: Couldn't register event handle.

once the service is being started. Investigation showed that this is not an
issue of logging in as postgres, neither is this a connection issue to the
postgres DB, see more details at

https://dba.stackexchange.com/questions/207067/pgagent-does-
not-start-with-message-error-couldnt-register-event-handle


It seems to me that pgAgent tries and fails to write something to the
windows logger . To confirm/reject this hypothesis I decided to download
the sources of pgAgent adjust the code a bit, and see it for myself. This
is what I did:

(1) I installed MS Visual Studio 2017 Community (MSVS)
(2) I downloaded wxWidgets, compiled it with the MSVS in UTF, Debugging and
Release, win32 Settings (to F:\pgbuild\wxWidgets-3.1.1)
(3) I downloaded, extracted, cmake-gui'ed pgAgent-3.4.0-Source into
F:\pgbuild\pgAgent-3.4.0-Source
(4) I download the 9.6 32bit postgres and extracted it into F:\pgbuild\pgsql
(5) I adjusted pgAgent MSVS solution configuration to include
F:\pgbuild\wxWidgets-3.1.1\lib\vc_lib\mswud and F:\pgbuild\pgsql\lib
(6) F:\pgbuild  has also libiconv, libxml2, libxslt
(7) I am able to compile pgAgent to the point that the executable is
created (that dies if I run it), other targets (ALL_BUILD, INSTALL, etc.)
cannot be built successfully with the following error:


1>-- Build started: Project: run, Configuration: Debug Win32 --
1>Generating pgagent--3.4.sql, pgagent.control
1>CUSTOMBUILD : CMake error : Error processing file: cmake/MakeExt.cmake
1>Done building project "run.vcxproj" -- FAILED.
2>-- Skipped Build: Project: INSTALL, Configuration: Debug Win32 --
2>Project not selected to build for this solution configuration
3>-- Skipped Build: Project: PACKAGE, Configuration: Debug Win32 --
3>Project not selected to build for this solution configuration
== Build: 0 succeeded, 1 failed, 4 up-to-date, 2 skipped ==

After inspecting the run.vcxproj file, I realized that the compilation
error was caused by the directory issues (adding "cd ..") solved the
building issues for the "run" project. Running the application fails with
the error:

The application was unable to start correctly (0xc07b). Click OK to
close the application.


Questions:

(1) Any comment how to address the initial problem (ERROR: Couldn't
register event handle.)
(2) Any comments, how to get pgAgent running?


Cheers,
Arturas



PS. The original message to pgsql-hackers mailing lists can be found at:

http://www.postgresql-archive.org/pgAgent-does-not-start-
with-message-ERROR-Couldn-t-register-event-handle-td6021519.html
https://www.postgresql.org/message-id/CAAUL=chzjuqdb3xkouk3qf0uuk8+dx6ow2xmtfw2wupdhsa...@mail.gmail.com



-- Forwarded message --
Date: Thu, May 31, 2018 at 8:54 PM
Subject: Re: pgAgent: ERROR: Couldn't register event handle.
Cc: "pgsql-hack...@postgresql.org" 


On Tue, May 29, 2018 at 8:15 AM, Arturas Mazeika wrote:
> I am overseeing a few hundred/thousand  postgres/pgagent installations and
> on one installation the pgAgent does not start with a message as a service
> on a Windows Server:
>
> ERROR: Couldn't register event handle.

I think that this isn't the right mailing list for pgAgent questions.
Perhaps the pgAdmin mailing list is the right place, since pgagent is,
IIRC, distributed from the pgAdmin site?

-- 
Robert Haas
EnterpriseDB: http://www.enterprisedb.com
The Enterprise PostgreSQL Company