-
Notifications
You must be signed in to change notification settings - Fork 3.4k
HBASE-29463 Bidirectional serial replication will block if a region’s last edit before rs crashed was from the peer cluster #7172
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 all commits
Commits
Show all changes
3 commits
Select commit
Hold shift + click to select a range
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
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
66 changes: 66 additions & 0 deletions
66
hbase-server/src/main/java/org/apache/hadoop/hbase/replication/WALEntryFilterBase.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,66 @@ | ||
| /* | ||
| * 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.hadoop.hbase.replication; | ||
|
|
||
| import org.apache.hadoop.hbase.HBaseInterfaceAudience; | ||
| import org.apache.hadoop.hbase.wal.WAL.Entry; | ||
| import org.apache.yetus.audience.InterfaceAudience; | ||
|
|
||
| /** | ||
| * Base class for {@link WALEntryFilter}, store the necessary common properties like | ||
| * {@link #serial}. | ||
| * <p> | ||
| * Why need to treat serial replication specially: | ||
| * <p> | ||
| * Under some special cases, we may filter out some entries but we still need to record the last | ||
| * pushed sequence id for these entries. For example, when we setup a bidirection replication A | ||
| * <-> B, if we write to both cluster A and cluster B, cluster A will not replicate the | ||
| * entries which are replicated from cluster B, which means we may have holes in the replication | ||
| * sequence ids. So if the region is closed abnormally, i.e, we do not have a close event for the | ||
| * region, and before the closing, we have some entries from cluster B, then the replication from | ||
| * cluster A to cluster B will be stuck if we do not record the last pushed sequence id of these | ||
| * entries because we will find out that the previous sequence id range will never finish. So we | ||
| * need to record the sequence id for these entries so the last pushed sequence id can reach the | ||
| * region barrier. | ||
| * @see <a href="https://issues.apache.org/jira/browse/HBASE-29463">HBASE-29463</a> | ||
| */ | ||
| @InterfaceAudience.LimitedPrivate(HBaseInterfaceAudience.REPLICATION) | ||
| public abstract class WALEntryFilterBase implements WALEntryFilter { | ||
|
|
||
| protected boolean serial; | ||
|
|
||
| @Override | ||
| public void setSerial(boolean serial) { | ||
| this.serial = serial; | ||
| } | ||
|
|
||
| /** | ||
| * Call this method when you do not need to replicate the entry. | ||
| * <p> | ||
| * For serial replication, since still need to WALKey for recording progress, we clear all the | ||
| * cells of the WALEdit. For normal replication, we just return null. | ||
| */ | ||
| protected final Entry clearOrNull(Entry entry) { | ||
| if (serial) { | ||
| entry.getEdit().getCells().clear(); | ||
| return entry; | ||
| } else { | ||
| return null; | ||
| } | ||
| } | ||
| } | ||
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
79 changes: 79 additions & 0 deletions
79
.../test/java/org/apache/hadoop/hbase/replication/TestBidirectionSerialReplicationStuck.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,79 @@ | ||
| /* | ||
| * 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.hadoop.hbase.replication; | ||
|
|
||
| import org.apache.hadoop.hbase.HBaseClassTestRule; | ||
| import org.apache.hadoop.hbase.client.Get; | ||
| import org.apache.hadoop.hbase.client.Put; | ||
| import org.apache.hadoop.hbase.testclassification.LargeTests; | ||
| import org.apache.hadoop.hbase.testclassification.ReplicationTests; | ||
| import org.apache.hadoop.hbase.util.Bytes; | ||
| import org.junit.ClassRule; | ||
| import org.junit.Test; | ||
| import org.junit.experimental.categories.Category; | ||
|
|
||
| @Category({ ReplicationTests.class, LargeTests.class }) | ||
| public class TestBidirectionSerialReplicationStuck extends TestReplicationBase { | ||
|
|
||
| @ClassRule | ||
| public static final HBaseClassTestRule CLASS_RULE = | ||
| HBaseClassTestRule.forClass(TestBidirectionSerialReplicationStuck.class); | ||
|
|
||
| @Override | ||
| protected boolean isSerialPeer() { | ||
| return true; | ||
| } | ||
|
|
||
| @Override | ||
| public void setUpBase() throws Exception { | ||
| UTIL1.ensureSomeRegionServersAvailable(2); | ||
| hbaseAdmin.balancerSwitch(false, true); | ||
| addPeer(PEER_ID2, tableName, UTIL1, UTIL2); | ||
| addPeer(PEER_ID2, tableName, UTIL2, UTIL1); | ||
| } | ||
|
|
||
| @Override | ||
| public void tearDownBase() throws Exception { | ||
| removePeer(PEER_ID2, UTIL1); | ||
| removePeer(PEER_ID2, UTIL2); | ||
| } | ||
|
|
||
| @Test | ||
| public void testStuck() throws Exception { | ||
| // disable the peer cluster1 -> cluster2 | ||
| hbaseAdmin.disableReplicationPeer(PEER_ID2); | ||
| byte[] qualifier = Bytes.toBytes("q"); | ||
| htable1.put(new Put(Bytes.toBytes("aaa-1")).addColumn(famName, qualifier, Bytes.toBytes(1))); | ||
|
|
||
| // add a row to cluster2 and wait it replicate back to cluster1 | ||
| htable2.put(new Put(Bytes.toBytes("aaa-2")).addColumn(famName, qualifier, Bytes.toBytes(2))); | ||
| UTIL1.waitFor(30000, () -> htable1.exists(new Get(Bytes.toBytes("aaa-2")))); | ||
|
|
||
| // kill the region server which holds the region which contains our rows | ||
| UTIL1.getRSForFirstRegionInTable(tableName).abort("for testing"); | ||
| // wait until the region is online | ||
| UTIL1.waitFor(30000, () -> htable1.exists(new Get(Bytes.toBytes("aaa-2")))); | ||
|
|
||
| // put a new row in cluster1 | ||
| htable1.put(new Put(Bytes.toBytes("aaa-3")).addColumn(famName, qualifier, Bytes.toBytes(3))); | ||
|
|
||
| // enable peer cluster1 -> cluster2, the new row should be replicated to cluster2 | ||
| hbaseAdmin.enableReplicationPeer(PEER_ID2); | ||
| UTIL1.waitFor(30000, () -> htable2.exists(new Get(Bytes.toBytes("aaa-3")))); | ||
| } | ||
| } |
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
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.
Will normal replication handle correctly the case when the entry is non-null but the cells list is empty? I wonder if we can avoid having two contracts for the two types of replication. I also that that it's safer to avoid returning null objects when possible.
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.
The actual replication code for serial and none-serial replication are the same, where we will not replicate anything when there is no cell in WALEdit.
Returning null is by-design here, which means we can skip this entry. We need to change a bunch of code if we want to change this...
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.
Bummer. Okay, fair enough.