znuny / Znuny

Znuny/Znuny LTS is a fork of the ((OTRS)) Community Edition, one of the most flexible web-based ticketing systems used for Customer Service, Help Desk, IT Service Management.
https://www.znuny.org
GNU General Public License v3.0
332 stars 82 forks source link

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

Open lukasdebaum opened 5 months ago

lukasdebaum commented 5 months ago

Environment

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

rkaldung commented 3 months ago

Internal issue 839