You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@phoenix.apache.org by ja...@apache.org on 2016/02/17 02:22:44 UTC

[2/2] phoenix git commit: PHOENIX-2680 stats table timestamp incorrectly used as table timestamp

PHOENIX-2680 stats table timestamp incorrectly used as table timestamp


Project: http://git-wip-us.apache.org/repos/asf/phoenix/repo
Commit: http://git-wip-us.apache.org/repos/asf/phoenix/commit/d8e5a73b
Tree: http://git-wip-us.apache.org/repos/asf/phoenix/tree/d8e5a73b
Diff: http://git-wip-us.apache.org/repos/asf/phoenix/diff/d8e5a73b

Branch: refs/heads/master
Commit: d8e5a73be52c798b525068382e0376cb2d79e372
Parents: 6544573
Author: James Taylor <ja...@apache.org>
Authored: Tue Feb 16 17:17:54 2016 -0800
Committer: James Taylor <ja...@apache.org>
Committed: Tue Feb 16 17:17:54 2016 -0800

----------------------------------------------------------------------
 .../UngroupedAggregateRegionObserver.java           | 10 +---------
 .../phoenix/schema/stats/StatisticsCollector.java   | 16 ++++++++++------
 2 files changed, 11 insertions(+), 15 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/phoenix/blob/d8e5a73b/phoenix-core/src/main/java/org/apache/phoenix/coprocessor/UngroupedAggregateRegionObserver.java
----------------------------------------------------------------------
diff --git a/phoenix-core/src/main/java/org/apache/phoenix/coprocessor/UngroupedAggregateRegionObserver.java b/phoenix-core/src/main/java/org/apache/phoenix/coprocessor/UngroupedAggregateRegionObserver.java
index 05cf08e..e000e25 100644
--- a/phoenix-core/src/main/java/org/apache/phoenix/coprocessor/UngroupedAggregateRegionObserver.java
+++ b/phoenix-core/src/main/java/org/apache/phoenix/coprocessor/UngroupedAggregateRegionObserver.java
@@ -80,7 +80,6 @@ import org.apache.phoenix.index.IndexMaintainer;
 import org.apache.phoenix.index.PhoenixIndexCodec;
 import org.apache.phoenix.join.HashJoinInfo;
 import org.apache.phoenix.query.QueryConstants;
-import org.apache.phoenix.query.QueryServices;
 import org.apache.phoenix.query.QueryServicesOptions;
 import org.apache.phoenix.schema.ConstraintViolationException;
 import org.apache.phoenix.schema.PColumn;
@@ -610,20 +609,13 @@ public class UngroupedAggregateRegionObserver extends BaseScannerRegionObserver
         InternalScanner internalScanner = scanner;
         if (scanType.equals(ScanType.COMPACT_DROP_DELETES)) {
             try {
-                boolean useCurrentTime = c.getEnvironment().getConfiguration().getBoolean(
-                        QueryServices.STATS_USE_CURRENT_TIME_ATTRIB,
-                        QueryServicesOptions.DEFAULT_STATS_USE_CURRENT_TIME);
                 Connection conn = c.getEnvironment().getRegionServerServices().getConnection();
                 Pair<HRegionInfo, HRegionInfo> mergeRegions = null;
                 if (store.hasReferences()) {
                     mergeRegions = MetaTableAccessor.getRegionsFromMergeQualifier(conn,
                             c.getEnvironment().getRegion().getRegionInfo().getRegionName());
                 }
-                // Provides a means of clients controlling their timestamps to not use current time
-                // when background tasks are updating stats. Instead we track the max timestamp of
-                // the cells and use that.
-                long clientTimeStamp = useCurrentTime ? TimeKeeper.SYSTEM.getCurrentTime()
-                        : StatisticsCollector.NO_TIMESTAMP;
+                long clientTimeStamp = TimeKeeper.SYSTEM.getCurrentTime();
                 StatisticsCollector stats = new StatisticsCollector(c.getEnvironment(), table.getNameAsString(),
                         clientTimeStamp, store.getFamily().getName());
                 internalScanner = stats.createCompactionScanner(c.getEnvironment(), store, scanner, mergeRegions);

http://git-wip-us.apache.org/repos/asf/phoenix/blob/d8e5a73b/phoenix-core/src/main/java/org/apache/phoenix/schema/stats/StatisticsCollector.java
----------------------------------------------------------------------
diff --git a/phoenix-core/src/main/java/org/apache/phoenix/schema/stats/StatisticsCollector.java b/phoenix-core/src/main/java/org/apache/phoenix/schema/stats/StatisticsCollector.java
index 75e0aa0..1d0204f 100644
--- a/phoenix-core/src/main/java/org/apache/phoenix/schema/stats/StatisticsCollector.java
+++ b/phoenix-core/src/main/java/org/apache/phoenix/schema/stats/StatisticsCollector.java
@@ -63,11 +63,6 @@ public class StatisticsCollector {
     protected StatisticsWriter statsTable;
     private Pair<Long, GuidePostsInfoBuilder> cachedGps = null;
 
-    public StatisticsCollector(RegionCoprocessorEnvironment env, String tableName, long clientTimeStamp)
-            throws IOException {
-        this(env, tableName, clientTimeStamp, null, null, null);
-    }
-
     public StatisticsCollector(RegionCoprocessorEnvironment env, String tableName, long clientTimeStamp,
             byte[] gp_width_bytes, byte[] gp_per_region_bytes) throws IOException {
         this(env, tableName, clientTimeStamp, null, gp_width_bytes, gp_per_region_bytes);
@@ -78,7 +73,7 @@ public class StatisticsCollector {
         this(env, tableName, clientTimeStamp, family, null, null);
     }
 
-    public StatisticsCollector(RegionCoprocessorEnvironment env, String tableName, long clientTimeStamp, byte[] family,
+    private StatisticsCollector(RegionCoprocessorEnvironment env, String tableName, long clientTimeStamp, byte[] family,
             byte[] gp_width_bytes, byte[] gp_per_region_bytes) throws IOException {
         Configuration config = env.getConfiguration();
         int guidepostPerRegion = gp_per_region_bytes == null
@@ -91,6 +86,15 @@ public class StatisticsCollector {
                 : PLong.INSTANCE.getCodec().decodeInt(gp_width_bytes, 0, SortOrder.getDefault());
         this.guidepostDepth = StatisticsUtil.getGuidePostDepth(guidepostPerRegion, guidepostWidth,
                 env.getRegion().getTableDesc());
+        // Provides a means of clients controlling their timestamps to not use current time
+        // when background tasks are updating stats. Instead we track the max timestamp of
+        // the cells and use that.
+        boolean useCurrentTime = env.getConfiguration().getBoolean(
+                QueryServices.STATS_USE_CURRENT_TIME_ATTRIB,
+                QueryServicesOptions.DEFAULT_STATS_USE_CURRENT_TIME);
+        if (!useCurrentTime) {
+            clientTimeStamp = StatisticsCollector.NO_TIMESTAMP;
+        }
         // Get the stats table associated with the current table on which the CP is
         // triggered
         this.statsTable = StatisticsWriter.newWriter(env, tableName, clientTimeStamp);