Assertion with non-blocking mode in 0.27

Bug #917006 reported by Dan Johansson
6
This bug affects 1 person
Affects Status Importance Assigned to Milestone
Gearman
Invalid
Undecided
Unassigned

Bug Description

I am using gearman client with the php extension and the gearmanamanger to manage multiple worker threads. Using non-blocking mode, causes this assertion:

libgearman/universal.cc:519: bool gearman_request_option(gearman_universal_st&,
gearman_string_t&): Assertion `con->recv_state ==
GEARMAN_CON_RECV_UNIVERSAL_NONE' failed.

Reverting to 0.26 seems to have another bug that was already reported and fixed, ill probably have to go back to 0.24 or something to get this to work in the meantime.

Revision history for this message
Brian Aker (brianaker) wrote :

Can you provide a test case?

Changed in gearmand:
status: New → Incomplete
Revision history for this message
Dan Johansson (datasage) wrote :

Yes I can, but I want to first add some information on other tests I have done. I dont know if this problem is due to the php extension, or libgearman. I've put a bug report with the php extension as well.

Combinations I've tested - On Fedora 16 64bit
libgearman - .23 pecl - 0.7 = Works
libgearman - .23 pecl - 0.8 = Works
libgearman - .23 pecl - 1.01 = A different assertion ( Assertion "packet->universal" failed for function "gearman_packet_free" likely for "Packet that is being freed has not been allocated, most likely this is do to freeing a gearman_task_st or other object twice", at libgearman/packet.cc:254 )

On Amazon Linux (32bit) I only tested pecl 1.01, with version of libgearman .23 to .27 the earlier versions had other assertions that were already documented. I think i should give pecl .8 a shot to see if that might be the cause of my issues.

The code I am using is this: https://github.com/brianlmoon/GearmanManager, Specifically:

protected function start_lib_worker($worker_list) {

        $thisWorker = new GearmanWorker();

        $thisWorker->addOptions(GEARMAN_WORKER_NON_BLOCKING);

        $thisWorker->setTimeout(5000);

        foreach($this->servers as $s){
            $this->log("Adding server $s", GearmanManager::LOG_LEVEL_WORKER_INFO);
            $thisWorker->addServers($s);
        }

        foreach($worker_list as $w){
            $this->log("Adding job $w", GearmanManager::LOG_LEVEL_WORKER_INFO);
            $thisWorker->addFunction($w, array($this, "do_job"), $this);
        }

        $start = time();

        while(!$this->stop_work){

            if(@$thisWorker->work() ||
               $thisWorker->returnCode() == GEARMAN_IO_WAIT ||
               $thisWorker->returnCode() == GEARMAN_NO_JOBS) {

                if ($thisWorker->returnCode() == GEARMAN_SUCCESS) continue;

                if (!@$thisWorker->wait()){
                    if ($thisWorker->returnCode() == GEARMAN_NO_ACTIVE_FDS){
                        sleep(5);
                    }
                }

            }

            /**
             * Check the running time of the current child. If it has
             * been too long, stop working.
             */
            if($this->max_run_time > 0 && time() - $start > $this->max_run_time) {
                $this->log("Been running too long, exiting", GearmanManager::LOG_LEVEL_WORKER_INFO);
                $this->stop_work = true;
            }

            if(!empty($this->config["max_runs_per_worker"]) && $this->job_execution_count >= $this->config["max_runs_per_worker"]) {
                $this->log("Ran $this->job_execution_count jobs which is over the maximum({$this->config['max_runs_per_worker']}), exiting", GearmanManager::LOG_LEVEL_WORKER_INFO);
                $this->stop_work = true;
            }

        }

        $thisWorker->unregisterAll();

    }

Revision history for this message
Dan Johansson (datasage) wrote :

I can now confirm that it appears to be an issue with the php extension and not libgearman. I downgraded to 0.8.1 and the problem goes away. I suppose we can close this issue and take it over to the pecl bug database.

Brian Aker (brianaker)
Changed in gearmand:
status: Incomplete → Invalid
To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.