forked from apache/accumulo
-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Avoids using tablet metadata for compaction reservation
This change fixes apache#5188. Unfortunately it touches a lot of code because of cascading dependencies in the code. It would be difficult to break this into a smaller commit. These changes do reduce some of those dependencies though. There are two major advantages after this change. First tablet metadata is no longer kept in memory for queued compactions. Second the tablet metadata is no longer read during compaction reservation. Before this change the following would happen. 1. TGW would find a tablet to compact and enqueue compaction jobs+tablet metadata. 2. Eventually when a compactor requested a job it would yank job+tablet metadata off the queue. 3. To reserve the compaction a lot of complex analysis was done in the coordinator and then a conditional mutation was submitted. The conditional mutation would require all data involved in the complex analysis to be the same. 4. If the conditional mutation failed then the coordinator would reread the tablet metadata and go back to step 3. After this change the following happens in the code. 1. TGW would find a tablet to compact and enqueue a new class called ResolvedCompactionJob. This new class takes the compaction job and tablet metadata and computes all information needed for the compaction later. The TabletMetadata object is no longer refrenced by this class after the constructor returns. So this class will use much less memory on the queue for the case when tablet have lots of files. 2. Eventually when a compactor requested a job it would yank a ResolvedCompactionJob off the queue. 3. All of the complex analysis to determine if a compaction can start is now done in the conditional mutation instead of in the coordinator. To enable this, new functionality was added to Ample including the new TabletMetadataCheck interface, TabletMetadataCheckIterator, and the CompactionReservationCheck class. With these changes its now super easy to write a conditional check that will do arbitrary analysis of TabletMetadata prior to committing a mutation. 4. Since the analysis is done in the conditional mutation there is no longer a need to retry. If the mutation fails then we know the compaction can not run. The following were some supporting changes that had to be made. * Took methods for encoding KeyExtent as base64 from TabletManagementParameters and moved the KeyExtent because this was needed in the new TabletMetadataCheckIterator. * Move TabletMetadata out of the compaction queues, which made those more independent but was a big change. The main change here is that instead of adding `TabletMetadata, List<CompactionJob>` to the compaction queue now `KeyExtent, List<CompactionJob>` is added. This required changing the test for these classes and the code that interacts with them in CompactionCoordinator creating lots of diff. * Moved CompactionCoordinatorTest.testCanReserve() to CompactionReservationCheckTest.testCanReserve() and changed the code to work with the new CompactionReservationCheck class. These are test of the complex logic that used to run in the coordinator and now runs in the tablet server as part of a conditional mutation. * Removed conditional checks from Ample related to compactions that were no longer used after these changes. There was code for requiring a set of files not not be compacting. The new TabletMetadataCheck functionality of ample could be used to simplify other conditional mutation checks of tablet metadata. It made the compaction reservation code much simpler and easier to understand. This code could be further improved if apache#5244 were implemented.
- Loading branch information
1 parent
7701e59
commit 1b4c876
Showing
29 changed files
with
1,151 additions
and
857 deletions.
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
57 changes: 57 additions & 0 deletions
57
core/src/main/java/org/apache/accumulo/core/metadata/schema/TabletMetadataCheck.java
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 |
---|---|---|
@@ -0,0 +1,57 @@ | ||
/* | ||
* 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.core.metadata.schema; | ||
|
||
import java.util.Collections; | ||
import java.util.EnumSet; | ||
import java.util.Set; | ||
|
||
/** | ||
* This interface facilitates atomic checks of tablet metadata prior to updating tablet metadata. | ||
* The way it is intended to be used is the following. | ||
* <ol> | ||
* <li>On the client side a TabletMetadataCheck object is created and passed to Ample</li> | ||
* <li>Ample uses Gson to serialize the object, so it must not reference anything that can not | ||
* serialize. Also it should not reference big things like server context or the Manager, it should | ||
* only reference a small amount of data needed for the check. | ||
* <li>On the tablet server side, as part of conditional mutation processing, this class is | ||
* recreated and the {@link #canUpdate(TabletMetadata)} method is called and if it returns true the | ||
* conditional mutation will go through.</li> | ||
* </ol> | ||
* | ||
* <p> | ||
* Implementations are expected to have a no arg constructor. | ||
* </p> | ||
* | ||
*/ | ||
public interface TabletMetadataCheck { | ||
|
||
Set<TabletMetadata.ColumnType> ALL_COLUMNS = | ||
Collections.unmodifiableSet(EnumSet.noneOf(TabletMetadata.ColumnType.class)); | ||
|
||
boolean canUpdate(TabletMetadata tabletMetadata); | ||
|
||
/** | ||
* Determines what tablet metadata columns are read on the server side. Return the empty set to | ||
* read all tablet metadata columns. | ||
*/ | ||
default Set<TabletMetadata.ColumnType> columnsToRead() { | ||
return ALL_COLUMNS; | ||
} | ||
} |
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
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
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
Oops, something went wrong.