[ https://issues.apache.org/jira/browse/HBASE-8930?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13762419#comment-13762419 ]
Vasu Mariyala commented on HBASE-8930: -------------------------------------- {code} for (SchemaMetrics cfm : tableAndFamilyToMetrics.values()) { if (metricName.startsWith(CF_PREFIX + CF_PREFIX)) { throw new AssertionError("Column family prefix used twice: " + metricName); } {code} The above code throws an error when the metric name starts with "cf.cf.". It would be helpful if any one sheds some light on the reason behind checking for "cf.cf." The scenarios in which we would have a metric name start with "cf.cf." are as follows (See generateSchemaMetricsPrefix method of SchemaMetrics) a) The column family name should be "cf" AND b) The table name is either "" or use table name globally should be false (useTableNameGlobally variable of SchemaMetrics). Table name is empty only in the case of ALL_SCHEMA_METRICS which has the column family as "". So we could rule out the possibility of the table name being empty. Also to note, the variables "useTableNameGlobally" and "tableAndFamilyToMetrics" of SchemaMetrics are static and are shared across all the tests that run in a single jvm. In our case, the profile runAllTests has the below configuration {code} <surefire.firstPartForkMode>once</surefire.firstPartForkMode> <surefire.firstPartParallel>none</surefire.firstPartParallel> <surefire.firstPartThreadCount>1</surefire.firstPartThreadCount> <surefire.firstPartGroups>org.apache.hadoop.hbase.SmallTests</surefire.firstPartGroups> {code} Hence all of our small tests run in a single jvm and share the above variables "useTableNameGlobally" and "tableAndFamilyToMetrics". The reasons why the order of execution of the tests caused this failure are as follows a) A bunch of small tests like TestMemStore, TestSchemaConfiguredset set the useTableNameGlobally to false. But these tests don't create tables that have the column family name as "cf". b) If the tests in step (a) run before the tests which create table/regions with column family 'cf', metric names would start with "cf.cf." c) If any of other tests, like the failed tests(TestScannerSelectionUsingTTL, TestHFileReaderV1, TestScannerSelectionUsingKeyRange), validate schema metrics, they would fail as the metric names start with "cf.cf." On my local machine, I have tried to re-create the failure scenario by changing the sure fire test configuration and creating a simple (TestSimple) which just creates a region for the table 'testtable' and column family 'cf'. {code} TestSimple.java ------------------------------------------------------------------ @Before public void setUp() throws Exception { HTableDescriptor htd = new HTableDescriptor(TABLE_NAME_BYTES); htd.addFamily(new HColumnDescriptor(FAMILY_NAME_BYTES)); HRegionInfo info = new HRegionInfo(TABLE_NAME_BYTES, null, null, false); this.region = HRegion.createHRegion(info, TEST_UTIL.getDataTestDir(), TEST_UTIL.getConfiguration(), htd); Put put = new Put(ROW_BYTES); for (int i = 0; i < 10; i += 2) { // puts 0, 2, 4, 6 and 8 put.add(FAMILY_NAME_BYTES, Bytes.toBytes(QUALIFIER_PREFIX + i), i, Bytes.toBytes(VALUE_PREFIX + i)); } this.region.put(put); this.region.flushcache(); } @Test public void testFilterInvocation() throws Exception { System.out.println("testing"); } @After public void tearDown() throws Exception { HLog hlog = region.getLog(); region.close(); hlog.closeAndDelete(); } Successful run: ------------------------------------------------------- T E S T S ------------------------------------------------------- 2013-09-09 15:38:03.478 java[46562:db03] Unable to load realm mapping info from SCDynamicStore Running org.apache.hadoop.hbase.filter.TestSimple Tests run: 1, Failures: 0, Errors: 0, Skipped: 0, Time elapsed: 0.342 sec Running org.apache.hadoop.hbase.io.hfile.TestHFileReaderV1 Tests run: 1, Failures: 0, Errors: 0, Skipped: 0, Time elapsed: 0.085 sec Running org.apache.hadoop.hbase.io.hfile.TestScannerSelectionUsingKeyRange Tests run: 3, Failures: 0, Errors: 0, Skipped: 0, Time elapsed: 0.217 sec Running org.apache.hadoop.hbase.io.hfile.TestScannerSelectionUsingTTL Tests run: 6, Failures: 0, Errors: 0, Skipped: 0, Time elapsed: 12.618 sec Running org.apache.hadoop.hbase.regionserver.TestMemStore Tests run: 24, Failures: 0, Errors: 0, Skipped: 0, Time elapsed: 26.542 sec Results : Tests run: 35, Failures: 0, Errors: 0, Skipped: 0 ------------------------------------------------------------------ Failed run order: ------------------------------------------------------- T E S T S ------------------------------------------------------- 2013-09-09 15:43:21.466 java[46890:db03] Unable to load realm mapping info from SCDynamicStore Running org.apache.hadoop.hbase.regionserver.TestMemStore Tests run: 24, Failures: 0, Errors: 0, Skipped: 0, Time elapsed: 11.967 sec Running org.apache.hadoop.hbase.io.hfile.TestScannerSelectionUsingTTL Tests run: 6, Failures: 0, Errors: 0, Skipped: 0, Time elapsed: 12.659 sec Running org.apache.hadoop.hbase.io.hfile.TestScannerSelectionUsingKeyRange Tests run: 3, Failures: 0, Errors: 0, Skipped: 0, Time elapsed: 0.15 sec Running org.apache.hadoop.hbase.filter.TestSimple Tests run: 1, Failures: 0, Errors: 0, Skipped: 0, Time elapsed: 0.031 sec Running org.apache.hadoop.hbase.io.hfile.TestHFileReaderV1 Tests run: 1, Failures: 1, Errors: 0, Skipped: 0, Time elapsed: 24.883 sec <<< FAILURE! Results : Failed tests: testReadingExistingVersion1HFile(org.apache.hadoop.hbase.io.hfile.TestHFileReaderV1): Column family prefix used twice: cf.cf.bt.Data.fsReadnumops Tests run: 35, Failures: 1, Errors: 0, Skipped: 0 [INFO] ------------------------------------------------------------------------ [INFO] BUILD FAILURE [INFO] ------------------------------------------------------------------------ {code} In the failed scenario, the below has happened a) TestMemStore sets the useTableNameGlobally to false b) TestScannerSelectionUsingKeyRange, TestScannerSelectionUsingKeyRange are successful as they don't create table with column family name "cf" c) TestSimple creates a region for table 'testtable' and column family 'cf'. Since useTableNameGlobally is set to false, it would create metric names that start with "cf.cf." d) TestHFileReaderV1 while validating metrics would fail as the metric names start with "cf.cf." The reason why this has been exposed due to this patch is because TestSimple is TestInvocationRecordFilter. The executions of the build 1136, 1137 and 1138 which have been executed after this patch have a different order of executions when compared to the failed builds 1139 & 1140. One simple fix to address the issue would have been to change the column family name from "cf" to "mycf" in the TestInvocationRecordFilter. But to avoid future occurrences of these issues, I would suggest setting the "surefire.firstPartForkMode" to "always" similar to the settings we use while running localTests, medium & large tests. > Filter evaluates KVs outside requested columns > ---------------------------------------------- > > Key: HBASE-8930 > URL: https://issues.apache.org/jira/browse/HBASE-8930 > Project: HBase > Issue Type: Bug > Components: Filters > Affects Versions: 0.94.7 > Reporter: Federico Gaule > Assignee: Vasu Mariyala > Priority: Critical > Labels: filters, hbase, keyvalue > Fix For: 0.98.0, 0.94.13, 0.96.1 > > Attachments: 0.94-HBASE-8930.patch, 0.94-HBASE-8930-rev1.patch, > 0.95-HBASE-8930.patch, 0.95-HBASE-8930-rev1.patch, > 0.96-HBASE-8930-rev2.patch, 8930-0.94.txt, HBASE-8930.patch, > HBASE-8930-rev1.patch, HBASE-8930-rev2.patch, HBASE-8930-rev3.patch, > HBASE-8930-rev4.patch, HBASE-8930-rev5.patch > > > 1- Fill row with some columns > 2- Get row with some columns less than universe - Use filter to print kvs > 3- Filter prints not requested columns > Filter (AllwaysNextColFilter) always return ReturnCode.INCLUDE_AND_NEXT_COL > and prints KV's qualifier > SUFFIX_0 = 0 > SUFFIX_1 = 1 > SUFFIX_4 = 4 > SUFFIX_6 = 6 > P= Persisted > R= Requested > E= Evaluated > X= Returned > | 5580 | 5581 | 5584 | 5586 | 5590 | 5591 | 5594 | 5596 | 5600 | 5601 | 5604 > | 5606 |... > | | P | P | | | P | P | | | P | P > | |... > | | R | R | R | | R | R | R | | | > | |... > | | E | E | | | E | E | | | > {color:red}E{color} | | |... > | | X | X | | | X | X | | | | > | | > {code:title=ExtraColumnTest.java|borderStyle=solid} > @Test > public void testFilter() throws Exception { > Configuration config = HBaseConfiguration.create(); > config.set("hbase.zookeeper.quorum", "myZK"); > HTable hTable = new HTable(config, "testTable"); > byte[] cf = Bytes.toBytes("cf"); > byte[] row = Bytes.toBytes("row"); > byte[] col1 = new QualifierConverter().objectToByteArray(new > Qualifier((short) 558, (byte) SUFFIX_1)); > byte[] col2 = new QualifierConverter().objectToByteArray(new > Qualifier((short) 559, (byte) SUFFIX_1)); > byte[] col3 = new QualifierConverter().objectToByteArray(new > Qualifier((short) 560, (byte) SUFFIX_1)); > byte[] col4 = new QualifierConverter().objectToByteArray(new > Qualifier((short) 561, (byte) SUFFIX_1)); > byte[] col5 = new QualifierConverter().objectToByteArray(new > Qualifier((short) 562, (byte) SUFFIX_1)); > byte[] col6 = new QualifierConverter().objectToByteArray(new > Qualifier((short) 563, (byte) SUFFIX_1)); > byte[] col1g = new QualifierConverter().objectToByteArray(new > Qualifier((short) 558, (byte) SUFFIX_6)); > byte[] col2g = new QualifierConverter().objectToByteArray(new > Qualifier((short) 559, (byte) SUFFIX_6)); > byte[] col1v = new QualifierConverter().objectToByteArray(new > Qualifier((short) 558, (byte) SUFFIX_4)); > byte[] col2v = new QualifierConverter().objectToByteArray(new > Qualifier((short) 559, (byte) SUFFIX_4)); > byte[] col3v = new QualifierConverter().objectToByteArray(new > Qualifier((short) 560, (byte) SUFFIX_4)); > byte[] col4v = new QualifierConverter().objectToByteArray(new > Qualifier((short) 561, (byte) SUFFIX_4)); > byte[] col5v = new QualifierConverter().objectToByteArray(new > Qualifier((short) 562, (byte) SUFFIX_4)); > byte[] col6v = new QualifierConverter().objectToByteArray(new > Qualifier((short) 563, (byte) SUFFIX_4)); > // =========== INSERTION =============// > Put put = new Put(row); > put.add(cf, col1, Bytes.toBytes((short) 1)); > put.add(cf, col2, Bytes.toBytes((short) 1)); > put.add(cf, col3, Bytes.toBytes((short) 3)); > put.add(cf, col4, Bytes.toBytes((short) 3)); > put.add(cf, col5, Bytes.toBytes((short) 3)); > put.add(cf, col6, Bytes.toBytes((short) 3)); > hTable.put(put); > put = new Put(row); > put.add(cf, col1v, Bytes.toBytes((short) 10)); > put.add(cf, col2v, Bytes.toBytes((short) 10)); > put.add(cf, col3v, Bytes.toBytes((short) 10)); > put.add(cf, col4v, Bytes.toBytes((short) 10)); > put.add(cf, col5v, Bytes.toBytes((short) 10)); > put.add(cf, col6v, Bytes.toBytes((short) 10)); > hTable.put(put); > hTable.flushCommits(); > //==============READING=================// > Filter allwaysNextColFilter = new AllwaysNextColFilter(); > Get get = new Get(row); > get.addColumn(cf, col1); //5581 > get.addColumn(cf, col1v); //5584 > get.addColumn(cf, col1g); //5586 > get.addColumn(cf, col2); //5591 > get.addColumn(cf, col2v); //5594 > get.addColumn(cf, col2g); //5596 > > get.setFilter(allwaysNextColFilter); > get.setMaxVersions(1); > System.out.println(get); > Scan scan = new Scan(get); > ResultScanner scanner = hTable.getScanner(scan); > Iterator<Result> iterator = scanner.iterator(); > System.out.println("SCAN"); > while (iterator.hasNext()) { > Result next = iterator.next(); > for (KeyValue kv : next.list()) { > System.out.println(new > QualifierConverter().byteArrayToObject(kv.getQualifier())); > } > } > } > } > {code} > Requested 5581 5584 5586 5591 5594 5596 > NOT REQUESTED: 5561 > Sysout Filter > {noformat} > \x00\x00\x1A\xBE\x00\x05^:\x00\x00\xA0X\x00\x00=\x1A/H0:\x02.\x01/1373577819267/Put/vlen=2/ts=2 > Qualifier{date=558, type=SUFFIX_1} > \x00\x00\x1A\xBE\x00\x05^:\x00\x00\xA0X\x00\x00=\x1A/H0:\x02.\x02/1373577819272/Put/vlen=2/ts=3 > Qualifier{date=558, type=SUFFIX_4} > \x00\x00\x1A\xBE\x00\x05^:\x00\x00\xA0X\x00\x00=\x1A/H0:\x02/\x01/1373577819267/Put/vlen=2/ts=2 > ualifier{date=559, type=SUFFIX_1} > \x00\x00\x1A\xBE\x00\x05^:\x00\x00\xA0X\x00\x00=\x1A/H0:\x02/\x02/1373577819272/Put/vlen=2/ts=3 > Qualifier{date=559, type=SUFFIX_4} > > \x00\x00\x1A\xBE\x00\x05^:\x00\x00\xA0X\x00\x00=\x1A/H0:\x020\x01/1373577819267/Put/vlen=2/ts=2 > Qualifier{date=560, type=SUFFIX_1} (DATE 5601 NOT REQUESTED BUT EVALUATED) > {noformat} > Sysout ExtraColumnTest > {noformat} > {"timeRange":[0,9223372036854775807],"totalColumns":6,"cacheBlocks":true,"families":{"H0":["\\x02.\\x01","\\x02.\\x02","\\x02.\\x06","\\x02/\\x01"]},"maxVersions":1,"filter":"AllwaysNextColFilter","row":"\\x00\\x00\\x1A\\xBE\\x00\\x05^:\\x00\\x00\\xA0X\\x00\\x00=\\x1A"} > SCAN > Qualifier{date=558, type=SUFFIX_1} > Qualifier{date=558, type=SUFFIX_4} > Qualifier{date=559, type=SUFFIX_1} > Qualifier{date=559, type=SUFFIX_4} > {noformat} -- This message is automatically generated by JIRA. If you think it was sent incorrectly, please contact your JIRA administrators For more information on JIRA, see: http://www.atlassian.com/software/jira