Skip to content

Commit b0908ef

Browse files
committed
Fix handleStartupError() to return the result of deleting the cache.
1. We are checking if we failed to delete the existing cache with a different buildID before unsetting J9SHR_RUNTIMEFLAG_AUTOKILL_DIFF_BUILDID, so handleStartupError() should return deleteRC 2. Unset J9SHR_RUNTIMEFLAG_AUTOKILL_DIFF_BUILDID for lower layer readonly caches. Signed-off-by: Hang Shao <hangshao@ca.ibm.com>
1 parent b86d21b commit b0908ef

File tree

2 files changed

+9
-7
lines changed

2 files changed

+9
-7
lines changed

runtime/shared_common/CacheMap.cpp

+8-6
Original file line numberDiff line numberDiff line change
@@ -567,6 +567,7 @@ SH_CacheMap::startup(J9VMThread* currentThread, J9SharedClassPreinitConfig* pico
567567
}
568568
if (0 == _sharedClassConfig->readOnlyCacheRuntimeFlags) {
569569
_sharedClassConfig->readOnlyCacheRuntimeFlags = (_sharedClassConfig->runtimeFlags | J9SHR_RUNTIMEFLAG_ENABLE_READONLY);
570+
_sharedClassConfig->readOnlyCacheRuntimeFlags &= ~J9SHR_RUNTIMEFLAG_AUTOKILL_DIFF_BUILDID;
570571
_readOnlyCacheRuntimeFlags = &_sharedClassConfig->readOnlyCacheRuntimeFlags;
571572
}
572573
I_8 preLayer = 0;
@@ -595,7 +596,7 @@ SH_CacheMap::startup(J9VMThread* currentThread, J9SharedClassPreinitConfig* pico
595596
if (isCcHead) {
596597
cacheFileSize = _ccHead->getTotalSize();
597598
}
598-
handleStartupError(currentThread, ccToUse, rc, *runtimeFlags, _verboseFlags, &doRetry);
599+
handleStartupError(currentThread, ccToUse, rc, *runtimeFlags, _verboseFlags, &doRetry, &deleteRC);
599600

600601
if (isCcHead && doRetry) {
601602
if (cacheFileSize > 0) {
@@ -690,7 +691,7 @@ SH_CacheMap::startup(J9VMThread* currentThread, J9SharedClassPreinitConfig* pico
690691
} while (NULL != ccToUse && CC_STARTUP_OK == rc);
691692

692693
if (rc != CC_STARTUP_OK) {
693-
handleStartupError(currentThread, ccToUse, rc, *runtimeFlags, _verboseFlags, &doRetry);
694+
handleStartupError(currentThread, ccToUse, rc, *runtimeFlags, _verboseFlags, &doRetry, &deleteRC);
694695
Trc_SHR_CM_startup_Exit1(currentThread);
695696
return -1;
696697
}
@@ -779,9 +780,10 @@ SH_CacheMap::startup(J9VMThread* currentThread, J9SharedClassPreinitConfig* pico
779780
* @param [in] runtimeFlags The runtime flags
780781
* @param [in] verboseFlags Flags controlling the verbose output
781782
* @param [out] doRetry Whether to retry starting up the cache
783+
* @param [out] deleteRC 0 if cache is successful deleted, -1 otherwise.
782784
*/
783785
void
784-
SH_CacheMap::handleStartupError(J9VMThread* currentThread, SH_CompositeCacheImpl* ccToUse, IDATA errorCode, U_64 runtimeFlags, UDATA verboseFlags, bool *doRetry)
786+
SH_CacheMap::handleStartupError(J9VMThread* currentThread, SH_CompositeCacheImpl* ccToUse, IDATA errorCode, U_64 runtimeFlags, UDATA verboseFlags, bool *doRetry, IDATA *deleteRC)
785787
{
786788
PORT_ACCESS_FROM_VMC(currentThread);
787789
if (errorCode == CC_STARTUP_CORRUPT) {
@@ -802,9 +804,9 @@ SH_CacheMap::handleStartupError(J9VMThread* currentThread, SH_CompositeCacheImpl
802804
if ((errorCode == CC_STARTUP_CORRUPT) || (errorCode == CC_STARTUP_RESET) || (errorCode == CC_STARTUP_SOFT_RESET)) {
803805
/* If SOFT_RESET, suppress verbose unless "verbose" is explicitly set
804806
* This will ensure that if the VM can't destroy the cache, we don't get unwanted error messages */
805-
IDATA deleteRC = ccToUse->deleteCache(currentThread, (errorCode == CC_STARTUP_SOFT_RESET) && !(verboseFlags & J9SHR_VERBOSEFLAG_ENABLE_VERBOSE));
807+
*deleteRC = ccToUse->deleteCache(currentThread, (errorCode == CC_STARTUP_SOFT_RESET) && !(verboseFlags & J9SHR_VERBOSEFLAG_ENABLE_VERBOSE));
806808
ccToUse->cleanup(currentThread);
807-
if (deleteRC == 0) {
809+
if (0 == *deleteRC) {
808810
if (errorCode == CC_STARTUP_CORRUPT) {
809811
/* Recovering from a corrupted cache, clear the flags which prevent access */
810812
resetCorruptState(currentThread, FALSE);
@@ -814,7 +816,7 @@ SH_CacheMap::handleStartupError(J9VMThread* currentThread, SH_CompositeCacheImpl
814816
/* If the restored cache is corrupted, return CC_STARTUP_CORRUPT and do not retry,
815817
* as retry will create another empty cache that is not restored from the snapshot
816818
*/
817-
if ((deleteRC == 0) || (errorCode == CC_STARTUP_SOFT_RESET)) {
819+
if ((0 == *deleteRC) || (errorCode == CC_STARTUP_SOFT_RESET)) {
818820
/* If we deleted the cache, or in the case of SOFT_RESET, even if we failed to delete the cache, retry */
819821
Trc_SHR_Assert_True(ccToUse == _ccHead);
820822
*doRetry = true;

runtime/shared_common/CacheMap.hpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -506,7 +506,7 @@ class SH_CacheMap : public SH_SharedCache, public SH_CacheMapStats
506506

507507
IDATA getPrereqCache(J9VMThread* currentThread, const char* cacheDir, SH_CompositeCacheImpl* ccToUse, bool startupForStats, const char** prereqCacheID, UDATA* idLen);
508508

509-
void handleStartupError(J9VMThread* currentThread, SH_CompositeCacheImpl* ccToUse, IDATA errorCode, U_64 runtimeFlags, UDATA verboseFlags, bool *doRetry);
509+
void handleStartupError(J9VMThread* currentThread, SH_CompositeCacheImpl* ccToUse, IDATA errorCode, U_64 runtimeFlags, UDATA verboseFlags, bool *doRetry, IDATA *deleteRC);
510510

511511
void setCacheAddressRangeArray(void);
512512

0 commit comments

Comments
 (0)