Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

TSM: Rename while file is in Use in compact_test #5096

Closed
mvadu opened this issue Dec 11, 2015 · 0 comments
Closed

TSM: Rename while file is in Use in compact_test #5096

mvadu opened this issue Dec 11, 2015 · 0 comments
Assignees

Comments

@mvadu
Copy link
Contributor

mvadu commented Dec 11, 2015

I am trying to implement mmap and tsm compatibility to Windows via PR #4981 to fix #4358.
But MustWriteTSM in compact_test.go is trying to rename a file which is in use (a possible file leak scenario, not supported by Windows) is preventing me from proceeding. Could somebody here help me to resolve the issue?

>go test -v ./tsdb/engine/tsm1 > %temp%\gotest.txt 2>&1

     --- FAIL: TestCompactor_Compact (0.00s)
 panic: create tsm file: rename C:\Users\Ady\AppData\Local\Temp\tsm1-test087429749\tsm1test014002000 C:\Users\Ady\AppData\Local\Temp\tsm1-test087429749\000000001-000000001.tsm: The process cannot access the file because it is being used by another process. [recovered]
    panic: create tsm file: rename C:\Users\Ady\AppData\Local\Temp\tsm1-test087429749\tsm1test014002000 C:\Users\Ady\AppData\Local\Temp\tsm1-test087429749\000000001-000000001.tsm: The process cannot access the file because it is being used by another process.

gotest.txt

The root cause is in below code compact_test.go:761 where file handle returned by MustTempFile is not closed before rename operation, which is failing in Windows. Simply closing that handle before rename fails the next write operation.

 func MustWriteTSM(dir string, gen int, values map[string][]tsm1.Value) string {
    f := MustTempFile(dir)
    newName := filepath.Join(filepath.Dir(f.Name()), tsmFileName(gen))
    if err := os.Rename(f.Name(), newName); err != nil {
        panic(fmt.Sprintf("create tsm file: %v", err))
    }
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants