Unprocessable mail > PG::InFailedSqlTransaction error

Infos:

  • Used Zammad version: 5.3.1
  • Used Zammad installation type: package
  • Operating system: Debian 11

I am getting a few unprocessable emails but when I open the rails console and do a Channel::EmailParser.process_unprocessable_mails, the mails are processed without any issues.

Does anyone have an idae what I can do to find the cause of this error?

Here is the output from the production log:

I, [2023-04-25T12:22:56.703503 #20030-72999880]  INFO -- : execute Channel.fetch (try_count 0)...
I, [2023-04-25T12:22:56.705120 #20030-72999880]  INFO -- : fetching imap (w0xxxxxx.kasserver.com/m01xxxxx port=993,ssl=true,starttls=false,folder=INBOX,keep_on_server=true,auth_type=LOGIN)
I, [2023-04-25T12:22:56.912439 #20030-72999880]  INFO -- :  - no message
I, [2023-04-25T12:22:56.921291 #20030-72999880]  INFO -- : fetching imap (w0xxxxxx.kasserver.com/m02xxxxx port=993,ssl=true,starttls=false,folder=INBOX,keep_on_server=true,auth_type=LOGIN)
I, [2023-04-25T12:22:57.114944 #20030-72999880]  INFO -- :  - message 1/1
I, [2023-04-25T12:22:58.128123 #20030-72999880]  INFO -- : Process email with msgid '<2xxxxxxxxxxxxxxxx.xxxxxxxxxxxxxxxx1@kaufland-marketplace.com>'
I, [2023-04-25T12:22:58.156602 #20030-72999880]  INFO -- : set_attributes_by_x_headers header x-zammad-ticket-customer_id found. Assign customer_id=8
E, [2023-04-25T12:22:58.163680 #20030-72999880] ERROR -- : Can't process email, you will find it for bug reporting under /opt/zammad/tmp/unprocessable_mail/03xxxxxxxxxxxxxxxxxxxxxxxxx.eml, please create an issue at https://github.com/zammad/zammad/issues
E, [2023-04-25T12:22:58.163736 #20030-72999880] ERROR -- : PG::InFailedSqlTransaction: ERROR:  current transaction is aborted, commands ignored until end of transaction block
 (ActiveRecord::StatementInvalid)
lib/transaction_dispatcher.rb:33:in `perform'
lib/transaction_dispatcher.rb:17:in `commit'
app/models/transaction.rb:51:in `finish_transaction'
app/models/transaction.rb:19:in `ensure in block in execute'
app/models/transaction.rb:19:in `block in execute'
app/models/transaction.rb:14:in `execute'
app/models/transaction.rb:26:in `execute'
app/models/channel/email_parser.rb:184:in `_process'
app/models/channel/email_parser.rb:123:in `block in process'
app/models/channel/email_parser.rb:122:in `process'
app/models/channel/driver/imap.rb:318:in `block in fetch'
app/models/channel/driver/imap.rb:255:in `each'
app/models/channel/driver/imap.rb:255:in `fetch'
app/models/channel.rb:56:in `fetch'
app/models/channel.rb:30:in `fetch'
(eval):1:in `eval_job_method'
lib/background_services/service/process_scheduled_jobs/job_executor.rb:48:in `eval'
lib/background_services/service/process_scheduled_jobs/job_executor.rb:48:in `eval_job_method'
lib/background_services/service/process_scheduled_jobs/job_executor.rb:23:in `execute'
lib/background_services/service/process_scheduled_jobs/job_executor/continuous.rb:16:in `block in run_loop'
lib/background_services/service/process_scheduled_jobs/job_executor/continuous.rb:15:in `times'
lib/background_services/service/process_scheduled_jobs/job_executor/continuous.rb:15:in `run_loop'
lib/background_services/service/process_scheduled_jobs/job_executor/continuous.rb:8:in `run'
lib/background_services/service/process_scheduled_jobs/job_executor.rb:10:in `run'
lib/background_services/service/process_scheduled_jobs/manager.rb:84:in `block in start_in_thread'
lib/application_handle_info.rb:19:in `use'
lib/background_services/service/process_scheduled_jobs/manager.rb:82:in `start_in_thread'
lib/background_services/service/process_scheduled_jobs/manager.rb:73:in `block (2 levels) in start'
lib/background_services/service/process_scheduled_jobs/manager.rb:72:in `block in start'
I, [2023-04-25T12:22:58.215484 #20030-72999880]  INFO -- : ended Channel.fetch took: 1.516626794 seconds.
I, [2023-04-25T12:23:03.092655 #20030-112100]  INFO -- : ProcessScheduledJobs running...

This is what I get in the rails console:

irb(main):001:0> Channel::EmailParser.process_unprocessable_mails
Process email with msgid '<2xxxxxxxxxxxxxxxx.xxxxxxxxxxxxxxxx1@kaufland-marketplace.com>'
set_attributes_by_x_headers header x-zammad-ticket-customer_id found. Assign customer_id=8
set_attributes_by_x_headers header x-zammad-article-preferences found. Assign preferences={"send-auto-response"=>true, "is-auto-response"=>false}
=> ["/opt/zammad/tmp/unprocessable_mail/03xxxxxxxxxxxxxxxxxxxxxxxxx.eml"]
irb(main):002:0> 

Any help is much appreciated.

Thanks,
Gijs

For some reason, it appears the SQL statement (transaction) to update the database was aborted. Check your PostgreSQL logs for more information regarding this error and post that here.

The aborted SQL statement is likely not caused by the email or its contents itself, as this appears to be a transient error, because you state that the unprocessable emails are processed fine when re-processing them. For now, Iā€™m guessing it might have something to do with the load on your platform and its tuning.

1 Like