-
Notifications
You must be signed in to change notification settings - Fork 1k
PHOENIX-7863 Add replication consistency point guard to compaction #2489
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
Open
Himanshu-g81
wants to merge
8
commits into
apache:PHOENIX-7562-feature-new
Choose a base branch
from
Himanshu-g81:PHOENIX-7863
base: PHOENIX-7562-feature-new
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
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 all commits
Commits
Show all changes
8 commits
Select commit
Hold shift + click to select a range
80a356b
PHOENIX-7863 Add replication consistency point guard to compaction
601debd
PHOENIX-7863 Move compaction guard logic to ReplicationLogReplayService
2b54278
PHOENIX-7863 Revert getConsistencyPoint visibility to protected
6404215
PHOENIX-7863 Move guard config constants to ReplicationLogReplayService
28108c9
PHOENIX-7863 Apply spotless formatting
01f14ca
PHOENIX-7863 Fix visibility and capacity hints from review
fbf7a3d
PHOENIX-7863 Address review: row-level guard, caching, visibility fixes
f879b51
PHOENIX-7863 Add cache test for consistency point resolution
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
147 changes: 147 additions & 0 deletions
147
...c/it/java/org/apache/phoenix/replication/reader/CompactionReplicationGuardDisabledIT.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,147 @@ | ||
| /* | ||
| * 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 | ||
| * | ||
| * http://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.phoenix.replication.reader; | ||
|
|
||
| import static org.apache.phoenix.coprocessorclient.BaseScannerRegionObserverConstants.PHOENIX_MAX_LOOKBACK_AGE_CONF_KEY; | ||
| import static org.apache.phoenix.util.TestUtil.assertRawRowCount; | ||
| import static org.junit.Assert.assertFalse; | ||
|
|
||
| import java.io.IOException; | ||
| import java.sql.Connection; | ||
| import java.sql.DriverManager; | ||
| import java.sql.SQLException; | ||
| import java.util.Map; | ||
| import org.apache.hadoop.hbase.TableName; | ||
| import org.apache.phoenix.end2end.NeedsOwnMiniClusterTest; | ||
| import org.apache.phoenix.query.BaseTest; | ||
| import org.apache.phoenix.query.QueryServices; | ||
| import org.apache.phoenix.util.EnvironmentEdgeManager; | ||
| import org.apache.phoenix.util.ManualEnvironmentEdge; | ||
| import org.apache.phoenix.util.ReadOnlyProps; | ||
| import org.apache.phoenix.util.TestUtil; | ||
| import org.junit.After; | ||
| import org.junit.Before; | ||
| import org.junit.BeforeClass; | ||
| import org.junit.Test; | ||
| import org.junit.experimental.categories.Category; | ||
|
|
||
| import org.apache.phoenix.thirdparty.com.google.common.collect.Maps; | ||
|
|
||
| /** | ||
| * Integration test verifying that the replication compaction guard does NOT interfere with normal | ||
| * compaction when explicitly disabled via configuration. | ||
| */ | ||
| @Category(NeedsOwnMiniClusterTest.class) | ||
| public class CompactionReplicationGuardDisabledIT extends BaseTest { | ||
|
|
||
| private static final int MAX_LOOKBACK_AGE = 15; | ||
| private static final int ROWS_POPULATED = 2; | ||
| private ManualEnvironmentEdge injectEdge; | ||
|
|
||
| @BeforeClass | ||
| public static synchronized void doSetup() throws Exception { | ||
| Map<String, String> props = Maps.newHashMapWithExpectedSize(5); | ||
| props.put(PHOENIX_MAX_LOOKBACK_AGE_CONF_KEY, Integer.toString(MAX_LOOKBACK_AGE)); | ||
| props.put(QueryServices.PHOENIX_COMPACTION_ENABLED, Boolean.toString(true)); | ||
| props.put(ReplicationLogReplayService.PHOENIX_REPLICATION_REPLAY_ENABLED, | ||
| Boolean.toString(true)); | ||
| props.put(ReplicationLogReplayService.REPLICATION_COMPACTION_GUARD_ENABLED, | ||
| Boolean.toString(false)); | ||
| props.put("hbase.procedure.remote.dispatcher.delay.msec", "0"); | ||
| setUpTestDriver(new ReadOnlyProps(props.entrySet().iterator())); | ||
| } | ||
|
|
||
| @Before | ||
| public void beforeTest() throws Exception { | ||
| EnvironmentEdgeManager.reset(); | ||
| injectEdge = new ManualEnvironmentEdge(); | ||
| injectEdge.setValue(System.currentTimeMillis()); | ||
| EnvironmentEdgeManager.injectEdge(injectEdge); | ||
| } | ||
|
|
||
| @After | ||
| public synchronized void afterTest() throws Exception { | ||
| ReplicationLogReplayService.resetInstanceForTesting(); | ||
| EnvironmentEdgeManager.reset(); | ||
| boolean refCountLeaked = isAnyStoreRefCountLeaked(); | ||
| assertFalse("refCount leaked", refCountLeaked); | ||
| } | ||
|
|
||
| /** | ||
| * When guard is disabled, delete markers are purged normally by maxLookback even though the | ||
| * consistency point would have protected them if the guard were enabled. | ||
| */ | ||
| @Test(timeout = 120000L) | ||
| public void testGuardDisabledDeleteMarkersPurgedByMaxLookback() throws Exception { | ||
| try (Connection conn = DriverManager.getConnection(getUrl())) { | ||
| String dataTableName = generateUniqueName(); | ||
| createTable(dataTableName); | ||
| TableName dataTable = TableName.valueOf(dataTableName); | ||
| populateTable(dataTableName); | ||
|
|
||
| injectEdge.incrementValue(1); | ||
| long beforeDeleteTime = EnvironmentEdgeManager.currentTimeMillis(); | ||
|
|
||
| // Delete a row | ||
| conn.createStatement().execute("DELETE FROM " + dataTableName + " WHERE id = 'a'"); | ||
| conn.commit(); | ||
| injectEdge.incrementValue(1); | ||
|
|
||
| // Set consistency point BEFORE delete — guard would retain if enabled | ||
| long consistencyPoint = beforeDeleteTime - 1; | ||
| ReplicationLogReplayService.setConsistencyPointForTesting(consistencyPoint); | ||
|
|
||
| // Advance past maxLookback | ||
| injectEdge.incrementValue(MAX_LOOKBACK_AGE * 1000 + 1000); | ||
|
|
||
| flush(dataTable); | ||
| majorCompact(dataTable); | ||
|
|
||
| // Guard disabled — delete marker purged by maxLookback as normal | ||
| assertRawRowCount(conn, dataTable, ROWS_POPULATED - 1); | ||
| } | ||
| } | ||
|
|
||
| private void flush(TableName table) throws IOException { | ||
| getUtility().getAdmin().flush(table); | ||
| } | ||
|
|
||
| private void majorCompact(TableName table) throws Exception { | ||
| TestUtil.majorCompact(getUtility(), table); | ||
| } | ||
|
|
||
| private void createTable(String tableName) throws SQLException { | ||
| try (Connection conn = DriverManager.getConnection(getUrl())) { | ||
| conn.createStatement().execute( | ||
| "CREATE TABLE " + tableName + " (id VARCHAR(10) NOT NULL PRIMARY KEY, val1 VARCHAR(10)," | ||
| + " val2 VARCHAR(10), val3 VARCHAR(10))"); | ||
| conn.commit(); | ||
| } | ||
| } | ||
|
|
||
| private void populateTable(String tableName) throws SQLException { | ||
| try (Connection conn = DriverManager.getConnection(getUrl())) { | ||
| conn.createStatement() | ||
| .execute("UPSERT INTO " + tableName + " VALUES ('a', 'ab', 'abc', 'abcd')"); | ||
| conn.commit(); | ||
| conn.createStatement() | ||
| .execute("UPSERT INTO " + tableName + " VALUES ('b', 'bc', 'bcd', 'bcde')"); | ||
| conn.commit(); | ||
| } | ||
| } | ||
| } |
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.
I commented on this elsewhere, but Claude called this a "foot gun", lol.