500 Errors accessing rest data from multiple threads

tshannon

Joined: 2012-04-20
Posts: 7
Posted: Fri, 2012-04-20 17:04

I'm writting a command line uploader that uses the REST api, and I'm uploading the data on 5 threads currently, and occassionaly I'm getting the following errors:

Quote:
2012-04-20 11:12:09 -05:00 --- error: Exception [ 0 ]: @todo UNABLE_TO_LOCK_EXCEPTION
/srv/www/<websiteurl>/public_html/gallery3/modules/gallery/libraries/ORM_MPTT.php [ 329 ]
#0 /srv/www/<websiteurl>/public_html/gallery3/modules/gallery/libraries/ORM_MPTT.php(50): ORM_MPTT_Core->lock()
#1 /srv/www/<websiteurl>/public_html/gallery3/modules/gallery/models/item.php(367): ORM_MPTT_Core->save()
#2 /srv/www/<websiteurl>/public_html/gallery3/modules/gallery/helpers/item_rest.php(181): Item_Model_Core->save()
#3 [internal function]: item_rest_Core::post(Object(stdClass))
#4 /srv/www/<websiteurl>/public_html/gallery3/modules/rest/controllers/rest.php(104): call_user_func(Array, Object(stdClass))
#5 [internal function]: Rest_Controller->__call('item', Array)
#6 /srv/www/<websiteurl>/public_html/gallery3/system/core/Kohana.php(331): ReflectionMethod->invokeArgs(Object(Rest_Controller), Array)
#7 [internal function]: Kohana_Core::instance(NULL)
#8 /srv/www/<websiteurl>/public_html/gallery3/system/core/Event.php(208): call_user_func_array(Array, Array)
#9 /srv/www/<websiteurl>/public_html/gallery3/application/Bootstrap.php(67): Event_Core::run('system.execute')
#10 /srv/www/<websiteurl>/public_html/gallery3/index.php(102): require('/srv/www/<websiteurl>...')
#11 {main}
2012-04-20 11:12:09 -05:00 --- error: Exception [ 0 ]: @todo UNABLE_TO_LOCK_EXCEPTION
/srv/www/<websiteurl>/public_html/gallery3/modules/gallery/libraries/ORM_MPTT.php [ 329 ]
#0 /srv/www/<websiteurl>/public_html/gallery3/modules/gallery/libraries/ORM_MPTT.php(50): ORM_MPTT_Core->lock()
#1 /srv/www/<websiteurl>/public_html/gallery3/modules/gallery/models/item.php(367): ORM_MPTT_Core->save()
#2 /srv/www/<websiteurl>/public_html/gallery3/modules/gallery/helpers/item_rest.php(181): Item_Model_Core->save()
#3 [internal function]: item_rest_Core::post(Object(stdClass))
#4 /srv/www/<websiteurl>/public_html/gallery3/modules/rest/controllers/rest.php(104): call_user_func(Array, Object(stdClass))
#5 [internal function]: Rest_Controller->__call('item', Array)
#6 /srv/www/<websiteurl>/public_html/gallery3/system/core/Kohana.php(331): ReflectionMethod->invokeArgs(Object(Rest_Controller), Array)
#7 [internal function]: Kohana_Core::instance(NULL)
#8 /srv/www/<websiteurl>/public_html/gallery3/system/core/Event.php(208): call_user_func_array(Array, Array)
#9 /srv/www/<websiteurl>/public_html/gallery3/application/Bootstrap.php(67): Event_Core::run('system.execute')
#10 /srv/www/<websiteurl>/public_html/gallery3/index.php(102): require('/srv/www/<websiteurl>...')
#11 {main}

My webserver isn't a powerhouse, and at this point I'm working on the assuming that it's a resource bottleneck issue (probabaly CPU), and I'm looking for some confirmation.

Is that what this error could be referring to, or is this something else?

For those interested, the commandline uploader is here: http://code.google.com/p/gal3upload

It's a work in progress, but should be finished shortly.

 
floridave
floridave's picture

Joined: 2003-12-22
Posts: 27300
Posted: Sat, 2012-04-21 03:49

I have never used REST so can rellay comment on that but the error comes from this function:

  /**
   * Lock the tree to prevent concurrent modification.
   */
  protected function lock() {
    $result = $this->db->query("SELECT GET_LOCK('{$this->table_name}', 1) AS l")->current();
    if (empty($result->l)) {
      throw new Exception("@todo UNABLE_TO_LOCK_EXCEPTION");
    }
  }

Are you trying to do muti uploads at the same time?
Maybe the script is not finished before going to the next image?

Dave
_____________________________________________
Blog & G2 || floridave - Gallery Team

 
tshannon

Joined: 2012-04-20
Posts: 7
Posted: Sun, 2012-04-22 03:25

I'm absolutely doing multiple uploads at the same time. I would assume that it could run multithreaded on the server.

 
floridave
floridave's picture

Joined: 2003-12-22
Posts: 27300
Posted: Sun, 2012-04-22 04:32

could be a server setting:
FAQ: Why do I get a Error #2038 when I try to upload more than one item
but like I said I'm no REST guy.

Dave
_____________________________________________
Blog & G2 || floridave - Gallery Team