Sometimes there are commit errors for clusters with a lot of hosts and enabled alert caching:
This is not often issue, but anyway it has extensive logging. Also this issue can cause other rare problems, so it should be fixed.
The reason of the issue is we have a shareable cache which can be updated with just merged value before this value will be really committed into DB. In this case other thread (from CachedAlertFlushService or AlertEventPublisher) can try to also merge already merged entity.
For example, we've created a new AlertHistoryEntity and set it to existing AlertCurrentEntity. A first thread started transaction, merged current entity to context, saved merged value to the cache and paused execution. After that a second thread tries to merge all content of cache and also merges just updated current entity. So we have two transaction and both think they should update current entity and create the new history entity. As result one of them is failing on duplicate error.