phoenix git commit: PHOENIX-4534 upsert/delete/upsert for the same row corrupts the indexes
Repository: phoenix Updated Branches: refs/heads/master 9566c78bd -> 0bcb872ba PHOENIX-4534 upsert/delete/upsert for the same row corrupts the indexes Project: http://git-wip-us.apache.org/repos/asf/phoenix/repo Commit: http://git-wip-us.apache.org/repos/asf/phoenix/commit/0bcb872b Tree: http://git-wip-us.apache.org/repos/asf/phoenix/tree/0bcb872b Diff: http://git-wip-us.apache.org/repos/asf/phoenix/diff/0bcb872b Branch: refs/heads/master Commit: 0bcb872ba7bb74e3131a339440e38f9689471388 Parents: 9566c78 Author: Rajeshbabu Chintaguntla Authored: Thu May 10 10:25:38 2018 -0700 Committer: ss77892 Committed: Thu May 10 10:29:59 2018 -0700 -- .../phoenix/end2end/index/MutableIndexIT.java | 41 .../filter/ApplyAndFilterDeletesFilter.java | 7 .../index/scanner/FilteredKeyValueScanner.java | 7 +++- 3 files changed, 47 insertions(+), 8 deletions(-) -- http://git-wip-us.apache.org/repos/asf/phoenix/blob/0bcb872b/phoenix-core/src/it/java/org/apache/phoenix/end2end/index/MutableIndexIT.java -- diff --git a/phoenix-core/src/it/java/org/apache/phoenix/end2end/index/MutableIndexIT.java b/phoenix-core/src/it/java/org/apache/phoenix/end2end/index/MutableIndexIT.java index e968e99..cfaed72 100644 --- a/phoenix-core/src/it/java/org/apache/phoenix/end2end/index/MutableIndexIT.java +++ b/phoenix-core/src/it/java/org/apache/phoenix/end2end/index/MutableIndexIT.java @@ -910,6 +910,47 @@ public class MutableIndexIT extends ParallelStatsDisabledIT { } } + + @Test + public void testUpsertingDeletedRowShouldGiveProperDataWithIndexes() throws Exception { + testUpsertingDeletedRowShouldGiveProperDataWithIndexes(false); + } + + @Test + public void testUpsertingDeletedRowShouldGiveProperDataWithMultiCFIndexes() throws Exception { + testUpsertingDeletedRowShouldGiveProperDataWithIndexes(true); + } + + private void testUpsertingDeletedRowShouldGiveProperDataWithIndexes(boolean multiCf) throws Exception { + String tableName = "TBL_" + generateUniqueName(); + String indexName = "IDX_" + generateUniqueName(); + String columnFamily1 = "cf1"; + String columnFamily2 = "cf2"; + String fullTableName = SchemaUtil.getTableName(TestUtil.DEFAULT_SCHEMA_NAME, tableName); + try (Connection conn = getConnection()) { +conn.createStatement().execute( +"create table " + fullTableName + " (id integer primary key, " ++ (multiCf ? columnFamily1 : "") + "f float, " ++ (multiCf ? columnFamily2 : "") + "s varchar)" + tableDDLOptions); +conn.createStatement().execute( +"create index " + indexName + " on " + fullTableName + " (" ++ (multiCf ? columnFamily1 : "") + "f) include ("+(multiCf ? columnFamily2 : "") +"s)"); +conn.createStatement().execute( +"upsert into " + fullTableName + " values (1, 0.5, 'foo')"); + conn.commit(); + conn.createStatement().execute("delete from " + fullTableName + " where id = 1"); + conn.commit(); +conn.createStatement().execute( +"upsert into " + fullTableName + " values (1, 0.5, 'foo')"); + conn.commit(); + ResultSet rs = conn.createStatement().executeQuery("select * from "+indexName); + assertTrue(rs.next()); + assertEquals(1, rs.getInt(2)); + assertEquals(0.5F, rs.getFloat(1), 0.0); + assertEquals("foo", rs.getString(3)); + } + } + private void upsertRow(String dml, Connection tenantConn, int i) throws SQLException { PreparedStatement stmt = tenantConn.prepareStatement(dml); stmt.setString(1, "00" + String.valueOf(i)); http://git-wip-us.apache.org/repos/asf/phoenix/blob/0bcb872b/phoenix-core/src/main/java/org/apache/phoenix/hbase/index/covered/filter/ApplyAndFilterDeletesFilter.java -- diff --git a/phoenix-core/src/main/java/org/apache/phoenix/hbase/index/covered/filter/ApplyAndFilterDeletesFilter.java b/phoenix-core/src/main/java/org/apache/phoenix/hbase/index/covered/filter/ApplyAndFilterDeletesFilter.java index 17779ba..2e9878d 100644 --- a/phoenix-core/src/main/java/org/apache/phoenix/hbase/index/covered/filter/ApplyAndFilterDeletesFilter.java +++ b/phoenix-core/src/main/java/org/apache/phoenix/hbase/index/covered/filter/ApplyAndFilterDeletesFilter.java @@ -105,11 +105,6 @@ public class ApplyAndFilterDeletesFilter extends FilterBase { @Override public ReturnCode filterKeyValue(Cell next) { -// we marked ourselves done, but the END_ROW_KEY didn't manage to seek to the very last key -if (this.done) { - return ReturnCode.
phoenix git commit: PHOENIX-4534 upsert/delete/upsert for the same row corrupts the indexes-addendum(Rajeshbabu)
Repository: phoenix Updated Branches: refs/heads/master 6157c13ee -> 9566c78bd PHOENIX-4534 upsert/delete/upsert for the same row corrupts the indexes-addendum(Rajeshbabu) Project: http://git-wip-us.apache.org/repos/asf/phoenix/repo Commit: http://git-wip-us.apache.org/repos/asf/phoenix/commit/9566c78b Tree: http://git-wip-us.apache.org/repos/asf/phoenix/tree/9566c78b Diff: http://git-wip-us.apache.org/repos/asf/phoenix/diff/9566c78b Branch: refs/heads/master Commit: 9566c78bd8aaace54aaebf34171f0d837ad7c0b7 Parents: 6157c13 Author: Rajeshbabu Chintaguntla Authored: Thu Jan 25 17:58:40 2018 +0530 Committer: ss77892 Committed: Thu May 10 10:06:48 2018 -0700 -- .../hbase/index/covered/filter/ApplyAndFilterDeletesFilter.java | 1 - 1 file changed, 1 deletion(-) -- http://git-wip-us.apache.org/repos/asf/phoenix/blob/9566c78b/phoenix-core/src/main/java/org/apache/phoenix/hbase/index/covered/filter/ApplyAndFilterDeletesFilter.java -- diff --git a/phoenix-core/src/main/java/org/apache/phoenix/hbase/index/covered/filter/ApplyAndFilterDeletesFilter.java b/phoenix-core/src/main/java/org/apache/phoenix/hbase/index/covered/filter/ApplyAndFilterDeletesFilter.java index a1f01ed..17779ba 100644 --- a/phoenix-core/src/main/java/org/apache/phoenix/hbase/index/covered/filter/ApplyAndFilterDeletesFilter.java +++ b/phoenix-core/src/main/java/org/apache/phoenix/hbase/index/covered/filter/ApplyAndFilterDeletesFilter.java @@ -95,7 +95,6 @@ public class ApplyAndFilterDeletesFilter extends FilterBase { @Override public void reset(){ this.coveringDelete.reset(); -this.done = false; }
phoenix git commit: PHOENIX-4534 upsert/delete/upsert for the same row corrupts the indexes-addendum(Rajeshbabu)
Repository: phoenix Updated Branches: refs/heads/5.x-HBase-2.0 ab796a8f5 -> b5d0bd789 PHOENIX-4534 upsert/delete/upsert for the same row corrupts the indexes-addendum(Rajeshbabu) Project: http://git-wip-us.apache.org/repos/asf/phoenix/repo Commit: http://git-wip-us.apache.org/repos/asf/phoenix/commit/b5d0bd78 Tree: http://git-wip-us.apache.org/repos/asf/phoenix/tree/b5d0bd78 Diff: http://git-wip-us.apache.org/repos/asf/phoenix/diff/b5d0bd78 Branch: refs/heads/5.x-HBase-2.0 Commit: b5d0bd78994f3c7c585cfccc9b2537a6a088a783 Parents: ab796a8 Author: Rajeshbabu Chintaguntla Authored: Thu Jan 25 17:58:40 2018 +0530 Committer: Rajeshbabu Chintaguntla Committed: Thu Jan 25 17:58:40 2018 +0530 -- .../hbase/index/covered/filter/ApplyAndFilterDeletesFilter.java | 1 - 1 file changed, 1 deletion(-) -- http://git-wip-us.apache.org/repos/asf/phoenix/blob/b5d0bd78/phoenix-core/src/main/java/org/apache/phoenix/hbase/index/covered/filter/ApplyAndFilterDeletesFilter.java -- diff --git a/phoenix-core/src/main/java/org/apache/phoenix/hbase/index/covered/filter/ApplyAndFilterDeletesFilter.java b/phoenix-core/src/main/java/org/apache/phoenix/hbase/index/covered/filter/ApplyAndFilterDeletesFilter.java index 0fa9487..2a606c5 100644 --- a/phoenix-core/src/main/java/org/apache/phoenix/hbase/index/covered/filter/ApplyAndFilterDeletesFilter.java +++ b/phoenix-core/src/main/java/org/apache/phoenix/hbase/index/covered/filter/ApplyAndFilterDeletesFilter.java @@ -94,7 +94,6 @@ public class ApplyAndFilterDeletesFilter extends FilterBase { @Override public void reset(){ this.coveringDelete.reset(); -this.done = false; }
phoenix git commit: PHOENIX-4534 upsert/delete/upsert for the same row corrupts the indexes(Rajeshbabu)
Repository: phoenix Updated Branches: refs/heads/5.x-HBase-2.0 668c36ca6 -> d1b5fd528 PHOENIX-4534 upsert/delete/upsert for the same row corrupts the indexes(Rajeshbabu) Project: http://git-wip-us.apache.org/repos/asf/phoenix/repo Commit: http://git-wip-us.apache.org/repos/asf/phoenix/commit/d1b5fd52 Tree: http://git-wip-us.apache.org/repos/asf/phoenix/tree/d1b5fd52 Diff: http://git-wip-us.apache.org/repos/asf/phoenix/diff/d1b5fd52 Branch: refs/heads/5.x-HBase-2.0 Commit: d1b5fd52885aac904016b38aa5d1ece43b0053ab Parents: 668c36c Author: Rajeshbabu Chintaguntla Authored: Wed Jan 24 15:40:12 2018 +0530 Committer: Rajeshbabu Chintaguntla Committed: Wed Jan 24 15:40:12 2018 +0530 -- .../phoenix/end2end/index/MutableIndexIT.java | 41 .../filter/ApplyAndFilterDeletesFilter.java | 8 .../index/scanner/FilteredKeyValueScanner.java | 7 +++- 3 files changed, 47 insertions(+), 9 deletions(-) -- http://git-wip-us.apache.org/repos/asf/phoenix/blob/d1b5fd52/phoenix-core/src/it/java/org/apache/phoenix/end2end/index/MutableIndexIT.java -- diff --git a/phoenix-core/src/it/java/org/apache/phoenix/end2end/index/MutableIndexIT.java b/phoenix-core/src/it/java/org/apache/phoenix/end2end/index/MutableIndexIT.java index a931084..0fbb933 100644 --- a/phoenix-core/src/it/java/org/apache/phoenix/end2end/index/MutableIndexIT.java +++ b/phoenix-core/src/it/java/org/apache/phoenix/end2end/index/MutableIndexIT.java @@ -728,6 +728,47 @@ public class MutableIndexIT extends ParallelStatsDisabledIT { } } + + @Test + public void testUpsertingDeletedRowShouldGiveProperDataWithIndexes() throws Exception { + testUpsertingDeletedRowShouldGiveProperDataWithIndexes(false); + } + + @Test + public void testUpsertingDeletedRowShouldGiveProperDataWithMultiCFIndexes() throws Exception { + testUpsertingDeletedRowShouldGiveProperDataWithIndexes(true); + } + + private void testUpsertingDeletedRowShouldGiveProperDataWithIndexes(boolean multiCf) throws Exception { + String tableName = "TBL_" + generateUniqueName(); + String indexName = "IDX_" + generateUniqueName(); + String columnFamily1 = "cf1"; + String columnFamily2 = "cf2"; + String fullTableName = SchemaUtil.getTableName(TestUtil.DEFAULT_SCHEMA_NAME, tableName); + try (Connection conn = getConnection()) { +conn.createStatement().execute( +"create table " + fullTableName + " (id integer primary key, " ++ (multiCf ? columnFamily1 : "") + "f float, " ++ (multiCf ? columnFamily2 : "") + "s varchar)" + tableDDLOptions); +conn.createStatement().execute( +"create index " + indexName + " on " + fullTableName + " (" ++ (multiCf ? columnFamily1 : "") + "f) include ("+(multiCf ? columnFamily2 : "") +"s)"); +conn.createStatement().execute( +"upsert into " + fullTableName + " values (1, 0.5, 'foo')"); + conn.commit(); + conn.createStatement().execute("delete from " + fullTableName + " where id = 1"); + conn.commit(); +conn.createStatement().execute( +"upsert into " + fullTableName + " values (1, 0.5, 'foo')"); + conn.commit(); + ResultSet rs = conn.createStatement().executeQuery("select * from "+indexName); + assertTrue(rs.next()); + assertEquals(1, rs.getInt(2)); + assertEquals(0.5F, rs.getFloat(1), 0.0); + assertEquals("foo", rs.getString(3)); + } + } + private void upsertRow(String dml, Connection tenantConn, int i) throws SQLException { PreparedStatement stmt = tenantConn.prepareStatement(dml); stmt.setString(1, "00" + String.valueOf(i)); http://git-wip-us.apache.org/repos/asf/phoenix/blob/d1b5fd52/phoenix-core/src/main/java/org/apache/phoenix/hbase/index/covered/filter/ApplyAndFilterDeletesFilter.java -- diff --git a/phoenix-core/src/main/java/org/apache/phoenix/hbase/index/covered/filter/ApplyAndFilterDeletesFilter.java b/phoenix-core/src/main/java/org/apache/phoenix/hbase/index/covered/filter/ApplyAndFilterDeletesFilter.java index 67049f5..0fa9487 100644 --- a/phoenix-core/src/main/java/org/apache/phoenix/hbase/index/covered/filter/ApplyAndFilterDeletesFilter.java +++ b/phoenix-core/src/main/java/org/apache/phoenix/hbase/index/covered/filter/ApplyAndFilterDeletesFilter.java @@ -53,7 +53,6 @@ import org.apache.phoenix.util.PhoenixKeyValueUtil; */ public class ApplyAndFilterDeletesFilter extends FilterBase { - private boolean done = false; List families; private final DeleteTracker coveringDelete = new DeleteT