Recently I started to hit crashes when opening the Card Info screen of certain cards.
This is the error message:
A fatal error occurred, and Anki must close. Please report this message on the forums.
Anki 2.1.46 (94913ec2) Python 3.8.6 Qt 5.14.2 PyQt 5.14.2
Platform: Windows 10
Flags: frz=True ao=True sv=?
Add-ons, last update check: 2021-08-10 01:25:11
Caught exception:
Traceback (most recent call last):
File "aqt\browser\browser.py", line 515, in showCardInfo
File "aqt\browser\card_info.py", line 21, in __init__
File "anki\stats.py", line 36, in report
File "anki\collection.py", line 823, in card_stats
File "anki\_backend\generated.py", line 804, in card_stats
File "anki\_backend\__init__.py", line 126, in _run_command
pyo3_runtime.PanicException: SystemTimeToFileTime failed with: The parameter is incorrect. (os error 87)
Further search revealed that this is caused by the cards having unusually large IDs (specifically, the crash happens around this line).
If I’m not mistaken, card IDs are just creation timestamps in milliseconds, so I should not have cards with huge IDs such as 1488978224757674 (a date around the year 49153).
The issue only affects cards created in the last two months. I have about 3000 cards affected. A large portion of them are from a shared deck, the others are mostly imported from a text file, while just a couple of them are manually made.
I don’t think I have any add-ons that can be the cause, but I will look further.
Here is a CSV file with affected rows of the cards table: cards-with-large-ids.csv · GitHub
Also a deck package: cards-with-large-ids.apkg
Judging from the fact that Anki uses max(id) + 1
when an ID is already used and that most of the affected cards are imported, I guess it’s all started with one odd card that has a large ID for some reason, then the ID stuck around as the maximum and gradually infected more newly added cards.
I will probably have to do a surgery on my collection to fix the IDs and the revlog.