Never delete the Install cache folder %windir%\installer to free up some disk space. This will cause serious problems during service pack upgrades!
In one of my cases, It happened. The installer folder was deleted and when I tried installing Service pack 2, It scolded me with this error: “The detection failed, this can be due to a corrupted installation database.”
Workaround is: I copied the files inside Installer cache from other SharePoint server and ran the upgrade again. It worked!
Update: Found this article to collect the Install cache from other servers and update the failed server: