Rare server crash after internal indexing exception with foreign key error on File entity
Sometimes, seemingly arbitrary, the server seems to get itself in such a state that it tries to add entities with foreign keys to other entities that seem to have been already removed (or weren't correctly readded).
I haven't been able to pin down when this happens exactly, as it doesn't happen often.
The error message looks like this:
Could not index file due to an internal exception. This likely means an exception should be caught at a deeper level (if it is acceptable) or there is a bug. The file is "file:///path/to/file.php" and the exact exception message: "An exception occurred while executing 'INSERT INTO FileNamespace (name, id, range_start_line, range_start_character, range_end_line, range_end_character, file_id) VALUES (?, ?, ?, ?, ?, ?, ?)' with params [null, "5d6f64c72553c9.96720947", 0, 0, 2, 0, "5d6cd95d51a703.28343136"]: SQLSTATE[23000]: Integrity constraint violation: 19 FOREIGN KEY constraint failed"
It looks like the File entity has somehow been pruned at this point, or not added yet. This was a file that was indexed before and not a new file.
When this happened, the following requests were sent (all for this file):
- didChange
- codeLens
- documentHighlight
I'm not sure if this is part of the problem or not. The server handles requests synchronously, in any case, so it should not be encountering any sorts of race conditions here.