Hello!
I just noticed that data in many of my temporal / system-versioned tables seems to have got somehow corrupted. I believe it happend after that the server ran out of free disk space last week.
There are now multiple records in many of my system versioned tables, where in the connected history tables there are records with the same primary key values AND system start time values (!), but whereas the system end time values in the system versioned tables are at infinity (max datetime) the system end time values of the most recent record with the same primary key value in the connected history table is the recent date when the database was recovered from the full disk incident. The consequence is that queries like "SELECT * FROM myTemporalTable FOR SYSTEM_TIME AS OF <time before incident> WHERE ID = <ID>" in many cases return two records instead of just one! Only a fraction of all records in these tables are affected.
For background, when the database was recovered from the disk space issue, the database was shrinked, and before that, it was (as far as I can remember) likely also detached for a brief amount of time. I dont think any other maintenance operations were performed on the database. I have run various DBCC CHECK* commands to see if there are more serious issues, but no errors were reported by any of these commands.
Would be grateful for any ideas as to why the history tables have got corrupted like this?
PS. My plan is to fix the problem by identifying the affected records, then to disable system versioning on the tables in order to remove the overlapping records from the history table. Interestingly, and maybe helpful for understanding what may have caused the issue, is that any affected record has the same value of its ROWVERSION field in both the system versioned table and the connected history table.
Thanks.