[
https://issues.apache.org/jira/browse/PHOENIX-6127?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=17236516#comment-17236516
]
ASF GitHub Bot commented on PHOENIX-6127:
-----------------------------------------
ChinmaySKulkarni commented on a change in pull request #944:
URL: https://github.com/apache/phoenix/pull/944#discussion_r528024432
##########
File path: phoenix-core/src/main/java/org/apache/phoenix/util/ViewUtil.java
##########
@@ -337,6 +337,49 @@ public boolean filterAllRemaining() {
/**
* Attempt to drop an orphan child view i.e. a child view for which we see
a parent->child entry
* in SYSTEM.CHILD_LINK/SYSTEM.CATALOG (as a child) but for whom the
parent no longer exists.
+ * Its better to use this version, and trying to get the hTable Lazily
instead of checking it
+ * first via HBase admin call
+ * @param env Region Coprocessor environment
+ * @param tenantIdBytes tenantId of the parent
+ * @param schemaName schema of the parent
+ * @param tableOrViewName parent table/view name
+ * @throws IOException thrown if there is an error scanning
SYSTEM.CHILD_LINK or SYSTEM.CATALOG
+ * @throws SQLException thrown if there is an error getting a connection
to the server or
+ * an error retrieving the PTable for a child view
+ */
+ public static void dropChildViews(RegionCoprocessorEnvironment env, byte[]
tenantIdBytes,
+ byte[] schemaName, byte[]
tableOrViewName)
+ throws IOException, SQLException {
+ Configuration conf = env.getConfiguration();
+ Table hTable = null;
+ try {
+ byte[] sysCatOrSysChildLink =
SchemaUtil.getPhysicalTableName(SYSTEM_CATALOG_NAME_BYTES,
Review comment:
The order needs to be reversed here. We should first try to get
`SYSTEM.CHILD_LINK` and if that fails, fallback to using `SYSTEM.CATALOG`. We
also need to maintain the client version logic that
[ViewUtil.getSystemTableForChildLinks()](https://github.com/apache/phoenix/blob/bf8bb519b0c3d0fe96e7e1e33a7672fc0e15b1ad/phoenix-core/src/main/java/org/apache/phoenix/util/ViewUtil.java#L497)
has. Btw, with your changes, do we need the `getSystemTableForChildLinks()`
API anymore?
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
[email protected]
> Prevent unnecessary HBase admin API calls in
> ViewUtil.getSystemTableForChildLinks() and act lazily instead
> ----------------------------------------------------------------------------------------------------------
>
> Key: PHOENIX-6127
> URL: https://issues.apache.org/jira/browse/PHOENIX-6127
> Project: Phoenix
> Issue Type: Improvement
> Affects Versions: 5.0.0, 4.15.0
> Reporter: Chinmay Kulkarni
> Assignee: Richard Antal
> Priority: Major
> Labels: phoenix-hardening, quality-improvement
> Fix For: 5.1.0, 4.16.0
>
> Attachments: PHOENIX-6127.master.v1.patch
>
>
> In order to handle the case of older clients connecting to a 4.16 cluster
> that has old metadata (no SYSTEM.CHILD_LINK table yet), we call
> ViewUtil.getSystemTableForChildLinks() to figure out whether to use
> SYSTEM.CHILD_LINK or SYSTEM.CATALOG to look up parent->child linking rows.
> Here we do HBase table existence checks using HBase admin APIs (see
> [this|https://github.com/apache/phoenix/blob/e3c7b4bdce2524eb4fd1e7eb0ccd3454fcca81ce/phoenix-core/src/main/java/org/apache/phoenix/util/ViewUtil.java#L265-L269])
> which can be avoided. In almost all cases once we've called this API, we
> later go on and retrieve the Table object anyhow so we can instead try to
> always get the SYSTEM.CHILD_LINK table and if that fails, try to get
> SYSTEM.CATALOG. This will avoid additional admin API calls.
--
This message was sent by Atlassian Jira
(v8.3.4#803005)