tengine/tengine — pull request #4 by akm (2013-02-13 04:49:57+00:00)
Title: 20130213 driver cache warning

## 現象
並列のジョブを３つのtenginedで動かすと、３つのプロセス中の２つで下のエラーメッセージBが出て、プロセスが止まってしまいます。

## 原因
これはtenginedプロセスが、デフォルトではイベントを受信するたびにDSLをロードするようになっており、その際は各プロセスがどれぞれ自分が登録したdriverのidを使って再ロードしようとして、最後のプロセス以外は自分が登録したdriverを見つけられないためです。

## 対応策
これを防ぐためには、現時点では、イベントを受信した際にDSLをロードする処理を行わないようにするために、 --tengined-cache-drivers オプションを指定する必要があります。

対応策として、--tengined-cache-driversオプションを指定することを促すエラーメッセージAのようなメッセージを、エラーが発生する際に出力するようにしました。

また、 --tengined-cache-drivers というオプションも長いので、-cという短いオプションも設定しました。

## エラーメッセージA
```
2013-02-13T13:35:03+09:00 STDERR [63007] failed to reload driver. Use --tengined-cache-drivers option if you execute multiple tengined process. driver : #.
```

## エラーメッセージB
```
$ bundle exec tengined -T examples/0027_parallel_ssh_jobs.rb
(略)
2013-02-13T11:44:28+09:00 STDOUT ****************************************************************************************************
2013-02-13T11:44:28+09:00 STDOUT Tengine::Job.notify /Users/akima/tengine/tengine_job/lib/tengine/job/drivers/job_control_driver.rb
2013-02-13T11:44:28+09:00 STDOUT Tengine::Job.notify /Users/akima/tengine/tengine_job/lib/tengine/job/drivers/job_execution_driver.rb
2013-02-13T11:44:28+09:00 STDOUT Tengine::Job.notify /Users/akima/tengine/tengine_job/lib/tengine/job/drivers/jobnet_control_driver.rb
2013-02-13T11:44:28+09:00 STDOUT Tengine::Job.notify /Users/akima/tengine/tengine_job/lib/tengine/job/drivers/schedule_driver.rb
2013-02-13T11:44:28+09:00 STDERR mq.connection.on_tcp_connection_loss.
/Users/akima/.rbenv/versions/1.9.3-p327/lib/ruby/gems/1.9.1/gems/mongoid-3.0.19/lib/mongoid/reloading.rb:21:in `reload': (Mongoid::Errors::DocumentNotFound)
Problem:
Document(s) not found for class Tengine::Core::Driver with id(s) 511afe0c5427db0aca000068.
Summary:
When calling Tengine::Core::Driver.find with an id or array of ids, each parameter must match a document in the database or this error will be raised. The search was for the id(s): 511afe0c5427db0aca000068 (1 total) and the following ids were not found: 511afe0c5427db0aca000068.
Resolution:
Search for an id that is in the database or set the Mongoid.raise_not_found_error configuration option to false, which will cause a nil to be returned instead of raising this error when searching for a single id, or only the matched documents when searching for multiples.
from /Users/akima/.rbenv/versions/1.9.3-p327/lib/ruby/gems/1.9.1/gems/tengine_core-1.1.0/lib/tengine/core/driveable.rb:56:in `method_added'
from /Users/akima/.rbenv/versions/1.9.3-p327/lib/ruby/gems/1.9.1/gems/tengine_core-1.1.0/lib/tengine/core/driveable.rb:158:in `define_method'
from /Users/akima/.rbenv/versions/1.9.3-p327/lib/ruby/gems/1.9.1/gems/tengine_core-1.1.0/lib/tengine/core/driveable.rb:158:in `block in on'
from /Users/akima/.rbenv/versions/1.9.3-p327/lib/ruby/gems/1.9.1/gems/tengine_core-1.1.0/lib/tengine/core/driveable.rb:157:in `instance_eval'
from /Users/akima/.rbenv/versions/1.9.3-p327/lib/ruby/gems/1.9.1/gems/tengine_core-1.1.0/lib/tengine/core/driveable.rb:157:in `on'
from /Users/akima/tengine/tengine_job/lib/tengine/job/drivers/job_control_driver.rb:177:in `block in '
from /Users/akima/.rbenv/versions/1.9.3-p327/lib/ruby/gems/1.9.1/gems/tengine_core-1.1.0/lib/tengine/core/dsl_loader.rb:82:in `module_eval'
from /Users/akima/.rbenv/versions/1.9.3-p327/lib/ruby/gems/1.9.1/gems/tengine_core-1.1.0/lib/tengine/core/dsl_loader.rb:82:in `driver'
from /Users/akima/tengine/tengine_job/lib/tengine/job/drivers/job_control_driver.rb:15:in `'
from /Users/akima/.rbenv/versions/1.9.3-p327/lib/ruby/gems/1.9.1/gems/activesupport-3.2.11/lib/active_support/dependencies.rb:245:in `load'
from /Users/akima/.rbenv/versions/1.9.3-p327/lib/ruby/gems/1.9.1/gems/activesupport-3.2.11/lib/active_support/dependencies.rb:245:in `block in load'
from /Users/akima/.rbenv/versions/1.9.3-p327/lib/ruby/gems/1.9.1/gems/activesupport-3.2.11/lib/active_support/dependencies.rb:236:in `load_dependency'
from /Users/akima/.rbenv/versions/1.9.3-p327/lib/ruby/gems/1.9.1/gems/activesupport-3.2.11/lib/active_support/dependencies.rb:245:in `load'
from /Users/akima/tengine/tengine_job/lib/tengine/job.rb:59:in `block in notify'
from /Users/akima/tengine/tengine_job/lib/tengine/job.rb:56:in `each'
from /Users/akima/tengine/tengine_job/lib/tengine/job.rb:56:in `notify'
from /Users/akima/.rbenv/versions/1.9.3-p327/lib/ruby/gems/1.9.1/gems/tengine_core-1.1.0/lib/tengine/core/plugins.rb:26:in `block in notify'
from /Users/akima/.rbenv/versions/1.9.3-p327/lib/ruby/gems/1.9.1/gems/tengine_core-1.1.0/lib/tengine/core/plugins.rb:25:in `each'
from /Users/akima/.rbenv/versions/1.9.3-p327/lib/ruby/gems/1.9.1/gems/tengine_core-1.1.0/lib/tengine/core/plugins.rb:25:in `notify'
from /Users/akima/.rbenv/versions/1.9.3-p327/lib/ruby/gems/1.9.1/gems/tengine_core-1.1.0/lib/tengine/core/plugins.rb:23:in `notify'
from /Users/akima/.rbenv/versions/1.9.3-p327/lib/ruby/gems/1.9.1/gems/tengine_core-1.1.0/lib/tengine/core/dsl_evaluator.rb:12:in `__evaluate__'
from /Users/akima/.rbenv/versions/1.9.3-p327/lib/ruby/gems/1.9.1/gems/tengine_core-1.1.0/lib/tengine/core/kernel.rb:83:in `evaluate'
from /Users/akima/.rbenv/versions/1.9.3-p327/lib/ruby/gems/1.9.1/gems/tengine_core-1.1.0/lib/tengine/core/kernel.rb:217:in `block (2 levels) in process_message'
from /Users/akima/.rbenv/versions/1.9.3-p327/lib/ruby/gems/1.9.1/gems/tengine_core-1.1.0/lib/tengine/core/kernel_runtime.rb:10:in `safety_processing_headers'
from /Users/akima/.rbenv/versions/1.9.3-p327/lib/ruby/gems/1.9.1/gems/tengine_core-1.1.0/lib/tengine/core/kernel.rb:208:in `block in process_message'
from /Users/akima/.rbenv/versions/1.9.3-p327/lib/ruby/gems/1.9.1/gems/tengine_core-1.1.0/lib/tengine/core/kernel_runtime.rb:65:in `safety_processing_event'
from /Users/akima/.rbenv/versions/1.9.3-p327/lib/ruby/gems/1.9.1/gems/tengine_core-1.1.0/lib/tengine/core/kernel.rb:144:in `process_message'
from /Users/akima/.rbenv/versions/1.9.3-p327/lib/ruby/gems/1.9.1/gems/tengine_core-1.1.0/lib/tengine/core/method_traceable.rb:22:in `process_message'
from /Users/akima/.rbenv/versions/1.9.3-p327/lib/ruby/gems/1.9.1/gems/tengine_core-1.1.0/lib/tengine/core/kernel.rb:135:in `block in subscribe_queue'
from /Users/akima/.rbenv/versions/1.9.3-p327/lib/ruby/gems/1.9.1/gems/tengine_event-1.1.0/lib/tengine/mq/suite.rb:274:in `block (2 levels) in subscribe'
from /Users/akima/.rbenv/versions/1.9.3-p327/lib/ruby/gems/1.9.1/gems/amqp-0.8.4/lib/amqp/consumer.rb:125:in `call'
from /Users/akima/.rbenv/versions/1.9.3-p327/lib/ruby/gems/1.9.1/gems/amqp-0.8.4/lib/amqp/consumer.rb:125:in `block in on_delivery'
from /Users/akima/.rbenv/versions/1.9.3-p327/lib/ruby/gems/1.9.1/gems/amq-client-0.8.7/lib/amq/client/async/callbacks.rb:41:in `call'
from /Users/akima/.rbenv/versions/1.9.3-p327/lib/ruby/gems/1.9.1/gems/amq-client-0.8.7/lib/amq/client/async/callbacks.rb:41:in `block in exec_callback'
from /Users/akima/.rbenv/versions/1.9.3-p327/lib/ruby/gems/1.9.1/gems/amq-client-0.8.7/lib/amq/client/async/callbacks.rb:41:in `each'
from /Users/akima/.rbenv/versions/1.9.3-p327/lib/ruby/gems/1.9.1/gems/amq-client-0.8.7/lib/amq/client/async/callbacks.rb:41:in `exec_callback'
from /Users/akima/.rbenv/versions/1.9.3-p327/lib/ruby/gems/1.9.1/gems/amq-client-0.8.7/lib/amq/client/async/consumer.rb:202:in `handle_delivery'
from /Users/akima/.rbenv/versions/1.9.3-p327/lib/ruby/gems/1.9.1/gems/amq-client-0.8.7/lib/amq/client/async/consumer.rb:248:in `block in '
from /Users/akima/.rbenv/versions/1.9.3-p327/lib/ruby/gems/1.9.1/gems/amq-client-0.8.7/lib/amq/client/async/adapter.rb:539:in `call'
from /Users/akima/.rbenv/versions/1.9.3-p327/lib/ruby/gems/1.9.1/gems/amq-client-0.8.7/lib/amq/client/async/adapter.rb:539:in `receive_frameset'
from /Users/akima/.rbenv/versions/1.9.3-p327/lib/ruby/gems/1.9.1/gems/amq-client-0.8.7/lib/amq/client/async/adapter.rb:519:in `receive_frame'
from /Users/akima/.rbenv/versions/1.9.3-p327/lib/ruby/gems/1.9.1/gems/amq-client-0.8.7/lib/amq/client/async/adapters/event_machine.rb:327:in `receive_data'
from /Users/akima/.rbenv/versions/1.9.3-p327/lib/ruby/gems/1.9.1/gems/eventmachine-1.0.0/lib/eventmachine.rb:187:in `run_machine'
from /Users/akima/.rbenv/versions/1.9.3-p327/lib/ruby/gems/1.9.1/gems/eventmachine-1.0.0/lib/eventmachine.rb:187:in `run'
from /Users/akima/.rbenv/versions/1.9.3-p327/lib/ruby/gems/1.9.1/gems/tengine_core-1.1.0/lib/tengine/core/kernel.rb:116:in `activate'
from /Users/akima/.rbenv/versions/1.9.3-p327/lib/ruby/gems/1.9.1/gems/tengine_core-1.1.0/lib/tengine/core/method_traceable.rb:22:in `activate'
from /Users/akima/.rbenv/versions/1.9.3-p327/lib/ruby/gems/1.9.1/gems/tengine_core-1.1.0/lib/tengine/core/kernel.rb:38:in `start'
from /Users/akima/.rbenv/versions/1.9.3-p327/lib/ruby/gems/1.9.1/gems/tengine_core-1.1.0/lib/tengine/core/method_traceable.rb:22:in `start'
from /Users/akima/.rbenv/versions/1.9.3-p327/lib/ruby/gems/1.9.1/gems/tengine_core-1.1.0/lib/tengine/core/bootstrap.rb:57:in `block in start_kernel'
from /Users/akima/.rbenv/versions/1.9.3-p327/lib/ruby/gems/1.9.1/gems/tengine_core-1.1.0/lib/tengine/core/plugins.rb:22:in `notify'
from /Users/akima/.rbenv/versions/1.9.3-p327/lib/ruby/gems/1.9.1/gems/tengine_core-1.1.0/lib/tengine/core/bootstrap.rb:56:in `start_kernel'
from /Users/akima/.rbenv/versions/1.9.3-p327/lib/ruby/gems/1.9.1/gems/tengine_core-1.1.0/lib/tengine/core/method_traceable.rb:22:in `start_kernel'
from /Users/akima/.rbenv/versions/1.9.3-p327/lib/ruby/gems/1.9.1/gems/tengine_core-1.1.0/lib/tengine/core/bootstrap.rb:28:in `boot'
from /Users/akima/.rbenv/versions/1.9.3-p327/lib/ruby/gems/1.9.1/gems/tengine_core-1.1.0/lib/tengine/core/method_traceable.rb:22:in `boot'
from /Users/akima/.rbenv/versions/1.9.3-p327/lib/ruby/gems/1.9.1/gems/tengine_core-1.1.0/bin/tengined:181:in `block in '
from /Users/akima/.rbenv/versions/1.9.3-p327/lib/ruby/gems/1.9.1/gems/tengine_core-1.1.0/bin/tengined:103:in `chdir'
from /Users/akima/.rbenv/versions/1.9.3-p327/lib/ruby/gems/1.9.1/gems/tengine_core-1.1.0/bin/tengined:103:in `block (2 levels) in run_daemons'
from /Users/akima/.rbenv/versions/1.9.3-p327/lib/ruby/gems/1.9.1/gems/daemons-1.1.9/lib/daemons/application.rb:255:in `call'
from /Users/akima/.rbenv/versions/1.9.3-p327/lib/ruby/gems/1.9.1/gems/daemons-1.1.9/lib/daemons/application.rb:255:in `block in start_proc'
from /Users/akima/.rbenv/versions/1.9.3-p327/lib/ruby/gems/1.9.1/gems/daemons-1.1.9/lib/daemons/application.rb:264:in `call'
from /Users/akima/.rbenv/versions/1.9.3-p327/lib/ruby/gems/1.9.1/gems/daemons-1.1.9/lib/daemons/application.rb:264:in `start_proc'
from /Users/akima/.rbenv/versions/1.9.3-p327/lib/ruby/gems/1.9.1/gems/daemons-1.1.9/lib/daemons/application.rb:296:in `start'
from /Users/akima/.rbenv/versions/1.9.3-p327/lib/ruby/gems/1.9.1/gems/daemons-1.1.9/lib/daemons/controller.rb:70:in `run'
from /Users/akima/.rbenv/versions/1.9.3-p327/lib/ruby/gems/1.9.1/gems/daemons-1.1.9/lib/daemons.rb:197:in `block in run_proc'
from /Users/akima/.rbenv/versions/1.9.3-p327/lib/ruby/gems/1.9.1/gems/daemons-1.1.9/lib/daemons/cmdline.rb:109:in `call'
from /Users/akima/.rbenv/versions/1.9.3-p327/lib/ruby/gems/1.9.1/gems/daemons-1.1.9/lib/daemons/cmdline.rb:109:in `catch_exceptions'
from /Users/akima/.rbenv/versions/1.9.3-p327/lib/ruby/gems/1.9.1/gems/daemons-1.1.9/lib/daemons.rb:196:in `run_proc'
from /Users/akima/.rbenv/versions/1.9.3-p327/lib/ruby/gems/1.9.1/gems/tengine_core-1.1.0/bin/tengined:102:in `block in run_daemons'
from /Users/akima/.rbenv/versions/1.9.3-p327/lib/ruby/gems/1.9.1/gems/tengine_core-1.1.0/bin/tengined:34:in `verbose'
from /Users/akima/.rbenv/versions/1.9.3-p327/lib/ruby/gems/1.9.1/gems/tengine_core-1.1.0/bin/tengined:77:in `run_daemons'
from /Users/akima/.rbenv/versions/1.9.3-p327/lib/ruby/gems/1.9.1/gems/tengine_core-1.1.0/bin/tengined:135:in `block in run'
from /Users/akima/.rbenv/versions/1.9.3-p327/lib/ruby/gems/1.9.1/gems/tengine_core-1.1.0/bin/tengined:34:in `verbose'
from /Users/akima/.rbenv/versions/1.9.3-p327/lib/ruby/gems/1.9.1/gems/tengine_core-1.1.0/bin/tengined:125:in `run'
from /Users/akima/.rbenv/versions/1.9.3-p327/lib/ruby/gems/1.9.1/gems/tengine_core-1.1.0/bin/tengined:159:in `'
from /Users/akima/.rbenv/versions/1.9.3-p327/lib/ruby/gems/1.9.1/bin/tengined:23:in `load'
from /Users/akima/.rbenv/versions/1.9.3-p327/lib/ruby/gems/1.9.1/bin/tengined:23:in `

'
$
```