error in deleting a completed job from drizzle persistent queue

Bug #778306 reported by xjchina on 2011-05-06
10
This bug affects 2 people
Affects Status Importance Assigned to Milestone
Gearman
Medium
Brian Aker

Bug Description

>gearmand -vvvvv -q libdrizzle --libdrizzle-host=127.0.0.1 --libdrizzle-port=3306 --libdrizzle-db=gearman --libdrizzle-mysql

when a testq job is completed, gearmand can't delete the completed jobs from the queue,the error log as follows:
    DEBUG [ proc ] libdrizzle done: 04ba70b4-1a3d-461f-8cdb-53ed05e291da
    ERROR [ proc ] snprintf(DELETE)(Success) -> libgearman-server/plugins/queue/drizzle/queue.cc:416
    ERROR [ proc ] Remove from persistent queue(QUEUE_ERROR) -> libgearman-server/server.c:495

I have checked the source code , and found the following codes near 416 line on libgearman-server/plugins/queue/drizzle/queue.cc.
    ssize_t query_size= (ssize_t)snprintf(query.c_str(), query.size(),
                                       "DELETE FROM %s WHERE unique_key='%s' and function_name= '%s'",
                                       queue->table.c_str(),
                                       escaped_unique_name.c_str(),
                                       escaped_function_name.c_str());

   if (query_size < 0 || query_size > (ssize_t)sizeof(query) )
   {
       gearmand_perror("snprintf(DELETE)");
       return GEARMAN_QUEUE_ERROR;
   }
    ...delete operation codes

I added some debug information and rebuild the source code, and I found the value of (ssize_t)sizeof(query) is always 12,
that is the if condition is always true, and delete operation is never invoked.

IMHO, I think it is may not proper that the sizeof operator is used to get the real size of the query object.
when I try query.size(), it will work normally, and the completed jobs can be deleted successfully.

Best Regards

xjchina (xjchina) wrote :

additional, the version of gearmand is 0.20.

Hi!

If you look in trunk (or at the very least lp:gearmand/build) I believe you will find that this is fixed. On inspecting the code again I noticed that the size of the buffer is not completely correct, but in the test cases it is passing. I'll fix that.

Thanks,
 -Brian

On May 5, 2011, at 8:55 PM, xjchina wrote:

> additional, the version of gearmand is 0.20.
>
> --
> You received this bug notification because you are subscribed to
> Gearman.
> https://bugs.launchpad.net/bugs/778306
>
> Title:
> error in deleting a completed job from drizzle persistent queue
>
> Status in Gearman Server and Client Libraries:
> New
>
> Bug description:
>> gearmand -vvvvv -q libdrizzle --libdrizzle-host=127.0.0.1
> --libdrizzle-port=3306 --libdrizzle-db=gearman --libdrizzle-mysql
>
> when a testq job is completed, gearmand can't delete the completed jobs from the queue,the error log as follows:
> DEBUG [ proc ] libdrizzle done: 04ba70b4-1a3d-461f-8cdb-53ed05e291da
> ERROR [ proc ] snprintf(DELETE)(Success) -> libgearman-server/plugins/queue/drizzle/queue.cc:416
> ERROR [ proc ] Remove from persistent queue(QUEUE_ERROR) -> libgearman-server/server.c:495
>
> I have checked the source code , and found the following codes near 416 line on libgearman-server/plugins/queue/drizzle/queue.cc.
> ssize_t query_size= (ssize_t)snprintf(query.c_str(), query.size(),
> "DELETE FROM %s WHERE unique_key='%s' and function_name= '%s'",
> queue->table.c_str(),
> escaped_unique_name.c_str(),
> escaped_function_name.c_str());
>
> if (query_size < 0 || query_size > (ssize_t)sizeof(query) )
> {
> gearmand_perror("snprintf(DELETE)");
> return GEARMAN_QUEUE_ERROR;
> }
> ...delete operation codes
>
> I added some debug information and rebuild the source code, and I found the value of (ssize_t)sizeof(query) is always 12,
> that is the if condition is always true, and delete operation is never invoked.
>
> IMHO, I think it is may not proper that the sizeof operator is used to get the real size of the query object.
> when I try query.size(), it will work normally, and the completed jobs can be deleted successfully.
>
> Best Regards

Brian Aker (brianaker) on 2011-06-06
Changed in gearmand:
assignee: nobody → Brian Aker (brianaker)
status: New → Incomplete
Brian Aker (brianaker) wrote :

I've checked this/made sure the error message will work.

Changed in gearmand:
status: Incomplete → Fix Committed
Brian Aker (brianaker) on 2011-06-08
Changed in gearmand:
importance: Undecided → Medium
Brian Aker (brianaker) on 2011-06-16
Changed in gearmand:
status: Fix Committed → Fix Released
To post a comment you must log in.
This report contains Public information  Edit
Everyone can see this information.

Other bug subscribers