mosquito-cr / mosquito

A background task runner for crystal applications supporting periodic (CRON) and manually queued jobs
MIT License
227 stars 24 forks source link

Expected a parameter named courier but found nil instead. #16

Closed Blacksmoke16 closed 6 years ago

Blacksmoke16 commented 6 years ago

mosquito.cr

require "redis"
require "./EveToolsApi/tasks/**"
require "./EveToolsApi/models/**"

Clear.logger.level = ::Logger::DEBUG
include EveToolsApi::Models
include EveToolsApi::Helpers

courier = Courier.query.first!

pp courier
pp typeof(courier)

EveToolsApi::Tasks::SendMail.new(courier).enqueue

Mosquito::Runner.start

send_mail.cr

require "mosquito"
require "../models/courier"

module EveToolsApi::Tasks
  class SendMail < Mosquito::QueuedJob
    params(courier : EveToolsApi::Models::Courier | Nil)

    def perform
      pp courier
    end
  end
end

output

mosquito    | #<EveToolsApi::Models::Courier:0x230edd0
mosquito    |  @acceptor_id_column=262543627,
mosquito    |  @attributes={},
mosquito    |  @cache=
mosquito    |   #<Clear::Model::QueryCache:0x22fa620 @cache={}, @cache_activation=Set{}>,
mosquito    |  @collateral_column=0.0,
mosquito    |  @contract_id_column=135484934,
mosquito    |  @date_accepted_column=2018-08-11 13:28:39.0 +00:00,
mosquito    |  @date_completed_column=2018-08-11 15:30:42.0 +00:00,
mosquito    |  @date_expired_column=2018-08-24 00:24:21.0 +00:00,
mosquito    |  @date_issued_column=2018-08-10 00:24:21.0 +00:00,
mosquito    |  @days_to_complete_column=14,
mosquito    |  @end_location_id_column=1022568876022_i64,
mosquito    |  @errors=[],
mosquito    |  @errors_column=[],
mosquito    |  @is_correct_column=true,
mosquito    |  @issuer_alliance_id_column=1555742183,
mosquito    |  @issuer_corporation_id_column=98173218,
mosquito    |  @issuer_id_column=1894412054,
mosquito    |  @mail_sent_column=nil,
mosquito    |  @persisted=true,
mosquito    |  @reward_column=66000000.0,
mosquito    |  @start_location_id_column=60003760_i64,
mosquito    |  @status_column="finished",
mosquito    |  @title_column="",
mosquito    |  @volume_column=94130.0703125>
mosquito    | EveToolsApi::Models::Courier
mosquito    | I, [2018-09-09 22:34:12 +00:00 #923]  INFO -- : Mosquito is buzzing...
mosquito    | I, [2018-09-09 22:34:12 +00:00 #923]  INFO -- : Found 1 delayed tasks
mosquito    | I, [2018-09-09 22:34:12 +00:00 #923]  INFO -- : Running task eve_tools_api::tasks::send_mail<mosquito:task:1536532452450:830> from eve_tools_api::tasks::send_mail
mosquito    | I, [2018-09-09 22:34:12 +00:00 #923]  INFO -- : [EveToolsApi::Tasks::SendMail-mosquito:task:1536532452450:830] Job failed! Raised Exception: Expected a parameter named courier but found nil instead. The record may not exist in the database or the parameter may not have been provided when the job was enqueued.
api2        | [production] Kemal is ready to lead at http://0.0.0.0:6000
mosquito    | I, [2018-09-09 22:34:12 +00:00 #923]  INFO -- : [EveToolsApi::Tasks::SendMail-mosquito:task:1536532452450:830] src/EveToolsApi/tasks/send_mail.cr:6:5 in 'courier'
mosquito    | I, [2018-09-09 22:34:12 +00:00 #923]  INFO -- : [EveToolsApi::Tasks::SendMail-mosquito:task:1536532452450:830] src/EveToolsApi/tasks/send_mail.cr:9:7 in 'perform'
mosquito    | I, [2018-09-09 22:34:12 +00:00 #923]  INFO -- : [EveToolsApi::Tasks::SendMail-mosquito:task:1536532452450:830] lib/mosquito/src/mosquito/job.cr:35:7 in 'run'
mosquito    | I, [2018-09-09 22:34:12 +00:00 #923]  INFO -- : [EveToolsApi::Tasks::SendMail-mosquito:task:1536532452450:830] lib/mosquito/src/mosquito/task.cr:73:10 in 'run'
mosquito    | I, [2018-09-09 22:34:12 +00:00 #923]  INFO -- : [EveToolsApi::Tasks::SendMail-mosquito:task:1536532452450:830] lib/mosquito/src/mosquito/runner.cr:122:14 in 'run_next_task'
mosquito    | I, [2018-09-09 22:34:12 +00:00 #923]  INFO -- : [EveToolsApi::Tasks::SendMail-mosquito:task:1536532452450:830] lib/mosquito/src/mosquito/runner.cr:86:9 in 'dequeue_and_run_tasks'
mosquito    | I, [2018-09-09 22:34:12 +00:00 #923]  INFO -- : [EveToolsApi::Tasks::SendMail-mosquito:task:1536532452450:830] lib/mosquito/src/mosquito/runner.cr:30:9 in 'run'
mosquito    | I, [2018-09-09 22:34:12 +00:00 #923]  INFO -- : [EveToolsApi::Tasks::SendMail-mosquito:task:1536532452450:830] lib/mosquito/src/mosquito/runner.cr:10:7 in 'start'
mosquito    | I, [2018-09-09 22:34:12 +00:00 #923]  INFO -- : [EveToolsApi::Tasks::SendMail-mosquito:task:1536532452450:830] src/mosquito.cr:0:1 in '__crystal_main'
mosquito    | I, [2018-09-09 22:34:12 +00:00 #923]  INFO -- : [EveToolsApi::Tasks::SendMail-mosquito:task:1536532452450:830] /usr/share/crystal/src/crystal/main.cr:97:5 in 'main_user_code'
mosquito    | I, [2018-09-09 22:34:12 +00:00 #923]  INFO -- : [EveToolsApi::Tasks::SendMail-mosquito:task:1536532452450:830] /usr/share/crystal/src/crystal/main.cr:86:7 in 'main'
mosquito    | I, [2018-09-09 22:34:12 +00:00 #923]  INFO -- : [EveToolsApi::Tasks::SendMail-mosquito:task:1536532452450:830] /usr/share/crystal/src/crystal/main.cr:106:3 in 'main'
mosquito    | I, [2018-09-09 22:34:12 +00:00 #923]  INFO -- : [EveToolsApi::Tasks::SendMail-mosquito:task:1536532452450:830] __libc_start_main
mosquito    | I, [2018-09-09 22:34:12 +00:00 #923]  INFO -- : [EveToolsApi::Tasks::SendMail-mosquito:task:1536532452450:830] _start
mosquito    | I, [2018-09-09 22:34:12 +00:00 #923]  INFO -- : [EveToolsApi::Tasks::SendMail-mosquito:task:1536532452450:830] ???
mosquito    | I, [2018-09-09 22:34:12 +00:00 #923]  INFO -- : Failure: task eve_tools_api::tasks::send_mail<mosquito:task:1536532452450:830> failed, taking 0.23s and will run again in 00:00:02 (at 2018-09-09 22:34:14 +00:00)
mosquito    | I, [2018-09-09 22:34:12 +00:00 #923]  INFO -- : Running task eve_tools_api::tasks::send_mail<mosquito:task:1536532438737:795> from eve_tools_api::tasks::send_mail
robacarp commented 6 years ago

@blacksmoke16 Two questions, what is a Courier? I assume it’s a Granite model. Second, what is in your redis at that task id?

My hunch is that there is a corrupted task stored there, which might be an edge case that mosquito doesn’t know how to handle.