Skip to content

Pack-Files not closed after git.close() #183

Description

@zotttelbart

Version

7.3.0

Operating System

Windows

Bug description

I think, the calculation of numRemovalBlocks in private WindowCache() is not correct.

At a Blocksize of 1024 and a tablesize of 3200, numRemovalBlocks is only 3.

		int bs = 1024;
		if (tableSize < 2 * bs) {
			bs = tableSize / 2;
		}
		removalBlockSize = bs;
		numRemovalBlocks = tableSize / removalBlockSize;

So, only elements at Index 0 - 3071 are closed properly in WindowCache.purge, even after git.close().

Image

That leeds to unclosed Packfiles in some cases.

Actual behavior

WindowCacheEntries behind numRemovalBlocks * bs are not closed properly, so that activeWindows never gets to zero in Pack.endWindowCache()

Expected behavior

numRemovalBlocks should be calculated correct in WindowCache()

numRemovalBlocks = ((tableSize-1) / removalBlockSize) + 1;

Relevant log output

After git.close() I get (under Windows):

Exception in thread "main" java.io.IOException: Could not delete file c:\temp\gctest\jgit-copy\.git\objects\pack\pack-151f5cdb9520a58a75358bcbf1601126fff04bae.pack
	at org.eclipse.jgit.util.FileUtils.handleDeleteException(FileUtils.java:233)
	at org.eclipse.jgit.util.FileUtils.delete(FileUtils.java:226)
	at GCTest.main(GCTest.java:256)
Caused by: java.nio.file.FileSystemException: c:\temp\gctest\jgit-copy\.git\objects\pack\pack-151f5cdb9520a58a75358bcbf1601126fff04bae.pack: Der Prozess kann nicht auf die Datei zugreifen, da sie von einem anderen Prozess verwendet wird
	at java.base/sun.nio.fs.WindowsException.translateToIOException(WindowsException.java:92)
	at java.base/sun.nio.fs.WindowsException.rethrowAsIOException(WindowsException.java:103)
	at java.base/sun.nio.fs.WindowsException.rethrowAsIOException(WindowsException.java:108)
	at java.base/sun.nio.fs.WindowsFileSystemProvider.implDelete(WindowsFileSystemProvider.java:275)
	at java.base/sun.nio.fs.AbstractFileSystemProvider.deleteIfExists(AbstractFileSystemProvider.java:110)
	at java.base/java.nio.file.Files.deleteIfExists(Files.java:1191)
	at org.eclipse.jgit.util.FileUtils.delete(FileUtils.java:219)
	... 1 more

Other information

The bug is caused by https://eclipse.gerrithub.io/c/eclipse-jgit/jgit/+/1204695 (6.10)

No response

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions