Znuny icon indicating copy to clipboard operation
Znuny copied to clipboard

Bug - duplicate inserts to the ticket_flag table with the MentionSeen key

Open lukasdebaum opened this issue 1 year ago • 1 comments

Environment

  • Server OS: Ubuntu 22.04.3
  • Browser: Chrome, Firefox
  • Znuny version: 6.5.5

Expected behavior

No duplicate inserts to the ticket_flag table.

Actual behavior

It looks like znuny performs the insert of the ticket_flag key "MentionSeen" twice when viewing a ticket for the first time under certain conditions. This has to happen within a very short time because the entry in the DB and the duplicate entry error message usually appear in the same second or at most with a difference of one second.

ticket_id, ticket_key, ticket_value, create_time, create_by ticket_flag-ticket_flag_per_user

[Kernel::System::Ticket::TicketFlagSet][7053] Duplicate entry '129174-MentionSeen-11' for key 'ticket_flag.ticket_flag_per_user', SQL: '
            INSERT INTO ticket_flag
            (ticket_id, ticket_key, ticket_value, create_time, create_by)
            VALUES (?, ?, ?, '2024-01-10 16:25:59', ?)'

How to reproduce

When a new ticket is viewed for the first time. But it looks like the problem is caused by a race condition, it only occurs by a few tickets.

Additional information

[Wed Jan 10 16:26:00 2024] -e: DBD::mysql::db do failed: Duplicate entry '129174-MentionSeen-11' for key 'ticket_flag.ticket_flag_per_user' at /opt/otrs/Kernel/System/DB.pm line 497.
ERROR: OTRS-CGI-10 Perl: 5.34.0 OS: linux Time: Wed Jan 10 16:26:00 2024

 Message: Duplicate entry '129174-MentionSeen-11' for key 'ticket_flag.ticket_flag_per_user', SQL: '
            INSERT INTO ticket_flag
            (ticket_id, ticket_key, ticket_value, create_time, create_by)
            VALUES (?, ?, ?, '2024-01-10 16:25:59', ?)'

 RemoteAddress: xx.xx.xx.xx
 RequestURI: /otrs/index.pl?Action=AgentTicketZoom;TicketID=129174

 Traceback (13566): 
   Module: Kernel::System::Ticket::TicketFlagSet Line: 7053
   Module: Kernel::Modules::AgentTicketZoom::Run Line: 278
   Module: Kernel::System::Web::InterfaceAgent::Run Line: 1144
   Module: ModPerl::ROOT::ModPerl::Registry::opt_otrs_bin_cgi_2dbin_index_2epl::handler Line: 39
   Module: (eval) (v1.99) Line: 207
   Module: ModPerl::RegistryCooker::run (v1.99) Line: 207
   Module: ModPerl::RegistryCooker::default_handler (v1.99) Line: 173
   Module: ModPerl::Registry::handler (v1.99) Line: 32

Screenshots

lukasdebaum avatar Jan 12 '24 21:01 lukasdebaum

Internal issue 839

rkaldung avatar Mar 14 '24 06:03 rkaldung

Fixed https://github.com/znuny/Znuny/commit/ff5a311b7b5c38ae33d0757adac9d1c7ceba6679 https://github.com/znuny/Znuny/releases/tag/rel-7_1_3

dennykorsukewitz avatar Oct 02 '24 08:10 dennykorsukewitz