Zammad: Too large article body fails OTRS import

Created on 1 Jul 2018  ·  9Comments  ·  Source: zammad/zammad

Hello,

in addition to https://github.com/zammad/zammad/issues/1467 I still not give up importing OTRS data.
(I think the older ticket can be closed)

Task:

With zammad 2.5 tried to import OTRS data (~6000 tickets.

Result:

Try 1:
Import via WebGUI was not successful, import process stopped after some time. Is it possible that there is something like a timeout ?

Try 2:
Import via console was better, but import failed at a ticket with a huge body (I assume this is an attachemend) with the following error (please see exception below). Executed the following commands:

bundle exec rails c

Setting.set('import_otrs_endpoint', 'http://123.456.789.012/otrs/public.pl?Action=ZammadMigrator')
Setting.set('import_otrs_endpoint_key', 'IhAvEaVeRySeCrEtKeY')
Setting.set('import_mode', true)
Setting.set('system_init_done', false)
Import::OTRS.start

Questions:

  • Can I simply raise the body limit in the source for the time of the import process or will I get problems afterwards when accessing the ticket ?
  • Or Is it possible to resume importing the remaining tickets
  • I am using your docker-compose version of zammad. In the import docs you write "Stop all Zammad processes". Which processes/containers should I stop (espacially when using the docker version)

Best regards
MrDigit

Trace fo exception:

W, [2018-07-01T12:58:20.356829 #76]  WARN -- : zammad-memcached:11211 failed (count: 0) RuntimeError: Already writing to socket
/opt/zammad/app/models/ticket/article.rb:301:in `check_body': body if article is to large, 3702347 chars - only 1500000 allowed (Exceptions::UnprocessableEntity)
        from /usr/local/bundle/gems/activesupport-5.1.5/lib/active_support/callbacks.rb:413:in `block in make_lambda'
        from /usr/local/bundle/gems/activesupport-5.1.5/lib/active_support/callbacks.rb:197:in `block (2 levels) in halting'
        from /usr/local/bundle/gems/activesupport-5.1.5/lib/active_support/callbacks.rb:601:in `block (2 levels) in default_terminator'
        from /usr/local/bundle/gems/activesupport-5.1.5/lib/active_support/callbacks.rb:600:in `catch'
        from /usr/local/bundle/gems/activesupport-5.1.5/lib/active_support/callbacks.rb:600:in `block in default_terminator'
        from /usr/local/bundle/gems/activesupport-5.1.5/lib/active_support/callbacks.rb:198:in `block in halting'
        from /usr/local/bundle/gems/activesupport-5.1.5/lib/active_support/callbacks.rb:507:in `block in invoke_before'
        from /usr/local/bundle/gems/activesupport-5.1.5/lib/active_support/callbacks.rb:507:in `each'
        from /usr/local/bundle/gems/activesupport-5.1.5/lib/active_support/callbacks.rb:507:in `invoke_before'
        from /usr/local/bundle/gems/activesupport-5.1.5/lib/active_support/callbacks.rb:130:in `run_callbacks'
        from /usr/local/bundle/gems/activesupport-5.1.5/lib/active_support/callbacks.rb:827:in `_run_create_callbacks'
        from /usr/local/bundle/gems/activerecord-5.1.5/lib/active_record/callbacks.rb:340:in `_create_record'
        from /usr/local/bundle/gems/activerecord-5.1.5/lib/active_record/timestamp.rb:95:in `_create_record'
        from /usr/local/bundle/gems/activerecord-5.1.5/lib/active_record/persistence.rb:559:in `create_or_update'
        from /usr/local/bundle/gems/activerecord-5.1.5/lib/active_record/callbacks.rb:336:in `block in create_or_update'
        from /usr/local/bundle/gems/activesupport-5.1.5/lib/active_support/callbacks.rb:131:in `run_callbacks'
        from /usr/local/bundle/gems/activesupport-5.1.5/lib/active_support/callbacks.rb:827:in `_run_save_callbacks'
        from /usr/local/bundle/gems/activerecord-5.1.5/lib/active_record/callbacks.rb:336:in `create_or_update'
        from /usr/local/bundle/gems/activerecord-5.1.5/lib/active_record/persistence.rb:129:in `save'
        from /usr/local/bundle/gems/activerecord-5.1.5/lib/active_record/validations.rb:44:in `save'
        from /usr/local/bundle/gems/activerecord-5.1.5/lib/active_record/attribute_methods/dirty.rb:35:in `save'
        from /usr/local/bundle/gems/activerecord-5.1.5/lib/active_record/transactions.rb:308:in `block (2 levels) in save'
        from /usr/local/bundle/gems/activerecord-5.1.5/lib/active_record/transactions.rb:384:in `block in with_transaction_returning_status'
        from /usr/local/bundle/gems/activerecord-5.1.5/lib/active_record/connection_adapters/abstract/database_statements.rb:235:in `block in transaction'
        from /usr/local/bundle/gems/activerecord-5.1.5/lib/active_record/connection_adapters/abstract/transaction.rb:194:in `block in within_new_transaction'
        from /usr/local/lib/ruby/2.4.0/monitor.rb:214:in `mon_synchronize'
        from /usr/local/bundle/gems/activerecord-5.1.5/lib/active_record/connection_adapters/abstract/transaction.rb:191:in `within_new_transaction'
        from /usr/local/bundle/gems/activerecord-5.1.5/lib/active_record/connection_adapters/abstract/database_statements.rb:235:in `transaction'
        from /usr/local/bundle/gems/activerecord-5.1.5/lib/active_record/transactions.rb:210:in `transaction'
        from /usr/local/bundle/gems/activerecord-5.1.5/lib/active_record/transactions.rb:381:in `with_transaction_returning_status'
        from /usr/local/bundle/gems/activerecord-5.1.5/lib/active_record/transactions.rb:308:in `block in save'
        from /usr/local/bundle/gems/activerecord-5.1.5/lib/active_record/transactions.rb:323:in `rollback_active_record_state!'
        from /usr/local/bundle/gems/activerecord-5.1.5/lib/active_record/transactions.rb:307:in `save'
        from /usr/local/bundle/gems/activerecord-5.1.5/lib/active_record/suppressor.rb:42:in `save'
        from /opt/zammad/lib/import/otrs/article.rb:64:in `create'
        from /opt/zammad/lib/import/otrs/article.rb:49:in `create_or_update'
        from /opt/zammad/lib/import/otrs/article.rb:37:in `import'
        from /opt/zammad/lib/import/otrs/article.rb:31:in `initialize'
        from /opt/zammad/lib/import/base_factory.rb:35:in `new'
        from /opt/zammad/lib/import/base_factory.rb:35:in `create_instance'
        from /opt/zammad/lib/import/base_factory.rb:11:in `block in import_action'
        from /opt/zammad/lib/import/base_factory.rb:39:in `each'
        from /opt/zammad/lib/import/base_factory.rb:39:in `import_loop'
        from /opt/zammad/lib/import/base_factory.rb:9:in `import_action'
        from /opt/zammad/lib/import/otrs/ticket.rb:40:in `import'
        from /opt/zammad/lib/import/otrs/ticket.rb:30:in `initialize'
        from /opt/zammad/lib/import/base_factory.rb:35:in `new'
        from /opt/zammad/lib/import/base_factory.rb:35:in `create_instance'
        from /opt/zammad/lib/import/base_factory.rb:11:in `block in import_action'
        from /opt/zammad/lib/import/base_factory.rb:39:in `each'
        from /opt/zammad/lib/import/base_factory.rb:39:in `import_loop'
        from /opt/zammad/lib/import/base_factory.rb:9:in `import_action'
        from /opt/zammad/lib/import/otrs.rb:147:in `import_action'
        from /opt/zammad/lib/import/otrs.rb:137:in `imported?'
        from /opt/zammad/lib/import/otrs.rb:101:in `block (3 levels) in threaded_import'
        from /opt/zammad/lib/import/otrs.rb:95:in `loop'
        from /opt/zammad/lib/import/otrs.rb:95:in `block (2 levels) in threaded_import'
        from /usr/local/bundle/gems/logging-2.2.2/lib/logging/diagnostic_context.rb:474:in `block in create_with_logging_context'
bug import verified

All 9 comments

Hi @MrDigit , Which one DB to use? I think limited from DB, see this line in log:

/opt/zammad/app/models/ticket/article.rb:301:in check_body': body if article is to large, 3702347 chars - only 1500000 allowed (Exceptions::UnprocessableEntity) from /usr/local/bundle/gems/activesupport-5.1.5/lib/active_support/callbacks.rb:413:inblock in make_lambda'

Hello @NeverMin ,

as the limit is hardcoded into article.rb this error independent of the selected DB backend.
(limit = 1_500_000, see below)

def check_body
    return true if body.blank?
    limit = 1_500_000
    current_length = body.length
    return true if body.length <= limit

    raise Exceptions::UnprocessableEntity, "body if article is to large, #{current_length} chars - only #{limit} allowed" if !ApplicationHandleInfo.postmaster?

    logger.warn "WARNING: cut string because of database length #{self.class}.body(#{limit} but is #{current_length})"
    self.body = body[0, limit]
end

Hello @MrDigit , Yes, you can fix(e.g. 4_000_000) and try, but, which one DB to use for Zammad ? MySQL or postgresql? What is OTRS version?

Hello @NeverMin ,

already raised the limit to some higher value, import worked afterwards. Question is why is the limit set to 1,5 MByte ? Because zammad will explode if larger bodies are stored or is this simply a arbitrary value ?

Regarding your questions: The docker-compose version of zammad I am using ( https://github.com/zammad/zammad-docker-compose ) is using postgresql, I am storing the attachments in the filesystem. OTRS is version 5.

Hello @MrDigit , Good questions, maybe let me ask to @thorsteneckel .

JFI: https://github.com/zammad/zammad/blob/develop/db/migrate/20120101000010_create_ticket.rb#L175

EDITED:
Can you move this issue to Community?

Hi @MrDigit

Question is why is the limit set to 1,5 MByte ?

I think this value is of yore and probably obsolete. Thanks for digging that deep, resolving your issue and sharing it here. We will have a closer look when addressing this issue.

This is not limited to OTRS import only.
This will strike at several points.

When trying to reproduce this, even with 15000 characters, I'll keep receiving errors (note: I had to switch to API here because our UI didn't like it):

F, [2019-07-03T16:36:15.330582 #18433-86302140] FATAL -- :
F, [2019-07-03T16:36:15.330620 #18433-86302140] FATAL -- : actionpack (5.1.7) lib/action_dispatch/http/parameters.rb:115:in `rescue in parse_formatted_parameters'
actionpack (5.1.7) lib/action_dispatch/http/parameters.rb:109:in `parse_formatted_parameters'
actionpack (5.1.7) lib/action_dispatch/http/request.rb:361:in `block in POST'
rack (2.0.7) lib/rack/request.rb:59:in `fetch'
rack (2.0.7) lib/rack/request.rb:59:in `fetch_header'
actionpack (5.1.7) lib/action_dispatch/http/request.rb:360:in `POST'
actionpack (5.1.7) lib/action_dispatch/http/parameters.rb:53:in `parameters'
actionpack (5.1.7) lib/action_dispatch/http/filter_parameters.rb:41:in `filtered_parameters'
actionpack (5.1.7) lib/action_controller/metal/instrumentation.rb:21:in `process_action'
actionpack (5.1.7) lib/action_controller/metal/params_wrapper.rb:252:in `process_action'
activerecord (5.1.7) lib/active_record/railties/controller_runtime.rb:22:in `process_action'
actionpack (5.1.7) lib/abstract_controller/base.rb:124:in `process'
actionview (5.1.7) lib/action_view/rendering.rb:30:in `process'
actionpack (5.1.7) lib/action_controller/metal.rb:189:in `dispatch'
actionpack (5.1.7) lib/action_controller/metal.rb:253:in `dispatch'
actionpack (5.1.7) lib/action_dispatch/routing/route_set.rb:49:in `dispatch'
actionpack (5.1.7) lib/action_dispatch/routing/route_set.rb:31:in `serve'
actionpack (5.1.7) lib/action_dispatch/journey/router.rb:50:in `block in serve'
actionpack (5.1.7) lib/action_dispatch/journey/router.rb:33:in `each'
actionpack (5.1.7) lib/action_dispatch/journey/router.rb:33:in `serve'
actionpack (5.1.7) lib/action_dispatch/routing/route_set.rb:844:in `call'
omniauth (1.9.0) lib/omniauth/strategy.rb:192:in `call!'
omniauth (1.9.0) lib/omniauth/strategy.rb:169:in `call'
omniauth (1.9.0) lib/omniauth/strategy.rb:192:in `call!'
omniauth (1.9.0) lib/omniauth/strategy.rb:169:in `call'
omniauth (1.9.0) lib/omniauth/strategy.rb:192:in `call!'
omniauth (1.9.0) lib/omniauth/strategy.rb:169:in `call'
omniauth (1.9.0) lib/omniauth/strategy.rb:192:in `call!'
omniauth (1.9.0) lib/omniauth/strategy.rb:169:in `call'
omniauth (1.9.0) lib/omniauth/strategy.rb:192:in `call!'
omniauth (1.9.0) lib/omniauth/strategy.rb:169:in `call'
omniauth (1.9.0) lib/omniauth/strategy.rb:192:in `call!'
omniauth (1.9.0) lib/omniauth/strategy.rb:169:in `call'
omniauth (1.9.0) lib/omniauth/strategy.rb:192:in `call!'
omniauth (1.9.0) lib/omniauth/strategy.rb:169:in `call'
omniauth (1.9.0) lib/omniauth/strategy.rb:192:in `call!'
omniauth (1.9.0) lib/omniauth/strategy.rb:169:in `call'
omniauth (1.9.0) lib/omniauth/strategy.rb:192:in `call!'
omniauth (1.9.0) lib/omniauth/strategy.rb:169:in `call'
omniauth (1.9.0) lib/omniauth/builder.rb:64:in `call'
rack (2.0.7) lib/rack/etag.rb:25:in `call'
rack (2.0.7) lib/rack/conditional_get.rb:38:in `call'
rack (2.0.7) lib/rack/head.rb:12:in `call'
rack (2.0.7) lib/rack/session/abstract/id.rb:232:in `context'
rack (2.0.7) lib/rack/session/abstract/id.rb:226:in `call'
actionpack (5.1.7) lib/action_dispatch/middleware/cookies.rb:613:in `call'
actionpack (5.1.7) lib/action_dispatch/middleware/callbacks.rb:26:in `block in call'
activesupport (5.1.7) lib/active_support/callbacks.rb:97:in `run_callbacks'
actionpack (5.1.7) lib/action_dispatch/middleware/callbacks.rb:24:in `call'
actionpack (5.1.7) lib/action_dispatch/middleware/debug_exceptions.rb:59:in `call'
actionpack (5.1.7) lib/action_dispatch/middleware/show_exceptions.rb:31:in `call'
railties (5.1.7) lib/rails/rack/logger.rb:36:in `call_app'
railties (5.1.7) lib/rails/rack/logger.rb:24:in `block in call'
activesupport (5.1.7) lib/active_support/tagged_logging.rb:69:in `block in tagged'
activesupport (5.1.7) lib/active_support/tagged_logging.rb:26:in `tagged'
activesupport (5.1.7) lib/active_support/tagged_logging.rb:69:in `tagged'
railties (5.1.7) lib/rails/rack/logger.rb:24:in `call'
actionpack (5.1.7) lib/action_dispatch/middleware/remote_ip.rb:79:in `call'
actionpack (5.1.7) lib/action_dispatch/middleware/request_id.rb:25:in `call'
rack (2.0.7) lib/rack/method_override.rb:22:in `call'
rack (2.0.7) lib/rack/runtime.rb:22:in `call'
activesupport (5.1.7) lib/active_support/cache/strategy/local_cache_middleware.rb:27:in `call'
actionpack (5.1.7) lib/action_dispatch/middleware/executor.rb:12:in `call'
actionpack (5.1.7) lib/action_dispatch/middleware/static.rb:125:in `call'
rack (2.0.7) lib/rack/sendfile.rb:111:in `call'
railties (5.1.7) lib/rails/engine.rb:522:in `call'
railties (5.1.7) lib/rails/railtie.rb:185:in `public_send'
railties (5.1.7) lib/rails/railtie.rb:185:in `method_missing'
puma (3.12.1) lib/puma/configuration.rb:227:in `call'
puma (3.12.1) lib/puma/server.rb:660:in `handle_request'
puma (3.12.1) lib/puma/server.rb:474:in `process_client'
puma (3.12.1) lib/puma/server.rb:334:in `block in run'
puma (3.12.1) lib/puma/thread_pool.rb:135:in `block in spawn_thread'
logging (2.2.2) lib/logging/diagnostic_context.rb:474:in `block in create_with_logging_context'

API response is empty.

I could, at no point, push the API to the above limit, as Zammad wouldn't take my payloads.

I tried with 1500001 characters (which my Browser already didn't like too much) and after with less 15000 chracters (this value is pastable within Zammad). But again, if the article get's too big, it will just stop taking the pastes.

1500001 however is not 1.5MB, but rather about 1.14MB which isn't even the limit. I could paste about 494320 characters (plain-text!), afterwards manual typing still works. Bigger thanks where not successful.

I used this generator during my tries: https://www.loremipsum.de/index_e.html

Hi,
i blamed the limit and this issue is the reason for the limit:
https://github.com/zammad/zammad/issues/1390

From my side 1.5 MB is okay... Normally bigger contents are handled in attachments anyways where they are no problem.

I ran into the same issue. A customer had a failed otrs article import with a embedded docx which broke the article (1 of 35k tickets). No usable content, looked like the mailserver/client broke it while delivering.

I will change the exception to not occure on imports, so the articles will be imported by cutting it to 1.5 MB like in other cases. We also should fix the limit from 1.14MB -> 1.5MB. The import should run smooth and prevent raising exceptions.

We decided to keep the limit of 1.5 million chars per article. As @MrGeneration pointed out the UI isn't usable after (a much lower) amount of chars anyway. It was never about the actual size in terms of MB/KB but the number of chars. However, the original issue is now fixed and will be ready to use with Zammad 3.5 🚀

Was this page helpful?
0 / 5 - 0 ratings