Return-Path: X-Original-To: archive-asf-public-internal@cust-asf2.ponee.io Delivered-To: archive-asf-public-internal@cust-asf2.ponee.io Received: from cust-asf.ponee.io (cust-asf.ponee.io [163.172.22.183]) by cust-asf2.ponee.io (Postfix) with ESMTP id 06B7A200D24 for ; Tue, 24 Oct 2017 21:11:06 +0200 (CEST) Received: by cust-asf.ponee.io (Postfix) id 0559E160BF1; Tue, 24 Oct 2017 19:11:06 +0000 (UTC) Delivered-To: archive-asf-public@cust-asf.ponee.io Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by cust-asf.ponee.io (Postfix) with SMTP id 53F6B1609C8 for ; Tue, 24 Oct 2017 21:11:05 +0200 (CEST) Received: (qmail 83027 invoked by uid 500); 24 Oct 2017 19:11:04 -0000 Mailing-List: contact dev-help@phoenix.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: dev@phoenix.apache.org Delivered-To: mailing list dev@phoenix.apache.org Received: (qmail 83006 invoked by uid 99); 24 Oct 2017 19:11:04 -0000 Received: from pnap-us-west-generic-nat.apache.org (HELO spamd1-us-west.apache.org) (209.188.14.142) by apache.org (qpsmtpd/0.29) with ESMTP; Tue, 24 Oct 2017 19:11:04 +0000 Received: from localhost (localhost [127.0.0.1]) by spamd1-us-west.apache.org (ASF Mail Server at spamd1-us-west.apache.org) with ESMTP id 778ACC0C03 for ; Tue, 24 Oct 2017 19:11:03 +0000 (UTC) X-Virus-Scanned: Debian amavisd-new at spamd1-us-west.apache.org X-Spam-Flag: NO X-Spam-Score: -99.201 X-Spam-Level: X-Spam-Status: No, score=-99.201 tagged_above=-999 required=6.31 tests=[KAM_ASCII_DIVIDERS=0.8, RP_MATCHES_RCVD=-0.001, SPF_PASS=-0.001, URIBL_BLOCKED=0.001, USER_IN_WHITELIST=-100] autolearn=disabled Received: from mx1-lw-eu.apache.org ([10.40.0.8]) by localhost (spamd1-us-west.apache.org [10.40.0.7]) (amavisd-new, port 10024) with ESMTP id HD8kDcgZvYHR for ; Tue, 24 Oct 2017 19:11:02 +0000 (UTC) Received: from mailrelay1-us-west.apache.org (mailrelay1-us-west.apache.org [209.188.14.139]) by mx1-lw-eu.apache.org (ASF Mail Server at mx1-lw-eu.apache.org) with ESMTP id B510D60D56 for ; Tue, 24 Oct 2017 19:11:01 +0000 (UTC) Received: from jira-lw-us.apache.org (unknown [207.244.88.139]) by mailrelay1-us-west.apache.org (ASF Mail Server at mailrelay1-us-west.apache.org) with ESMTP id C27D2E0D60 for ; Tue, 24 Oct 2017 19:11:00 +0000 (UTC) Received: from jira-lw-us.apache.org (localhost [127.0.0.1]) by jira-lw-us.apache.org (ASF Mail Server at jira-lw-us.apache.org) with ESMTP id 7BAA9212F9 for ; Tue, 24 Oct 2017 19:11:00 +0000 (UTC) Date: Tue, 24 Oct 2017 19:11:00 +0000 (UTC) From: "ASF GitHub Bot (JIRA)" To: dev@phoenix.apache.org Message-ID: In-Reply-To: References: Subject: [jira] [Commented] (PHOENIX-3757) System mutex table not being created in SYSTEM namespace when namespace mapping is enabled MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 7bit X-JIRA-FingerPrint: 30527f35849b9dde25b450d4833f0394 archived-at: Tue, 24 Oct 2017 19:11:06 -0000 [ https://issues.apache.org/jira/browse/PHOENIX-3757?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=16217491#comment-16217491 ] ASF GitHub Bot commented on PHOENIX-3757: ----------------------------------------- Github user twdsilva commented on a diff in the pull request: https://github.com/apache/phoenix/pull/277#discussion_r146663164 --- Diff: phoenix-core/src/main/java/org/apache/phoenix/query/ConnectionQueryServicesImpl.java --- @@ -3101,49 +3124,68 @@ void ensureSystemTablesUpgraded(ReadOnlyProps props) // Regardless of the case 1 or 2, if the NS does not exist, we will error expectedly // below. If the NS does exist and is mapped, the below check will exit gracefully. } - + List tableNames = getSystemTableNames(admin); // No tables exist matching "SYSTEM\..*", they are all already in "SYSTEM:.*" if (tableNames.size() == 0) { return; } // Try to move any remaining tables matching "SYSTEM\..*" into "SYSTEM:" if (tableNames.size() > 5) { logger.warn("Expected 5 system tables but found " + tableNames.size() + ":" + tableNames); } + + // Try acquiring a lock in SYSMUTEX table before migrating the tables since it involves disabling the table + // If we cannot acquire lock, it means some old client is either migrating SYSCAT or trying to upgrade the + // schema of SYSCAT table and hence it should not be interrupted + acquiredMutexLock = acquireUpgradeMutex(0, mutexRowKey); + if(acquiredMutexLock) { + logger.debug("Acquired lock in SYSMUTEX table for migrating SYSTEM tables to SYSTEM namespace"); + } + // We will not reach here if we fail to acquire the lock, since it throws UpgradeInProgressException + + // Handle the upgrade of SYSMUTEX table separately since it doesn't have any entries in SYSCAT + String sysMutexSrcTableName = PhoenixDatabaseMetaData.SYSTEM_MUTEX_NAME; + String sysMutexDestTableName = SchemaUtil.getPhysicalName(sysMutexSrcTableName.getBytes(), props).getNameAsString(); + UpgradeUtil.mapTableToNamespace(admin, sysMutexSrcTableName, sysMutexDestTableName, PTableType.SYSTEM); + byte[] mappedSystemTable = SchemaUtil .getPhysicalName(PhoenixDatabaseMetaData.SYSTEM_CATALOG_NAME_BYTES, props).getName(); metatable = getTable(mappedSystemTable); if (tableNames.contains(PhoenixDatabaseMetaData.SYSTEM_CATALOG_HBASE_TABLE_NAME)) { if (!admin.tableExists(mappedSystemTable)) { + // Actual migration of SYSCAT table UpgradeUtil.mapTableToNamespace(admin, metatable, PhoenixDatabaseMetaData.SYSTEM_CATALOG_NAME, props, null, PTableType.SYSTEM, null); + // Invalidate the client-side metadataCache ConnectionQueryServicesImpl.this.removeTable(null, PhoenixDatabaseMetaData.SYSTEM_CATALOG_NAME, null, MetaDataProtocol.MIN_SYSTEM_TABLE_TIMESTAMP_4_1_0); } tableNames.remove(PhoenixDatabaseMetaData.SYSTEM_CATALOG_HBASE_TABLE_NAME); } - tableNames.remove(PhoenixDatabaseMetaData.SYSTEM_MUTEX_HBASE_TABLE_NAME); --- End diff -- I think you still need to remove SYSTEM.MUTEX from tableNames. > System mutex table not being created in SYSTEM namespace when namespace mapping is enabled > ------------------------------------------------------------------------------------------ > > Key: PHOENIX-3757 > URL: https://issues.apache.org/jira/browse/PHOENIX-3757 > Project: Phoenix > Issue Type: Bug > Reporter: Josh Elser > Assignee: Karan Mehta > Priority: Critical > Labels: namespaces > Fix For: 4.13.0 > > Attachments: PHOENIX-3757.001.patch, PHOENIX-3757.002.patch > > > Noticed this issue while writing a test for PHOENIX-3756: > The SYSTEM.MUTEX table is always created in the default namespace, even when {{phoenix.schema.isNamespaceMappingEnabled=true}}. At a glance, it looks like the logic for the other system tables isn't applied to the mutex table. -- This message was sent by Atlassian JIRA (v6.4.14#64029)