It seems there are duplicate rows in the database table where every
column has the same value except id.

What table? If this somehow comes from recentchanges, remember that wikidata inserts fake rows. Any and all queries against RC must filter rc_type != 5.
https://bugzilla.wikimedia.org/show_bug.cgi?id=43581

That's a good point but no, this is an EventLogging table.  So the issue is new as far as we know.