Opened 14 years ago

Closed 14 years ago

#525 closed defect (fixed)

compactstub3 and compactstub4 tests fail on Windows

Reported by: Charlie Hull Owned by: Olly Betts
Priority: normal Milestone: 1.2.5
Component: Test Suite Version: 1.2.4
Severity: normal Keywords:
Cc: Blocked By:
Blocking: Operating System: Microsoft Windows

Description (last modified by Olly Betts)

Grouped together as I expect they're failing for the same reason (different file deletion behaviour).

Running test: compactstub3... DatabaseError: Cannot rename '.stub/compactstub3_1
294240351/new_stub.tmp' to '.stub/compactstub3' (File exists)
apitest backend brass: 0 tests passed, 1 failed.
Running tests with backend "chert"...
Running test: compactstub3... DatabaseError: Cannot rename '.stub/compactstub3_1
294240352/new_stub.tmp' to '.stub/compactstub3' (File exists)
apitest backend chert: 0 tests passed, 1 failed.
Running tests with backend "flint"...
Running test: compactstub3... DatabaseError: Cannot rename '.stub/compactstub3_1
294240353/new_stub.tmp' to '.stub/compactstub3' (File exists)

Attachments (1)

patch47.patch (421 bytes ) - added by Charlie Hull 14 years ago.
patch to api_compact.cc

Download all attachments as: .zip

Change History (9)

comment:1 by Charlie Hull, 14 years ago

Running test: compactstub3... DatabaseError: Cannot rename '.stub/compactstub3_1
294240351/new_stub.tmp' to '.stub/compactstub3' (File exists)
apitest backend brass: 0 tests passed, 1 failed.
Running tests with backend "chert"...
Running test: compactstub3... DatabaseError: Cannot rename '.stub/compactstub3_1
294240352/new_stub.tmp' to '.stub/compactstub3' (File exists)
apitest backend chert: 0 tests passed, 1 failed.
Running tests with backend "flint"...
Running test: compactstub3... DatabaseError: Cannot rename '.stub/compactstub3_1
294240353/new_stub.tmp' to '.stub/compactstub3' (File exists)

comment:2 by Olly Betts, 14 years ago

Description: modified (diff)
Milestone: 1.2.5

Hopefully fixed in trunk r15288 - please retest.

comment:3 by Charlie Hull, 14 years ago

Still the same error I'm afraid.

comment:4 by Olly Betts, 14 years ago

I'm afraid that's me out of ideas, so I think you're going to work out what's going wrong. From the error, it seems the exception is being thrown from api/compactor.cc.

comment:5 by Charlie Hull, 14 years ago

The error is ERROR_CURRENT_DIRECTORY being thrown by MoveFileEx(), which is being called at line 522 of api/compactor.cc - MoveFileEx seems to be saying it can't delete the 'from' directory - could this be because something is still open here?

comment:6 by Olly Betts, 14 years ago

Both the arguments are (or should be) filenames - it is renaming the new temporary stub file to replace the existing stub. It really shouldn't be trying to delete any directories.

The files aren't in the same directory, as they probably are in other cases where we already use MoveFileEx - perhaps that's the issue? It doesn't seem to be a documented limitation though.

Otherwise not sure what might be up. The file should be closed when the ofstream object goes out of scope just above, but I guess you could try adding an explicit call to close() to see if that makes a difference, but I don't see why that would give ERROR_CURRENT_DIRECTORY.

comment:7 by Charlie Hull, 14 years ago

Closing the handle to the stub file in the test code before compacting fixes this, patch attached. Windows didn't like overwriting a file that was already opened by ofstream.

by Charlie Hull, 14 years ago

Attachment: patch47.patch added

patch to api_compact.cc

comment:8 by Olly Betts, 14 years ago

Resolution: fixed
Status: newclosed

I've added close() calls to all the ofstream objects in api_compact.cc in r15320, which should help avoid us hitting similar issues in this area in the future.

Note: See TracTickets for help on using tickets.