hived cannot remove obsolete events
When hived pushes MASSIVE_SYNC_EVENT or NEW_IRREVERSIBLE_EVENT then the obsolete tail od hive.events_queue is removed ( hive.remove_unecessary_events ) - the events with id lower than the lowest 'event id' of all contexts are removed. This can work with the assumption that contexts cannot back to lower events. But there is a case when a new context is created ( it got events id = NULL ) and hived is removing obsolete events. Because or READ COMMITED level of transaction isolation the new context moves to a first available event but hived transaction is not seeing this and is starting to removing the event which is being assigned to a new context what violates fk_hive_app_context FOREIGN KEY constraint