mirror of
https://github.com/overleaf/overleaf.git
synced 2024-11-21 20:47:08 -05:00
Run GC on a project at start of swap job.
When there is an exception during swap, add project name to log
This commit is contained in:
parent
a2d041ffae
commit
c7d8c1c6b5
3 changed files with 13 additions and 2 deletions
|
@ -139,6 +139,13 @@ public class FSGitRepoStore implements RepoStore {
|
|||
return Tar.bz2.zip(getDotGitForProject(projectName), sizePtr);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void gcProject(String projectName) throws IOException {
|
||||
Project.checkValidProjectName(projectName);
|
||||
ProjectRepo repo = getExistingRepo(projectName);
|
||||
repo.runGC();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void remove(String projectName) throws IOException {
|
||||
Project.checkValidProjectName(projectName);
|
||||
|
|
|
@ -50,6 +50,8 @@ public interface RepoStore {
|
|||
return bzip2Project(projectName, null);
|
||||
}
|
||||
|
||||
void gcProject(String projectName) throws IOException;
|
||||
|
||||
/**
|
||||
* Called after {@link #bzip2Project(String, long[])}'s has been safely
|
||||
* uploaded to the swap store. Removes all traces of the project from disk,
|
||||
|
|
|
@ -118,10 +118,11 @@ public class SwapJobImpl implements SwapJob {
|
|||
(totalSize = repoStore.totalSize()) > lowWatermarkBytes &&
|
||||
(numProjects = dbStore.getNumUnswappedProjects()) > minProjects
|
||||
) {
|
||||
String projectName = dbStore.getOldestUnswappedProject();
|
||||
try {
|
||||
evict(dbStore.getOldestUnswappedProject());
|
||||
evict(projectName);
|
||||
} catch (IOException e) {
|
||||
Log.warn("Exception while swapping, giving up", e);
|
||||
Log.warn("[{}] Exception while swapping, giving up", projectName, e);
|
||||
}
|
||||
}
|
||||
if (totalSize > lowWatermarkBytes) {
|
||||
|
@ -161,6 +162,7 @@ public class SwapJobImpl implements SwapJob {
|
|||
Preconditions.checkNotNull(projName, "projName was null");
|
||||
Log.info("Evicting project: {}", projName);
|
||||
try (LockGuard __ = lock.lockGuard(projName)) {
|
||||
repoStore.gcProject(projName);
|
||||
long[] sizePtr = new long[1];
|
||||
try (InputStream blob = repoStore.bzip2Project(projName, sizePtr)) {
|
||||
swapStore.upload(projName, blob, sizePtr[0]);
|
||||
|
|
Loading…
Reference in a new issue