etcd
etcd copied to clipboard
fileutil: fixed work with wal files lock on the windows
trafficstars
The current wal file lock check contains a very strange code.
//Etcd/client/pkg/fileutil/lock_windows.go
if err == nil {
return nil
} else if err.Error() == errLocked.Error() {
return ErrLocked
} else if err != windows.ERROR_LOCK_VIOLATION {
return err
}
return nil
This code check whether the lock is set or not by the message of the error received from the operating system. At the same time, the message with which it is compared differs from the message that the operating system returns.
//The message returned by the OS
"The process cannot access the file because another process has locked a portion of the file."
//The message expected in the code
"the process cannot access the file because another process has locked a portion of the file"
As a result, the check fails and the purge loop deletes the blocked wal files. I rewrote the check to check the error code, in my opinion this is a more reliable way.
Linked issue 14252