-
Notifications
You must be signed in to change notification settings - Fork 55
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
GG-37730 Logging improvements for events of WAL segments deletion #2963
Open
sergey-chugunov-1985
wants to merge
9
commits into
master
Choose a base branch
from
gg-37730
base: master
Could not load branches
Branch not found: {{ refName }}
Could not load tags
Nothing to show
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from 4 commits
Commits
Show all changes
9 commits
Select commit
Hold shift + click to select a range
2cbab1a
GG-37730 Additional logging for deleting WAL segments
sergey-chugunov-1985 34b9fe1
GG-37730 Logging for cleaning up segments from FileCleaner operations
sergey-chugunov-1985 d373b72
GG-37730 Additional tests and minor code clean up fixes
sergey-chugunov-1985 e42c5aa
GG-37730 Checkstyle fix
sergey-chugunov-1985 692c89f
Update modules/core/src/test/java/org/apache/ignite/internal/processo…
sergey-chugunov-1985 dc4c84e
Update modules/core/src/test/java/org/apache/ignite/internal/processo…
sergey-chugunov-1985 d27396e
Update modules/core/src/test/java/org/apache/ignite/internal/processo…
sergey-chugunov-1985 70815cc
GG-37730 Review changes addressed
sergey-chugunov-1985 5ef66e4
GG-37730 Pesky NPE fixed
sergey-chugunov-1985 File filter
Filter by extension
Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -1067,16 +1067,19 @@ private boolean hasIndex(long absIdx) { | |
|
||
int deleted = 0; | ||
|
||
List<String> deletedSegments = new ArrayList<>(); | ||
long lastCpIdx = lastCheckpointPtr.index(); | ||
|
||
for (FileDescriptor desc : descs) { | ||
long archivedAbsIdx = segmentAware.lastArchivedAbsoluteIndex(); | ||
|
||
long lastArchived = archivedAbsIdx >= 0 ? archivedAbsIdx : lastArchivedIndex(); | ||
|
||
if (desc.idx >= lastCheckpointPtr.index() // We cannot delete segments needed for binary recovery. | ||
if (desc.idx >= lastCpIdx // We cannot delete segments needed for binary recovery. | ||
|| desc.idx >= lastArchived // We cannot delete last segment, it is needed at start of node and avoid gaps. | ||
|| desc.idx >= highPtr.index() // We cannot delete segments larger than the border. | ||
|| !segmentAware.minReserveIndex(desc.idx)) // We cannot delete reserved segment. | ||
return deleted; | ||
break; | ||
|
||
long len = desc.file.length(); | ||
|
||
|
@@ -1087,6 +1090,8 @@ private boolean hasIndex(long absIdx) { | |
else { | ||
deleted++; | ||
|
||
deletedSegments.add(desc.file().getName()); | ||
|
||
long idx = desc.idx(); | ||
|
||
segmentSize.remove(idx); | ||
|
@@ -1100,6 +1105,11 @@ private boolean hasIndex(long absIdx) { | |
cctx.kernalContext().encryption().onWalSegmentRemoved(desc.idx); | ||
} | ||
|
||
if (log.isInfoEnabled() && !deletedSegments.isEmpty()) { | ||
log.info("Segments removed after WAL archive cleaning [cleanedSegments=" + deletedSegments | ||
+ ", lastCpIdx=" + lastCpIdx + ", highIdx=" + highPtr.index() + ']'); | ||
} | ||
|
||
return deleted; | ||
} | ||
|
||
|
@@ -2412,21 +2422,36 @@ private void deleteObsoleteRawSegments() { | |
Set<Long> indices = new HashSet<>(); | ||
Set<Long> duplicateIndices = new HashSet<>(); | ||
|
||
long lastCpIndex = lastCheckpointPtr.index(); | ||
|
||
for (FileDescriptor desc : descs) { | ||
if (!indices.add(desc.idx)) | ||
duplicateIndices.add(desc.idx); | ||
} | ||
|
||
List<Long> deletedRawSegments = new ArrayList<>(); | ||
|
||
for (FileDescriptor desc : descs) { | ||
if (desc.isCompressed()) | ||
continue; | ||
|
||
// Do not delete reserved or locked segment and any segment after it. | ||
if (segmentReservedOrLocked(desc.idx)) | ||
return; | ||
break; | ||
|
||
if (desc.idx < lastCpIndex && duplicateIndices.contains(desc.idx)) { | ||
long cleanedUpSize = deleteArchiveFiles(desc.file); | ||
|
||
if (cleanedUpSize > 0) | ||
deletedRawSegments.add(desc.idx); | ||
|
||
segmentAware.addSize(desc.idx, -cleanedUpSize); | ||
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. should we move this line under the |
||
} | ||
} | ||
|
||
if (desc.idx < lastCheckpointPtr.index() && duplicateIndices.contains(desc.idx)) | ||
segmentAware.addSize(desc.idx, -deleteArchiveFiles(desc.file)); | ||
if (log.isInfoEnabled() && !deletedRawSegments.isEmpty()) { | ||
log.info("Raw segments removed after compression [deletedSegments=" + deletedRawSegments | ||
+ ", lastCpIndex=" + lastCpIndex + ']'); | ||
} | ||
} | ||
} | ||
|
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 |
---|---|---|
|
@@ -21,9 +21,11 @@ | |
import java.util.Collection; | ||
import java.util.concurrent.ConcurrentLinkedQueue; | ||
import java.util.function.Consumer; | ||
import java.util.regex.Pattern; | ||
import java.util.stream.Stream; | ||
import org.apache.ignite.Ignite; | ||
import org.apache.ignite.IgniteCache; | ||
import org.apache.ignite.IgniteLogger; | ||
import org.apache.ignite.cache.CacheAtomicityMode; | ||
import org.apache.ignite.cluster.ClusterState; | ||
import org.apache.ignite.configuration.CacheConfiguration; | ||
|
@@ -41,6 +43,8 @@ | |
import org.apache.ignite.internal.util.IgniteUtils; | ||
import org.apache.ignite.internal.util.typedef.internal.U; | ||
import org.apache.ignite.testframework.ListeningTestLogger; | ||
import org.apache.ignite.testframework.LogListener; | ||
import org.apache.ignite.testframework.junits.GridAbstractTest; | ||
import org.apache.ignite.testframework.junits.WithSystemProperty; | ||
import org.apache.ignite.testframework.junits.common.GridCommonAbstractTest; | ||
import org.junit.Test; | ||
|
@@ -62,16 +66,19 @@ | |
*/ | ||
public abstract class WalDeletionArchiveAbstractTest extends GridCommonAbstractTest { | ||
/** | ||
* Start grid with override default configuration via customConfigurator. | ||
* Start grid with override default configuration via customConfigurator and with custom logger (if provided). | ||
sergey-chugunov-1985 marked this conversation as resolved.
Show resolved
Hide resolved
|
||
*/ | ||
private Ignite startGrid(Consumer<DataStorageConfiguration> customConfigurator) throws Exception { | ||
private Ignite startGrid(Consumer<DataStorageConfiguration> customConfigurator, IgniteLogger customLog) throws Exception { | ||
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. Do we use |
||
IgniteConfiguration configuration = getConfiguration(getTestIgniteInstanceName()); | ||
|
||
if (customLog != null) | ||
configuration.setGridLogger(customLog); | ||
|
||
DataStorageConfiguration dbCfg = new DataStorageConfiguration(); | ||
|
||
dbCfg.setWalMode(walMode()); | ||
dbCfg.setWalSegmentSize(512 * 1024); | ||
dbCfg.setCheckpointFrequency(60 * 1000);//too high value for turn off frequency checkpoint. | ||
dbCfg.setCheckpointFrequency(60 * 1000);//too high value for turn off triggering checkpoint by timeout. | ||
sergey-chugunov-1985 marked this conversation as resolved.
Show resolved
Hide resolved
|
||
dbCfg.setDefaultDataRegionConfiguration(new DataRegionConfiguration() | ||
.setMaxSize(100 * 1024 * 1024) | ||
.setPersistenceEnabled(true)); | ||
|
@@ -87,6 +94,13 @@ private Ignite startGrid(Consumer<DataStorageConfiguration> customConfigurator) | |
return ignite; | ||
} | ||
|
||
/** | ||
* Start grid with override default configuration via customConfigurator and default logger. | ||
sergey-chugunov-1985 marked this conversation as resolved.
Show resolved
Hide resolved
|
||
*/ | ||
private Ignite startGrid(Consumer<DataStorageConfiguration> customConfigurator) throws Exception { | ||
return startGrid(customConfigurator, null); | ||
} | ||
|
||
/** */ | ||
private CacheConfiguration<Integer, Object> cacheConfiguration() { | ||
CacheConfiguration<Integer, Object> ccfg = new CacheConfiguration<>(DEFAULT_CACHE_NAME); | ||
|
@@ -125,9 +139,16 @@ private String findSourceMessage(Throwable ex) { | |
*/ | ||
@Test | ||
public void testCorrectDeletedArchivedWalFiles() throws Exception { | ||
ListeningTestLogger listeningLog = new ListeningTestLogger(GridAbstractTest.log); | ||
//"Segments removed after WAL archive cleaning [cleanedSegments=[" | ||
LogListener listener = LogListener | ||
.matches(Pattern.compile("Segments removed after WAL archive cleaning \\[cleanedSegments=\\[\\d+.wal")) | ||
.build(); | ||
listeningLog.registerListener(listener); | ||
|
||
//given: configured grid with setted max wal archive size | ||
long maxWalArchiveSize = 2 * 1024 * 1024; | ||
Ignite ignite = startGrid(dbCfg -> dbCfg.setMaxWalArchiveSize(maxWalArchiveSize)); | ||
Ignite ignite = startGrid(dbCfg -> dbCfg.setMaxWalArchiveSize(maxWalArchiveSize), listeningLog); | ||
|
||
GridCacheDatabaseSharedManager dbMgr = gridDatabase(ignite); | ||
|
||
|
@@ -158,6 +179,8 @@ public void testCorrectDeletedArchivedWalFiles() throws Exception { | |
assertFalse(Stream.of(files).anyMatch(desc -> desc.file().getName().endsWith("00001.wal"))); | ||
|
||
assertTrue(!hist.checkpoints().isEmpty()); | ||
|
||
assertTrue(listener.check()); | ||
} | ||
|
||
/** | ||
|
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.
I would suggest to use lazy initialization here and in similar places, since this is only for logging