-
Notifications
You must be signed in to change notification settings - Fork 480
Removes in memory set from dead compaction detector #6283
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
Merged
Merged
Changes from 7 commits
Commits
Show all changes
8 commits
Select commit
Hold shift + click to select a range
2b6cbb6
Removes in memory set from dead compaction detector
keith-turner 6ad2090
consolidate code
keith-turner 8e895f7
Update server/base/src/main/java/org/apache/accumulo/server/metadata/…
keith-turner b211e5b
Update server/manager/src/main/java/org/apache/accumulo/manager/compa…
keith-turner d5af542
Merge remote-tracking branch 'upstream/main' into tmp-file-cleanup
keith-turner 3ce74c0
remove import
keith-turner 4993169
code review update
keith-turner db57334
renamed RemovedCompaction to OrphanedCompaction
keith-turner 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 hidden or 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 hidden or 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 hidden or 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
103 changes: 103 additions & 0 deletions
103
...er/base/src/main/java/org/apache/accumulo/server/metadata/RemovedCompactionStoreImpl.java
This file contains hidden or 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 |
|---|---|---|
| @@ -0,0 +1,103 @@ | ||
| /* | ||
| * Licensed to the Apache Software Foundation (ASF) under one | ||
| * or more contributor license agreements. See the NOTICE file | ||
| * distributed with this work for additional information | ||
| * regarding copyright ownership. The ASF licenses this file | ||
| * to you under the Apache License, Version 2.0 (the | ||
| * "License"); you may not use this file except in compliance | ||
| * with the License. You may obtain a copy of the License at | ||
| * | ||
| * https://www.apache.org/licenses/LICENSE-2.0 | ||
| * | ||
| * Unless required by applicable law or agreed to in writing, | ||
| * software distributed under the License is distributed on an | ||
| * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY | ||
| * KIND, either express or implied. See the License for the | ||
| * specific language governing permissions and limitations | ||
| * under the License. | ||
| */ | ||
| package org.apache.accumulo.server.metadata; | ||
|
|
||
| import java.util.Collection; | ||
| import java.util.List; | ||
| import java.util.Map; | ||
| import java.util.function.Function; | ||
| import java.util.stream.Collectors; | ||
| import java.util.stream.Stream; | ||
|
|
||
| import org.apache.accumulo.core.client.MutationsRejectedException; | ||
| import org.apache.accumulo.core.client.Scanner; | ||
| import org.apache.accumulo.core.client.TableNotFoundException; | ||
| import org.apache.accumulo.core.data.Mutation; | ||
| import org.apache.accumulo.core.metadata.schema.Ample; | ||
| import org.apache.accumulo.core.metadata.schema.MetadataSchema.RemovedCompactionSection; | ||
| import org.apache.accumulo.core.security.Authorizations; | ||
| import org.apache.accumulo.server.ServerContext; | ||
|
|
||
| import com.google.common.base.Preconditions; | ||
|
|
||
| public class RemovedCompactionStoreImpl implements Ample.RemovedCompactionStore { | ||
| private final ServerContext context; | ||
|
|
||
| public RemovedCompactionStoreImpl(ServerContext context) { | ||
| this.context = context; | ||
| } | ||
|
|
||
| private Stream<Ample.RemovedCompaction> createStream(String tableName) { | ||
| Scanner scanner = null; | ||
| try { | ||
| scanner = context.createScanner(tableName, Authorizations.EMPTY); | ||
| } catch (TableNotFoundException e) { | ||
| throw new IllegalStateException(e); | ||
| } | ||
| scanner.setRange(RemovedCompactionSection.getRange()); | ||
| return scanner.stream().map(e -> e.getKey().getRowData().toString()) | ||
| .map(RemovedCompactionSection::decodeRow).onClose(scanner::close); | ||
| } | ||
|
|
||
| @Override | ||
| public Stream<Ample.RemovedCompaction> list() { | ||
| return Stream.concat(createStream(Ample.DataLevel.METADATA.metaTable()), | ||
| createStream(Ample.DataLevel.USER.metaTable())); | ||
| } | ||
|
|
||
| private void write(Collection<Ample.RemovedCompaction> removedCompactions, | ||
| Function<Ample.RemovedCompaction,Mutation> converter) { | ||
| if (removedCompactions.isEmpty()) { | ||
| return; | ||
| } | ||
|
|
||
| Map<Ample.DataLevel,List<Ample.RemovedCompaction>> byLevel = removedCompactions.stream() | ||
| .collect(Collectors.groupingBy(rc -> Ample.DataLevel.of(rc.table()))); | ||
| // Do not expect the root to split or merge so it should never have this data | ||
| Preconditions.checkArgument(!byLevel.containsKey(Ample.DataLevel.ROOT)); | ||
| byLevel.forEach((dl, removed) -> { | ||
| try (var writer = context.createBatchWriter(dl.metaTable())) { | ||
| for (var rc : removed) { | ||
| writer.addMutation(converter.apply(rc)); | ||
| } | ||
| } catch (TableNotFoundException | MutationsRejectedException e) { | ||
| throw new IllegalStateException(e); | ||
| } | ||
| }); | ||
| } | ||
|
|
||
| @Override | ||
| public void add(Collection<Ample.RemovedCompaction> removedCompactions) { | ||
| write(removedCompactions, rc -> { | ||
| Mutation m = new Mutation(RemovedCompactionSection.encodeRow(rc)); | ||
| m.put("", "", ""); | ||
| return m; | ||
| }); | ||
|
|
||
| } | ||
|
|
||
| @Override | ||
| public void delete(Collection<Ample.RemovedCompaction> removedCompactions) { | ||
| write(removedCompactions, rc -> { | ||
| Mutation m = new Mutation(RemovedCompactionSection.encodeRow(rc)); | ||
| m.putDelete("", ""); | ||
| return m; | ||
| }); | ||
| } | ||
| } |
This file contains hidden or 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 hidden or 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
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.
It took me a few minutes to understand what a
RemovedCompactionrepresented. My understanding of these changes are that when a tablet is merged or split, the ECID entries in the tablet metadata for the tablets involved are removed. However, the compaction is likely running on a Compactor. Is that right?I was having trouble understanding the context given the name. I wonder if a different name might better reflect the situation. The compaction itself is not removed, it's OBE. It's been orphaned from it's parent tablet or it's like a dangling ref in a database. Would
OrphanedCompactionbe a better name?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.
OrphanedCompactionis a much better name, will change to that. Used removed in the name because it was removed from the metadata table.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.
Yes that is all correct.
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.
Renamed in db57334