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

sync before trimUnreferencedReaders to improve index preformance #47790

Merged
merged 12 commits into from
Oct 9, 2019
Merged
Original file line number Diff line number Diff line change
Expand Up @@ -1670,6 +1670,8 @@ public void rollGeneration() throws IOException {
* required generation
*/
public void trimUnreferencedReaders() throws IOException {
// move most of the data to disk to reduce the time the lock is held
sync();
try (ReleasableLock ignored = writeLock.acquire()) {
if (closed.get()) {
// we're shutdown potentially on some tragic event, don't delete anything
Expand Down Expand Up @@ -1697,6 +1699,7 @@ public void trimUnreferencedReaders() throws IOException {
// We now update the checkpoint to ignore the file we are going to remove.
// Note that there is a provision in recoverFromFiles to allow for the case where we synced the checkpoint
// but crashed before we could delete the file.
// sync at once to make sure that there's at most one unreferenced generation.
current.sync();
deleteReaderFiles(reader);
}
Expand Down