[
https://issues.apache.org/jira/browse/PHOENIX-2671?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=15145001#comment-15145001
]
James Taylor commented on PHOENIX-2671:
---------------------------------------
Thanks, [~ankit.singhal]. Looks good, but one minor comment on this change:
{code}
diff --git
a/phoenix-core/src/main/java/org/apache/phoenix/util/UpgradeUtil.java
b/phoenix-core/src/main/java/org/apache/phoenix/util/UpgradeUtil.java
index 1d6f438..f49abad 100644
--- a/phoenix-core/src/main/java/org/apache/phoenix/util/UpgradeUtil.java
+++ b/phoenix-core/src/main/java/org/apache/phoenix/util/UpgradeUtil.java
@@ -1226,13 +1226,13 @@ public class UpgradeUtil {
PhoenixDatabaseMetaData.SYSTEM_CATALOG_TABLE)))
.getColumnCells(PhoenixDatabaseMetaData.TABLE_FAMILY_BYTES,
QueryConstants.EMPTY_COLUMN_BYTES);
if (!columnCells.isEmpty()
- && columnCells.get(0).getTimestamp() <
MetaDataProtocol.MIN_SYSTEM_TABLE_TIMESTAMP_4_7_0) {
+ && columnCells.get(0).getTimestamp() <
MetaDataProtocol.MIN_SYSTEM_TABLE_TIMESTAMP_4_7_0 - 2) {
byte[] statsTableKey = SchemaUtil.getTableKey(null,
PhoenixDatabaseMetaData.SYSTEM_SCHEMA_NAME,
PhoenixDatabaseMetaData.SYSTEM_STATS_TABLE);
KeyValue upgradeKV = KeyValueUtil.newKeyValue(statsTableKey,
PhoenixDatabaseMetaData.TABLE_FAMILY_BYTES,
UPGRADE_TO_4_7_COLUMN_NAME,
MetaDataProtocol.MIN_SYSTEM_TABLE_TIMESTAMP_4_7_0 - 1,
- ByteUtil.EMPTY_BYTE_ARRAY);
+ PBoolean.INSTANCE.toBytes(true));
Put upgradePut = new Put(statsTableKey);
upgradePut.add(upgradeKV);
{code}
Instead of checking the SYSTEM.CATALOG row timestamp, check the SYSTEM.STATS
table row timestamp (as that row will be set to
MetaDataProtocol.MIN_SYSTEM_TABLE_TIMESTAMP_4_7_0 once upgraded).
So something like this as in this way you don't change the timestamp of the
SYSTEM.STATS row and we don't need to subtract anything from our
MetaDataProtocol.MIN_SYSTEM_TABLE_TIMESTAMP_4_7_0 constant, as it seems more
consistent to use the SYSTEM.STATS row for the entire check:
{code}
public static boolean truncateStats(HTableInterface metaTable,
HTableInterface statsTable)
throws IOException, InterruptedException {
byte[] statsTableKey = SchemaUtil.getTableKey(null,
PhoenixDatabaseMetaData.SYSTEM_SCHEMA_NAME,
PhoenixDatabaseMetaData.SYSTEM_STATS_TABLE);
List<Cell> columnCells = metaTable
.get(new Get(statsTableKey))
.getColumnCells(PhoenixDatabaseMetaData.TABLE_FAMILY_BYTES,
QueryConstants.EMPTY_COLUMN_BYTES);
if (!columnCells.isEmpty()
&& columnCells.get(0).getTimestamp() <
MetaDataProtocol.MIN_SYSTEM_TABLE_TIMESTAMP_4_7_0) {
KeyValue upgradeKV = KeyValueUtil.newKeyValue(statsTableKey,
PhoenixDatabaseMetaData.TABLE_FAMILY_BYTES,
UPGRADE_TO_4_7_COLUMN_NAME,
columnCells.get(0).getTimestamp(),
PBoolean.INSTANCE.toBytes(true));
Put upgradePut = new Put(statsTableKey);
upgradePut.add(upgradeKV);
// check for null in UPGRADE_TO_4_7_COLUMN_NAME in checkAndPut so
that only single client
// drop the rows of SYSTEM.STATS
if (metaTable.checkAndPut(statsTableKey,
PhoenixDatabaseMetaData.TABLE_FAMILY_BYTES,
UPGRADE_TO_4_7_COLUMN_NAME, null, upgradePut)) {
{code}
WDYT?
> System.STATS table getting truncated every time on new client connection
> ------------------------------------------------------------------------
>
> Key: PHOENIX-2671
> URL: https://issues.apache.org/jira/browse/PHOENIX-2671
> Project: Phoenix
> Issue Type: Bug
> Affects Versions: 4.7.0
> Reporter: Mujtaba Chohan
> Assignee: Ankit Singhal
> Priority: Blocker
> Fix For: 4.7.0
>
> Attachments: PHOENIX-2671.patch
>
>
> Every time a client connects, SYSTEM.STATS table gets truncated.
> Log:
> {code}
> coprocessor.MetaDataRegionObserver: Stats are successfully truncated for
> upgrade 4.7!!
> {code}
--
This message was sent by Atlassian JIRA
(v6.3.4#6332)