Skip to content

Commit 76efc2b

Browse files
committed
Fix file truncation errors during replication in Windows CS
1 parent 9eefa79 commit 76efc2b

File tree

1 file changed

+8
-3
lines changed

1 file changed

+8
-3
lines changed

src/jrd/replication/ChangeLog.cpp

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -273,11 +273,16 @@ void ChangeLog::Segment::truncate()
273273

274274
const auto hndl = (HANDLE) _get_osfhandle(m_handle);
275275
const auto ret = SetFilePointer(hndl, newSize.LowPart, &newSize.HighPart, FILE_BEGIN);
276-
if (ret == INVALID_SET_FILE_POINTER || !SetEndOfFile(hndl))
276+
if (ret != INVALID_SET_FILE_POINTER)
277+
SetEndOfFile(hndl);
277278
#else
278-
if (os_utils::ftruncate(m_handle, length))
279+
os_utils::ftruncate(m_handle, length);
279280
#endif
280-
raiseError("Journal file %s truncate failed (error %d)", m_filename.c_str(), ERRNO);
281+
282+
// Truncation is known to be error-prone in Windows CS, which does not allow to truncate
283+
// a file with a mapping open by some other process (ERROR_USER_MAPPED_FILE is returned).
284+
// But we may safely ignore the result, because truncation here is just a storage/copying
285+
// optimization, it's not critical from the archiving POV.
281286

282287
mapHeader();
283288
}

0 commit comments

Comments
 (0)