Skip to content

[ZEPPELIN-6529] Evict note cache entries when removing a folder#5296

Open
HwangRock wants to merge 1 commit into
apache:masterfrom
HwangRock:ZEPPELIN-6529-pr
Open

[ZEPPELIN-6529] Evict note cache entries when removing a folder#5296
HwangRock wants to merge 1 commit into
apache:masterfrom
HwangRock:ZEPPELIN-6529-pr

Conversation

@HwangRock

Copy link
Copy Markdown
Contributor

What is this PR for?

NoteManager.removeFolder removed the deleted notes from notesInfo and the in-memory folder tree, but never evicted them from the NoteCache. removeNote(String, AuthenticationInfo) already calls noteCache.removeNote(noteId), so the single-note path is clean; the folder path was not. As a result the Note objects for deleted notes stayed on the heap until the LRU threshold naturally evicted them, and they kept occupying cache slots that live notes could otherwise use. This is most wasteful for large folder deletions such as emptying the trash.

This PR evicts each removed note from noteCache in the same loop that clears notesInfo, mirroring the single-note removal path. There is no functional/correctness change (processNote already gates on notesInfo.containsKey), only immediate reclamation of the cache slots and heap held by deleted notes.

This was found by @ParkGyeongTae while reviewing #5288 / #5292 (ZEPPELIN-6345).

What type of PR is it?

Improvement

What is the Jira issue?

How should this be tested?

  • Added NoteManagerTest#testRemoveFolderEvictsNoteCache: adds two notes under /folder1, asserts getCacheSize() == 2, calls removeFolder("/folder1", ...), and asserts getCacheSize() == 0. Fails before the change (cache size stays 2), passes after.
  • Full NoteManagerTest passes (6 tests), including testLruCache and testNoteOperations.

Questions:

  • Does the license files need to update? No
  • Is there breaking changes for older versions? No
  • Does this needs documentation? No

NoteManager.removeFolder removed the deleted notes from notesInfo and the
in-memory folder tree, but did not call noteCache.removeNote for each note, so
the note objects stayed in the NoteCache until the LRU threshold naturally
evicted them. removeNote(String, AuthenticationInfo) already evicts the cache.

Evict each removed note from noteCache in the same loop that clears notesInfo,
mirroring the single-note removal path. This frees the heap held by deleted
notes immediately and stops them from occupying cache slots that live notes
could use, which matters most for large folder deletions such as emptying the
trash.

Added NoteManagerTest#testRemoveFolderEvictsNoteCache: adds two notes under a
folder, asserts they are cached, removes the folder, and asserts the cache is
emptied. Fails before the change (cache size stays 2), passes after.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant