-
Notifications
You must be signed in to change notification settings - Fork 413
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
OAK-10921 : fixed race condition where fullGC database variables gets… #1562
Merged
Merged
Changes from all commits
Commits
Show all changes
7 commits
Select commit
Hold shift + click to select a range
813e1c1
OAK-10921 : fixed race condition where fullGC database variables gets…
de4280d
OAK-10921 : fixed unit cases
d75f63d
OAK-10921 : added unit case for resetFullGC & resetGC both
d34ba07
OAK-10921 : undo the scope change for FullGcMode
4479723
OAK-10921 : extracted out common code
4e2009e
OAK-10921 : added javadocs for update settings method
7f560c6
OAK-10921 : removed hashmap subclass with normal hashmap creation
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -95,7 +95,6 @@ | |
import static org.junit.Assert.assertNull; | ||
import static org.junit.Assert.assertTrue; | ||
import static org.junit.Assert.fail; | ||
import static org.junit.Assume.assumeThat; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. removed it, cause it was an unused import. |
||
import static org.junit.Assume.assumeTrue; | ||
|
||
import org.apache.jackrabbit.guava.common.cache.Cache; | ||
|
@@ -1477,6 +1476,90 @@ private Iterator<NodeDocument> candidates(long fromModified, long toModified, in | |
|
||
// OAK-10199 END | ||
|
||
// OAK-10921 | ||
@Test | ||
public void resetGCFromOakRunWhileRunning() throws Exception { | ||
// if we reset fullGC from any external source while GC is running, | ||
// it should not update the fullGC variables. | ||
resetFullGCExternally(false); | ||
} | ||
|
||
@Test | ||
public void resetFullGCFromOakRunWhileRunning() throws Exception { | ||
// if we reset fullGC from any external source while GC is running, | ||
// it should not update the fullGC variables. | ||
resetFullGCExternally(true); | ||
} | ||
|
||
private void resetFullGCExternally(final boolean resetFullGCOnly) throws Exception { | ||
//1. Create nodes with properties | ||
NodeBuilder b1 = store1.getRoot().builder(); | ||
|
||
// Add property to node & save | ||
for (int i = 0; i < 5; i++) { | ||
b1.child("z"+i).setProperty("prop", "foo", STRING); | ||
} | ||
store1.merge(b1, EmptyHook.INSTANCE, CommitInfo.EMPTY); | ||
store1.runBackgroundOperations(); | ||
|
||
// enable the full gc flag | ||
writeField(gc, "fullGCEnabled", true, true); | ||
long maxAge = 1; //hours | ||
long delta = MINUTES.toMillis(10); | ||
//1. Go past GC age and check no GC done as nothing deleted | ||
clock.waitUntil(getCurrentTimestamp() + maxAge); | ||
VersionGCStats stats = gc(gc, maxAge, HOURS); | ||
assertStatsCountsZero(stats); | ||
|
||
//Remove property | ||
NodeBuilder b2 = store1.getRoot().builder(); | ||
for (int i = 0; i < 5; i++) { | ||
b2.getChildNode("z"+i).removeProperty("prop"); | ||
} | ||
store1.merge(b2, EmptyHook.INSTANCE, CommitInfo.EMPTY); | ||
store1.runBackgroundOperations(); | ||
|
||
final AtomicReference<VersionGarbageCollector> gcRef = Atomics.newReference(); | ||
final VersionGCSupport gcSupport = new VersionGCSupport(store1.getDocumentStore()) { | ||
|
||
@Override | ||
public Iterable<NodeDocument> getModifiedDocs(long fromModified, long toModified, int limit, @NotNull String fromId, | ||
final @NotNull Set<String> includePaths, final @NotNull Set<String> excludePaths) { | ||
// reset fullGC variables externally while GC is running | ||
if (resetFullGCOnly) { | ||
gcRef.get().resetFullGC(); | ||
} else { | ||
gcRef.get().reset(); | ||
} | ||
return super.getModifiedDocs(fromModified, toModified, limit, fromId, includePaths, excludePaths); | ||
} | ||
}; | ||
|
||
gcRef.set(new VersionGarbageCollector(store1, gcSupport, true, false, false, 3)); | ||
|
||
//3. Check that deleted property does get collected post maxAge | ||
clock.waitUntil(clock.getTime() + HOURS.toMillis(maxAge*2) + delta); | ||
|
||
Document document = store1.getDocumentStore().find(SETTINGS, SETTINGS_COLLECTION_ID); | ||
assert document != null; | ||
assertNotNull(document.get(SETTINGS_COLLECTION_FULL_GC_TIMESTAMP_PROP)); | ||
assertNotNull(document.get(SETTINGS_COLLECTION_FULL_GC_DOCUMENT_ID_PROP)); | ||
|
||
stats = gcRef.get().gc(maxAge*2, HOURS); | ||
|
||
document = store1.getDocumentStore().find(SETTINGS, SETTINGS_COLLECTION_ID); | ||
assertEquals(5, stats.updatedFullGCDocsCount); | ||
assertEquals(5, stats.deletedPropsCount); | ||
assertEquals(MIN_ID_VALUE, stats.oldestModifiedDocId); | ||
|
||
// 4. verify that fullGC variables are not updated after resetting them | ||
assert document != null; | ||
assertNull(document.get(SETTINGS_COLLECTION_FULL_GC_TIMESTAMP_PROP)); | ||
assertNull(document.get(SETTINGS_COLLECTION_FULL_GC_DOCUMENT_ID_PROP)); | ||
} | ||
|
||
// OAK-10921 END | ||
|
||
@SuppressWarnings("unchecked") | ||
/** | ||
* Test when a revision on a parent is becoming garbage on a property | ||
|
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Noticed a couple issues with this:
updateVGCSetting
is used. It seems to be targeted forevaluate
. But that method has a complex (if-) structure and it's not easy to figure out in which casesupdateVGCSetting
is called. Maybe this is more of a readability comment. Perhaps adding a comment would be a good improvement thouhg.VersionGCInitTest.lazyInitialize
currently fails sinceupdateVGCSetting
is invokved but with a condition thatfullGCTimeStamp
andfullGCId
are set. Except it seems those are not initialized. So the initialization of these must somehow be better covered, I'd suggest first in a separate test case perhaps, and then in the code.