#2768·Tautulli

Regroup play history can merge unrelated non-live items when legacy rating_key collisions exist

Author: vefilippoCreated Aug 2, 2026Updated Sep 17, 2026
Labelstype:bugpriority:mediumtopic:history

Bug description

Regroup play history can merge unrelated non-live items on long-lived databases where historical rating_key collisions exist.

What I observed

Observed on August 2, 2026 on a long-running Tautulli instance that has survived multiple Plex/library migrations over the years.

After resetting reference_id values to repair a visibly broken group, running Regroup play history recreated the incorrect merge.

Verified example from the database:

  • row 2381: Modern Family - Wine Weekend
  • row 9704: NCIS: Origins - Operazione Tramonto
  • both rows stored with rating_key = 8908
  • the rows have different guid values
  • regroup merged them again because it grouped by user_id + rating_key

Source analysis

In plexpy/activity_processor.py:

  • regroup_history() iterates all history rows and calls group_history()
  • for non-live media, group_history() selects the previous rows using user_id and rating_key
  • it then reuses the previous row's reference_id
  • it does not validate that non-live rows also share the same guid

That means a historical rating_key collision can recreate an invalid group even after reference_id is repaired.

Why I think this matters

This seems especially likely on old databases that span years of Plex migrations, metadata changes, or library rebuilds.

In my backup DB, I found:

  • 475 rating_key values attached to multiple different titles
  • 517 rating_key values attached to multiple different guid values
  • 1909 rows involved in those multi-guid collisions

Expected behavior

Regroup play history should not merge non-live rows unless they identify the same underlying item.

Suggested fix

Require matching guid for non-live regrouping before reusing a previous reference_id.

I also prepared a branch with a candidate fix:

  • vefilippo/Tautulli branch codex/fix-history-regroup-guid