In researching the issue, I found that auto_increment should be set for the metadata_id field in the wp_metadata table. If it is not set, WordPress tries to assign a metadata_id of 0 for all new custom fields and fails with that something strange error. I can’t guarantee it will work for you but it is something worth checking. When switching that field to aut_increment, make sure to remove the default value of 0.