Challenge
You might see "Failed to detach SCSI lun" errors in vSphere during the unexport phase when restoring items (file-level restore) from storage snapshot or doing an Instant Recovery from storage snapshot because of certain VMware behaviour. Both types of the restores include a step when storage snapshot clone is presented as a temporary datastore which should be unmounted or detached when the restore is finished.
Cause
By default when the device is detached, it stays in an unmounted state even if the device is re-presented (that is, the detached state is persistent). That positively means that it's possible to exhaust the limit of 512 detached devices which can lead to aforementioned error message
Solution
To clean up the list please refer to this kb article:
https://kb.vmware.com/s/article/2004605