malthe/pq

Question: why am I seeing "NOTICE: function pq_notify does not exist" in the logs?

Opened this issue · 3 comments

oz123 commented

I am running the two consumers in docker containers. The to run the process is:

def main(queue_name, processor):
    """
    queue is blocking as long as there are no tasks.
    """
    for i in range(20):
        try:
            pq = PQ(database.connection())
            break
        except peewee.OperationalError as err:
            print(err)
            # the database is still not receiving connections
            if re.search("Connection refused", err.args[0]):
                time.sleep(1)
    try:
        pq.create()
    except errors.DuplicateTable:
        print("queue table already exists")

    queue = pq[queue_name]
    print("waiting for jobs ...")

    for job in queue:
        if job is not None:
            print("Processing job id %d" % job.id)
            try:
                processor(**job.data).process()
            except api.ViesError as E:
                queue.put(job.data, schedule_at='5m')
            except Exception as E:
                print("Something weired happend with that data: ", job.data)
                raise E

When I start a fresh postgresql container I see the following logs:

$ docker logs -f vatprocessor 
Sending emails via smtpd:25
processing vat queue
could not connect to server: Connection refused
	Is the server running on host "db" (172.18.0.2) and accepting
	TCP/IP connections on port 5432?

could not connect to server: Connection refused
	Is the server running on host "db" (172.18.0.2) and accepting
	TCP/IP connections on port 5432?

NOTICE:  function pq_notify() does not exist, skipping

waiting for jobs ...
NOTICE:  function pq_notify() does not exist, skipping

NOTICE:  function pq_notify() does not exist, skipping

NOTICE:  function pq_notify() does not exist, skipping

NOTICE:  function pq_notify() does not exist, skipping

NOTICE:  function pq_notify() does not exist, skipping

NOTICE:  function pq_notify() does not exist, skipping

NOTICE:  function pq_notify() does not exist, skipping

NOTICE:  function pq_notify() does not exist, skipping

NOTICE:  function pq_notify() does not exist, skipping

NOTICE:  function pq_notify() does not exist, skipping

Processing job id 1

If I stop the containers and restart them again, I no longer see the NOTICE message.
As far as I can tell my code works fine, despite the notice. I am just curious to know why I am seeing this message.
I believe it comes for the database it's as I could not find any reference to it in the code.

oz123 commented

Update, running in the postgress shell:

portal@db:portaldb> drop function if exists pq_notify() cascade;                                                                                                                                                                             
You're about to run a destructive command.
Do you want to proceed? (y/n): y
Your call!
NOTICE:  function pq_notify() does not exist, skipping

DROP FUNCTION
Time: 0.004s
portal@db:portaldb>  

What is calling create during the iteration?

jobh commented

I think this is probably that the notices are not cleared, and hence they are printed repeatedly whenever the connection is used. See commit 515e7f3.

edit: ...which is part of PR48.

oz123 commented

@jobh thank you so much for answering and fixing the issue!