When an SQL query fails due to a storage engine error, it doesn't return an (expected) SQLSTATE error, e.g., 42S01. Instead, we get an internal errno, e.g.,
Mysqli statement execute error : Got error 28 from storage engine
where 28 is often defined in errno.h as ENOSPC, i.e., no disk space left on volume.
Can we catch errors like this and provide a more user-friendly error message to users (via php's posix_strerror() function, if available)?
Note: in the case of ENOSPC, this wouldn't necessarily be limited to INSERTs. SELECTs (e.g., JOINs) and disk-based temporary tables could also be the trigger.
Note: it looks like -1 (though not a defined errno) is also a possible "errno" that could be returned.
I'm going to mark this as a wontfix for now. Proactive system monitoring falls within the sysadmin's scope of responsibilities, especially in a shared hosting (shared resources) environment.
At present, we generally don't try to catch errors on INSERT/UPDATE/SELECT queries. Implication: big patch, small benefit (warning) for a rare occurrence, requires user to check the Piwik dashboard (meanwhile other applications could be failing)
If a storage engine error occurs while the tracker executes, it could go undetected for a while. Implication: lost tracking, pain point
Running out of disk space is also an issue for disk-based session files. This would be visible to someone using the UI.
Another symptom that users might encounter:
SQLSTATE[HY000]: General error: 1 Can't create/write to file '/mysql/tmp/mysql-xyz/#sql_xyz_0.MYI' (Errcode: 2)