Can't restart when using persistent queue

Bug #1197956 reported by Michael Gauthier on 2013-07-04
6
This bug affects 1 person
Affects Status Importance Assigned to Milestone
Gearman
Undecided
Unassigned

Bug Description

Using PostgreSQL persistent queues.

Gearmand Version: 1.0.6

Server options:
-l /var/log/gearmand/gearmand.log --queue-type=Postgres --libpq-conninfo 'host=myhost dbname=Gearman user=gearman' --libpq-table=Queue --verbose=DEBUG

ERROR 2013-07-04 19:51:49.640038 [ main ] PQexec:ERROR: relation "queue" already exists
 -> libgearman-server/plugins/queue/postgres/queue.cc:226
  ERROR 2013-07-04 19:51:49.640160 [ main ] Failed to initialize postgres: initialize(QUEUE_ERROR) -> libgearman-server/queue.cc:204

Related branches

Servus,

ich bin bis einschliesslich 05 Juli nicht erreichbar.

Viele Gruesse,
 Sven

---

Hi,

i am on vacation till Jul 5th.

Bye,
 Sven

Brian Aker (brianaker) wrote :

std::string query("SELECT tablename FROM pg_tables WHERE tablename='" +queue->table + "'");

This query would need to fail for this error to occur.

On a style related note... this should be using the information_schema.

Brian, thanks for pasting that snippet. It's helpful in tracking down the problem.

The query to check if the table exists (which also looks like it has a SQL injection issue) quotes the table name. In PostgreSQL this preserves case.

If I list the tables manually after connecting to the DB I see the table exists as all lower-case. The other queries (including the table creation) in the PostgreSQL persistent backend must not be quoting the table name. In PostgreSQL this normalizes the table name to lower-case.

I recommend all the queries be updated to use libpq's PQescapeIdentifier to quote the table name properly and consistently in the SQL statements.

To post a comment you must log in.
This report contains Public information  Edit
Everyone can see this information.

Other bug subscribers