Mentioning a user gives ForeignKeyViolation

Infos:

  • Used Zammad version: 4.0
  • Used Zammad installation source: package (migrated from source)
  • Operating system: Ubuntu 18
  • Browser + version: Firefox 87

Expected behavior:

  • mentioning a user works as expected

Actual behavior:

Following shows up:

PG::ForeignKeyViolation: ERROR:  insert or update on table "histories" violates foreign key constraint "fk_rails_0e64d284d8"
DETAIL:  Key (history_object_id)=(6) is not present in table "history_objects".

history_objects looks like this:

----+-----------------+------+-------------------------+-------------------------
  1 | User            |      | 2019-08-16 20:28:35.758 | 2019-08-16 20:28:35.758
  2 | Group           |      | 2019-08-16 20:28:36.183 | 2019-08-16 20:28:36.183
  3 | Organization    |      | 2019-08-16 20:28:36.419 | 2019-08-16 20:28:36.419
  4 | Ticket          |      | 2019-08-16 20:28:36.8   | 2019-08-16 20:28:36.8
  5 | Ticket::Article |      | 2019-08-16 20:28:36.914 | 2019-08-16 20:28:36.914

I have already run zammad run rake db:migrate, and running it again gives no output. Here is output of db:migrate:status:

database: zammad

 Status   Migration ID    Migration Name
--------------------------------------------------
   up     20120101000001  Create base
   up     20120101000010  Create ticket
   up     20150979000001  Update timestamps
   up     20160217000001  Object manager update user
   up     20160921000001  Permission activerb
   up     20161101131409  Create doorkeeper tables
   up     20161112000001  Organization domain based assignment
   up     20161117000001  Job unable to create issue 432
   up     20161117000002  Ticket number generator issue 427
   up     20161117000003  Store config name update issue 428
   up     20161122000001  Monitoring issue 453
   up     20161228000001  Add taskbar meta
   up     20170113000001  Object manager attribute create middle
   up     20170113000002  Slack group config issue 587
   up     20170116000001  Add ticket time accounting 373
   up     20170116000002  Fixed typos 622
   up     20170117000001  Unable to enable time accounting 633
   up     20170119000001  Login email length 650
   up     20170123000001  Ui ticket zoom article new internal
   up     20170123000002  Fixed translation
   up     20170126091128  Application secret setting
   up     20170130000001  Follow up possible check 643
   up     20170203000001  Remove last login from history 722
   up     20170203000003  Do not import onw notifications 731
   up     20170207081400  Ticket state priority defaults
   up     20170214000001  Reload online browser after cors csrf changes
   up     20170215000001  Telegram support
   up     20170314000001  Fixed translation2
   up     20170403000001  Fixed admin user permission 920
   up     20170418000001  Validate agent limit
   up     20170419000001  Ldap support
   up     20170419000002  Overview role ids
   up     20170420000001  Chat increase message size
   up     20170421000001  Pretty date options added
   up     20170421110000  Add origin by
   up     20170426135500  Add reply to
   up     20170504144100  Follow up merged
   up     20170515000001  Scheduler status
   up     20170516000001  Trigger recipient update
   up     20170525000001  Reply to sender feature
   up     20170529000002  Setting delivery permanent failed
   up     20170529132120  Ldap multi group mapping
   up     20170531144425  Foreign keys
   up     20170608151442  Enhanced permissions
   up     20170619000001  Tree select
   up     20170626000001  Locale add direction
   up     20170628000001  Form group selection
   up     20170629000001  Exchange integration
   up     20170713000001  Omniauth office365 setting
   up     20170713000002  Ticket zoom setting2
   up     20170714000001  Object manager user email optional
   up     20170714000002  User email multiple use
   up     20170714000003  Cleanup cti log
   up     20170727000001  Setting proxy
   up     20170816000001  Idoit support
   up     20170822000001  Agend based sender issue 1351
   up     20170905140038  Cti log preferences migration
   up     20170910000002  Out of office2
   up     20170912123300  Remove network
   up     20170924054554  Weibo oauth2
   up     20170927000001  Setting send no auto response reg exp
   up     20171002091043  Change note char limit for users and organizations
   up     20171023000001  Fixed store upgrade ror 45
   up     20171024000001  Monit integration
   up     20171024000002  Check mk integration2
   up     20171102000001  Last owner update2
   up     20171123000001  Email process customer selection based on sender recipient
   up     20171203000001  Setting es pipeline
   up     20171206000001  Setting default locale2
   up     20171207000001  Permission user preferences out of office
   up     20171213000001  Change authorization token size
   up     20180108000001  Change exchange external sync identifier
   up     20180111000001  Ldap samaccountname to uid
   up     20180116000001  Setting ticket number ignore system id support
   up     20180128000001  Chat add ip country
   up     20180202000001  Sidebar customer open ticket colored
   up     20180202000002  Custom ldap login attribute
   up     20180220000001  Setting attachment preview
   up     20180220000002  Setting user organization selector with email
   up     20180220171219  Check for object attributes
   up     20180226085743  Issue 1660 fix tree select configurations
   up     20180306084119  Custom html email css font
   up     20180320000001  Setting table group by show count
   up     20180327170847  Issue 1905 exchange login from remote
   up     20180410000001  Cleanup user preferences notification sound2
   up     20180418000001  Setting third party link account at login
   up     20180426134922  Issue 1977 remove invalid user foreign keys
   up     20180502015927  Issue 1219 zhtw locale typo
   up     20180508182850  Ticket create types setting issue 1987
   up     20180518000001  Issue2029 sipgate integration enable
   up     20180518100316  Email forward prefix setting issue 1730
   up     20180521141004  Ticket last contact behavior
   up     20180524182518  Sms support
   up     20180529000001  Issue 2035 recursive ticket trigger
   up     20180604000001  Setting add ticket auto assignment2
   up     20180611070839  Add ux flow next up to macros
   up     20180622140531  Sequencer log level setting
   up     20180709020509  Add group direction to overviews
   up     20180711080554  Issue 2100 utf8 encode http logs
   up     20180716060129  Issue 2019 fix double domain links in trigger emails
   up     20180719033247  Add confidential to doorkeeper application
   up     20180806000001  Fixed twitter ticket article preferences7
   up     20180809000001  Cti generic api
   up     20180830000001  Setting delivery temporary failed
   up     20180911064647  Issue 2140 reset ldap config
   up     20180913000001  Setting add system bcc
   up     20180913000002  Permission add time accounting
   up     20180919000000  Setting update pretty date format
   up     20181010000000  Setting add sipgate alternative fqdn
   up     20181017000001  Cti generic api2
   up     20181023163804  Add stats backends
   up     20181030000001  Setting add placetel1
   up     20181102142526  Object manager attribute indexes
   up     20181108123847  Add country attribute to users
   up     20181120150357  Issue 2345 es attachment max size in mb setting lower default
   up     20181123000000  Issue 2368 add indices to histories and tickets
   up     20181203000000  Setting add email full quote header
   up     20190131000001  Setting change ticket zoom attachment preview
   up     20190208000001  Setting timezone default
   up     20190314084909  Object manager attribute date remove future past
   up     20190328000000  Rename locale on users
   up     20190405000001  Database indexes
   up     20190408000001  Issue 2541 fix notification email without body
   up     20190409000001  Setting ticket overview priority icon and color
   up     20190415000001  Setting es multi index
   up     20190418000000  Normalize setting ticket number ignore system
   up     20190419000001  Setting add import archive
   up     20190531180304  Initialize knowledge base
   up     20190613000001  Group dependent text modules
   up     20190626000001  Setting update karma level
   up     20190713000001  Group dependent macros
   up     20190715141227  Saml auth
   up     20190717210244  Issue 2641 kb color change limit
   up     20190718140450  Forget insecure sessions
   up     20190724000001  Rename reserved words
   up     20190806000001  Setting postmaster send reject email
   up     20190814000001  Object manager attribute ticket article body maxlength change
   up     20190903165443  Issue 2595 GitLab placeholder
   up     20190918114553  Issue 2867 footer header public link
   up     20191001090809  Create active job locks
   up     20191029101733  Issue 2608 missing trigger permission
   up     20191107050249  Issue 2460 fix corrupted twitter ids
   up     20191107181428  Issue 2715 fix broken twitter urls
   up     20191129102720  Active job lock cleanup job scheduler
   up     20200121000001  SMIME support
   up     20200205000001  Chat add allow website
   up     20200401000001  Service now config
   up     20200413160113  Issue 2990 delete timeframe
   up     20200419204445  Setting websocket backend
   up     20200507095900  Imap authentication migration cleanup job scheduler
   up     20200522125253  Issue 2943 add setting enforce special character
   up     20200527000000  Agent customer
   up     20200615150955  Issue 3085 doorkeeper scopes
   up     20200617153806  Issue 3087 search taskbar deadlock
   up     20200707000001  Data privacy init
   up     20200709091905  Maintenance checkmk wordings on settings
   up     20200709094556  Issue 3110 service now provider
   up     20200716124141  Issue 3123 external sync ticket merge
   up     20200724130426  Issue3128 add sso
   up     20200806122951  Cti user profile
   up     20200911070327  Data privacy delete name
   up     20200923092140  Issue3195 inconsistent granular agent permissions chat
   up     20201002094932  Datetime precision
   up     20201005084847  Agent customer permission
   up     20201006131231  Stats store polymorphic association
   up     20201013095141  Elastic search lower65 obsolete
   up     20201027152258  Add missing permissions
   up     20201028095957  Issue 3215 rename existing office365
   up     20201110000001  Mention init
   up     20201111133905  Maintenance associations cleanup
   up     20201112000000  Role signup column fix
   up     20201118140850  Issue 2671 pending till can be changed by customer
   up     20201201000001  Setting add sender format agent name
   up     20201202080338  Issue3270 selector update
   up     20201210075534  Maintenance missing kb unique indexes
   up     20210106100013  Issue 3346 xoauth2 token not fetched
   up     20210113000001  GitLab support
   up     20210118095820  Issue 3372 webhooks admin view
   up     20210215000001  Setting es total max size in mb
   up     20210308000001  GitHub support
   up     20210310090351  Activerecord session store114
   up     20210311130946  Remove unfixable generic oauth2 login

Steps to reproduce the behavior:

  • Mention a user

Subscribing to a ticket also fails, with the same error

Turns out this was fixed on it’s own after 2 days (probably sooner, but noticed it after 2 days)

The Mention row was added on 2021-04-04 22:15:11.25. No agent or admin was on Zammad at that time, so it must’ve been an automated task

This topic was automatically closed 120 days after the last reply. New replies are no longer allowed.