-
Notifications
You must be signed in to change notification settings - Fork 3.4k
HBASE-25994 Active WAL tailing fails when WAL value compression is enabled #3377
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
6 commits
Select commit
Hold shift + click to select a range
fd21d8b
HBASE-25994 Active WAL tailing fails when WAL value compression is en…
apurtell c2a3a90
Remove unused import
apurtell 380a7e7
Reduce test running times so the MediumTest annotation is proper
apurtell 5919d21
Just ignore the lower stream's available() in BoundedDelegatingInputS…
apurtell ec6eecd
Update javadoc and add comment
apurtell 2618906
Fix whitespace
apurtell 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
108 changes: 108 additions & 0 deletions
108
...t/java/org/apache/hadoop/hbase/replication/regionserver/TestReplicationCompressedWAL.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,108 @@ | ||
| /** | ||
| * 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.regionserver; | ||
|
|
||
| import static org.junit.Assert.assertArrayEquals; | ||
| import static org.junit.Assert.fail; | ||
|
|
||
| import java.io.IOException; | ||
|
|
||
| import org.apache.hadoop.hbase.HBaseClassTestRule; | ||
| import org.apache.hadoop.hbase.HConstants; | ||
| import org.apache.hadoop.hbase.client.Get; | ||
| import org.apache.hadoop.hbase.client.Put; | ||
| import org.apache.hadoop.hbase.client.Result; | ||
| import org.apache.hadoop.hbase.replication.TestReplicationBase; | ||
| import org.apache.hadoop.hbase.testclassification.MediumTests; | ||
| import org.apache.hadoop.hbase.util.Bytes; | ||
| import org.junit.AfterClass; | ||
| import org.junit.BeforeClass; | ||
| import org.junit.ClassRule; | ||
| import org.junit.Test; | ||
| import org.junit.experimental.categories.Category; | ||
| import org.slf4j.Logger; | ||
| import org.slf4j.LoggerFactory; | ||
|
|
||
| @Category(MediumTests.class) | ||
| public class TestReplicationCompressedWAL extends TestReplicationBase { | ||
|
|
||
| @ClassRule | ||
| public static final HBaseClassTestRule CLASS_RULE = | ||
| HBaseClassTestRule.forClass(TestReplicationCompressedWAL.class); | ||
|
|
||
| static final Logger LOG = LoggerFactory.getLogger(TestReplicationCompressedWAL.class); | ||
| static final int NUM_BATCHES = 20; | ||
| static final int NUM_ROWS_PER_BATCH = 100; | ||
|
|
||
| @BeforeClass | ||
| public static void setUpBeforeClass() throws Exception { | ||
| CONF1.setBoolean(HConstants.ENABLE_WAL_COMPRESSION, true); | ||
| TestReplicationBase.setUpBeforeClass(); | ||
| } | ||
|
|
||
| @AfterClass | ||
| public static void tearDownAfterClass() throws Exception { | ||
| TestReplicationBase.tearDownAfterClass(); | ||
| } | ||
|
|
||
| @Test | ||
| public void testMultiplePuts() throws Exception { | ||
| runMultiplePutTest(); | ||
| } | ||
|
|
||
| protected static void runMultiplePutTest() throws IOException, InterruptedException { | ||
| for (int i = 0; i < NUM_BATCHES; i++) { | ||
| putBatch(i); | ||
| getBatch(i); | ||
| } | ||
| } | ||
|
|
||
| protected static void getBatch(int batch) throws IOException, InterruptedException { | ||
| for (int i = 0; i < NUM_ROWS_PER_BATCH; i++) { | ||
| byte[] row = getRowKey(batch, i); | ||
| Get get = new Get(row); | ||
| for (int j = 0; j < NB_RETRIES; j++) { | ||
| if (j == NB_RETRIES - 1) { | ||
| fail("Waited too much time for replication"); | ||
| } | ||
| Result res = htable2.get(get); | ||
| if (res.isEmpty()) { | ||
| LOG.info("Row not available"); | ||
| Thread.sleep(SLEEP_TIME); | ||
| } else { | ||
| assertArrayEquals(row, res.value()); | ||
| break; | ||
| } | ||
| } | ||
| } | ||
| } | ||
|
|
||
| protected static byte[] getRowKey(int batch, int count) { | ||
| return Bytes.toBytes("row" + ((batch * NUM_ROWS_PER_BATCH) + count)); | ||
| } | ||
|
|
||
| protected static void putBatch(int batch) throws IOException { | ||
| for (int i = 0; i < NUM_ROWS_PER_BATCH; i++) { | ||
| byte[] row = getRowKey(batch, i); | ||
| Put put = new Put(row); | ||
| put.addColumn(famName, row, row); | ||
| htable1.put(put); | ||
| } | ||
| } | ||
|
|
||
| } |
59 changes: 59 additions & 0 deletions
59
...a/org/apache/hadoop/hbase/replication/regionserver/TestReplicationValueCompressedWAL.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,59 @@ | ||
| /** | ||
| * 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.regionserver; | ||
|
|
||
| import org.apache.hadoop.hbase.HBaseClassTestRule; | ||
| import org.apache.hadoop.hbase.HConstants; | ||
| import org.apache.hadoop.hbase.regionserver.wal.CompressionContext; | ||
| import org.apache.hadoop.hbase.replication.TestReplicationBase; | ||
| import org.apache.hadoop.hbase.testclassification.MediumTests; | ||
| import org.junit.AfterClass; | ||
| import org.junit.BeforeClass; | ||
| import org.junit.ClassRule; | ||
| import org.junit.Test; | ||
| import org.junit.experimental.categories.Category; | ||
| import org.slf4j.Logger; | ||
| import org.slf4j.LoggerFactory; | ||
|
|
||
| @Category(MediumTests.class) | ||
| public class TestReplicationValueCompressedWAL extends TestReplicationBase { | ||
|
|
||
| @ClassRule | ||
| public static final HBaseClassTestRule CLASS_RULE = | ||
| HBaseClassTestRule.forClass(TestReplicationValueCompressedWAL.class); | ||
|
|
||
| static final Logger LOG = LoggerFactory.getLogger(TestReplicationValueCompressedWAL.class); | ||
|
|
||
| @BeforeClass | ||
| public static void setUpBeforeClass() throws Exception { | ||
| CONF1.setBoolean(HConstants.ENABLE_WAL_COMPRESSION, true); | ||
| CONF1.setBoolean(CompressionContext.ENABLE_WAL_VALUE_COMPRESSION, true); | ||
| TestReplicationBase.setUpBeforeClass(); | ||
| } | ||
|
|
||
| @AfterClass | ||
| public static void tearDownAfterClass() throws Exception { | ||
| TestReplicationBase.tearDownAfterClass(); | ||
| } | ||
|
|
||
| @Test | ||
| public void testMultiplePuts() throws Exception { | ||
| TestReplicationCompressedWAL.runMultiplePutTest(); | ||
| } | ||
|
|
||
| } |
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.
Ya, something like this in a wrapping input stream is what I had in my mind but doing this in BoundedDelegatingInputStream is even more elegant and clean..
nit: Looks like javadoc needs updation..
I think this behavior is very subtle and not obvious, would be great to back it up with a small comment and how tailing reads depend on it..