joncrlsn/dque

Dequeue is failing while deleting the segment "The process cannot access the file because it is being used by another process"

ysaik opened this issue · 3 comments

ysaik commented

Hi,
I was trying a simple program to enqueue and dequeue 10 elements. with segment size 5
its failing with below error
main.go and go.mod files attached
PS C:\Sai_laptop_backup\workspace\golang\dque_test> .\main.exe
Enqueued SAI100 1
Enqueued SAI101 2
Enqueued SAI102 3
Enqueued SAI103 4
Enqueued SAI104 5
Enqueued SAI105 6
Enqueued SAI106 7
Enqueued SAI107 8
Enqueued SAI108 9
Enqueued SAI109 10
Dequeued: &{SAI100 1}
Dequeued: &{SAI101 2}
Dequeued: &{SAI102 3}
Dequeued: &{SAI103 4}
2021/07/20 11:22:49 Error dequeuing item:error deleting queue segment C:/Sai_laptop_backup/workspace/golang/dque_test/item-queue/0000000000001.dque. Queue is in an inconsistent state: error deleting file: C:/Sai_laptop_backup/workspace/golang/dque_test/item-queue/0000000000001.dque: remove C:/Sai_laptop_backup/workspace/golang/dque_test/item-queue/0000000000001.dque: The process cannot access the file because it is being used by another process.

ysaik commented

dque_test.zip

main.go and go.mod files are attached

It is failing to remove the first segment from the queue

Hi, Thank you for reporting that. I don't have access to a Windows machine. If you figure it out and find a fix, please create a Pull Request. Or at least let me know what the fix is.

This is an inherent bug with Golang, based on how files are created in Windows. There is a long thread on fixing and changing it (and the Linux people seemed to have won). One of the posts in there has a work around for it.

https://github.com/alexbrainman/goissue34681

I've implemented in a fork I am using, but I also had to make changes in the Flock library because it was using the same call/function.