I'd like to use preemptible google compute instance to save money, and persist data using a persistent disk that is attached to the instance. But I'm concerned about the risk of data corruption as outlined in the detach-disk documentation, because it's unclear to me if the disk will be detached properly when the instance is preempted. Any advice/experiences on this? I didn't find any guidance in the google cloud documentation. I'm wondering if I could add the unmount command, sudo umount /dev/disk/by-id/[disk-name]
, to the preemptible instance shutdown script, but I haven't tried that yet. I could also set up frequent disk snapshots to minimize the damage of data corruption, if that does happen.
Asked
Active
Viewed 316 times
0

skeller88
- 4,276
- 1
- 32
- 34
1 Answers
3
You should have zero concern that there will be disk corruption because a preempt-able Compute Engine is preempted. If it were possible that disk buffers were not properly flushed during a Compute Engine preemption, that fact would be screamed loudly from the documentation and the forum. While I have no information on how the Compute Engine is ultimately shutdown, I do have a rock-solid belief that just before it breathes its last, any persistent disk writes out-standing are committed.

Kolban
- 13,794
- 3
- 38
- 60
-
3To add to this correct answer. The final result depends on the applications running on the instance. If they correctly shutdown in response to the shutdown event, no problem. A poorly designed application that does not shutdown could produce unexpected results. Preemptible instances have 30 seconds after instance preemption begins to complete application-specific shutdown processes. https://cloud.google.com/compute/docs/shutdownscript – John Hanley Jan 16 '20 at 04:35
-
You're probably right. However, Google mentions that "Compute Engine executes shutdown scripts only on a best-effort basis. In rare cases, Compute Engine cannot guarantee that the shutdown script will complete." I'm gonna reach out to their support to get their input. – skeller88 Jan 16 '20 at 20:20
-
1I wasn't able to get ahold of their support, but I've worked with pre-emptible instances a bit now and I agree; the instances would be unusable if risk of disk corruption was high. – skeller88 Feb 04 '20 at 00:46