geode
geode copied to clipboard
GEODE-10338: Fix LogWriterAppender shutdown
When a stop session is called on the LogWriterAppender, it closes the ManagerLogWriter's files. Still, it does not release ManagerLogWriter's reference, so the LogWriterAppender instance is kept around after disconnect. This situation ends up keeping the InternalDistributedSystem alive.
The fix is to clear the LogWriterAppender's reference to the ManagerLogWriter when the appender session is stopped.
For all changes:
-
[x] Is there a JIRA ticket associated with this PR? Is it referenced in the commit message?
-
[x] Has your PR been rebased against the latest commit within the target branch (typically
develop
)? -
[x] Is your initial contribution a single, squashed commit?
-
[x] Does
gradlew build
run cleanly? -
[x] Have you written or updated unit tests to verify your changes?
-
[ ] If adding new dependencies to the code, are these dependencies licensed in a way that is compatible for inclusion under ASF 2.0?
When created in the same VM, all cache instances use the same LogWriterAppender service. Therefore all tests that create multiple caches and try to close them will fail with NullpointerExecption
(the stopSession()
method will be executed more than once for the same LogWriterAppender
).
For example check MultipleCacheJUnitTest.cacheCreateTwoPeerCaches test case:
Jale create cache1
Jale LOGWRITER with instance org.apache.geode.logging.log4j.internal.impl.LogWriterAppender@49925e47:LOGWRITER {eagerMemberName=null, lazyMemberName=appendLog=true, security=false, paused=false, loggingSessionRegistry=org.apache.geode.logging.internal.LoggingSessionRegistryProvider@4ae90315, logWriter=org.apache.geode.logging.log4j.internal.impl.NullLogWriter@6b0572fa, debug=false} has logWriter object: org.apache.geode.logging.log4j.internal.impl.NullLogWriter@6b0572fa
Jale SECURITYLOGWRITER with instance org.apache.geode.logging.log4j.internal.impl.LogWriterAppender@7ed478ab:SECURITYLOGWRITER {eagerMemberName=null, lazyMemberName=appendLog=true, security=true, paused=false, loggingSessionRegistry=org.apache.geode.logging.internal.LoggingSessionRegistryProvider@4ae90315, logWriter=org.apache.geode.logging.log4j.internal.impl.NullLogWriter@3a981478, debug=false} has logWriter object: org.apache.geode.logging.log4j.internal.impl.NullLogWriter@3a981478
Jale create cache2
Jale LOGWRITER with instance org.apache.geode.logging.log4j.internal.impl.LogWriterAppender@49925e47:LOGWRITER {eagerMemberName=null, lazyMemberName=appendLog=true, security=false, paused=false, loggingSessionRegistry=org.apache.geode.logging.internal.LoggingSessionRegistryProvider@4ae90315, logWriter=org.apache.geode.logging.log4j.internal.impl.NullLogWriter@78cc6db3, debug=false} has logWriter object: org.apache.geode.logging.log4j.internal.impl.NullLogWriter@78cc6db3
Jale SECURITYLOGWRITER with instance org.apache.geode.logging.log4j.internal.impl.LogWriterAppender@7ed478ab:SECURITYLOGWRITER {eagerMemberName=null, lazyMemberName=appendLog=true, security=true, paused=false, loggingSessionRegistry=org.apache.geode.logging.internal.LoggingSessionRegistryProvider@4ae90315, logWriter=org.apache.geode.logging.log4j.internal.impl.NullLogWriter@3839a6d9, debug=false} has logWriter object: org.apache.geode.logging.log4j.internal.impl.NullLogWriter@3839a6d9
Jale closing: cache1
Jale stopSession: org.apache.geode.logging.log4j.internal.impl.NullLogWriter@78cc6db3
Jale stopSession: org.apache.geode.logging.log4j.internal.impl.NullLogWriter@3839a6d9
Jale closing: cache2
Jale stopSession: null
java.lang.NullPointerException
I think it would be best to return the check whether logWriter
is null at the beginning of stopSession()
method for these test cases to work. @kirklund, what do you think?