You are viewing a plain text version of this content. The canonical link for it is here.
Posted to reviews@impala.apache.org by "Quanlong Huang (Code Review)" <ge...@cloudera.org> on 2023/11/30 11:44:27 UTC
[Impala-ASF-CR] IMPALA-11501: Add flag to allow catalog-cache operations on masked tables
Quanlong Huang has uploaded this change for review. ( http://gerrit.cloudera.org:8080/20742
Change subject: IMPALA-11501: Add flag to allow catalog-cache operations on masked tables
......................................................................
IMPALA-11501: Add flag to allow catalog-cache operations on masked tables
REFRESH/INVALIDATE METADATA <table> are the table level catalog-cache
operations. In Hive-Ranger plugin, when a table is masked (either by
column-masking or row-filtering policy) for a user, the user is unable
to perform any modification (insert/delete/update) on the table, i.e.
it's considered a read-only user (RANGER-1087, RANGER-1100). However,
Hive doesn't have these catalog-cache operations. It's a grey area
whether they should be blocked.
Before this patch, these catalog-cache operations are considered as
modifications on the table so they are also blocked for masked users.
Table metadata is required to be loaded so we have the column names to
fetch Ranger column masking policies. This causes a performance
regression on INVALIDATE METADATA <table> commands since in older
versions (e.g. CDH), IM commands don't need to load the table metadata
and runs pretty fast.
This patch adds a flag, allow_catalog_cache_op_from_masked_users, for
coordinators to skip checking masking policies for such statements. When
this flag is on, coordinators don't need to load the table metadata thus
fix the performance regression as well.
Note that Ranger ownership based policies can't be applied correctly
when the table is unloaded (so the owner is unknown). REFRESH/INVALIDATE
METADATA <table> commands could be denied on owners even if there are
Ranger policies allowing the owner's operations. This is a known issue
since IMPALA-8228. To ensure a user can always perform these operations,
grant REFRESH privilege to them to get rid of the unloaded table issue.
This patch also fixes a bug in local catalog mode which only occurs
after adding the new flag. The bug is that LocalDb#getTableIfCached()
always returns a LocalIncompleteTable regardless whether the table is
loaded in the coordinator. LocalIncompleteTable doens't have the owner
string, which causes REFRESH/INVALIDATE statements can't pass the
ownership context to RangerAccessResourceImpl so ownership policies
can't be correctly applied. This patch fixes LocalDb#getTableIfCached()
to also lookup in the cache and returns the LocalTable instance if it's
loaded.
Tests:
- Add e2e tests on both the legacy and local catalog mode.
Change-Id: I45935654cbf05a55d740f1b04781022c271f7678
---
M be/src/service/frontend.cc
M be/src/util/backend-gflag-util.cc
M common/thrift/BackendGflags.thrift
M fe/src/main/java/org/apache/impala/analysis/StmtMetadataLoader.java
M fe/src/main/java/org/apache/impala/authorization/BaseAuthorizationChecker.java
M fe/src/main/java/org/apache/impala/authorization/Privilege.java
M fe/src/main/java/org/apache/impala/catalog/local/CatalogdMetaProvider.java
M fe/src/main/java/org/apache/impala/catalog/local/DirectMetaProvider.java
M fe/src/main/java/org/apache/impala/catalog/local/LocalDb.java
M fe/src/main/java/org/apache/impala/catalog/local/LocalTable.java
M fe/src/main/java/org/apache/impala/catalog/local/MetaProvider.java
M fe/src/main/java/org/apache/impala/service/BackendConfig.java
M tests/authorization/test_ranger.py
13 files changed, 165 insertions(+), 8 deletions(-)
git pull ssh://gerrit.cloudera.org:29418/Impala-ASF refs/changes/42/20742/1
--
To view, visit http://gerrit.cloudera.org:8080/20742
To unsubscribe, visit http://gerrit.cloudera.org:8080/settings
Gerrit-Project: Impala-ASF
Gerrit-Branch: master
Gerrit-MessageType: newchange
Gerrit-Change-Id: I45935654cbf05a55d740f1b04781022c271f7678
Gerrit-Change-Number: 20742
Gerrit-PatchSet: 1
Gerrit-Owner: Quanlong Huang <hu...@gmail.com>
[Impala-ASF-CR] IMPALA-11501: Add flag to allow catalog-cache operations on masked tables
Posted by "Impala Public Jenkins (Code Review)" <ge...@cloudera.org>.
Impala Public Jenkins has posted comments on this change. ( http://gerrit.cloudera.org:8080/20742 )
Change subject: IMPALA-11501: Add flag to allow catalog-cache operations on masked tables
......................................................................
Patch Set 1: Verified+1
--
To view, visit http://gerrit.cloudera.org:8080/20742
To unsubscribe, visit http://gerrit.cloudera.org:8080/settings
Gerrit-Project: Impala-ASF
Gerrit-Branch: master
Gerrit-MessageType: comment
Gerrit-Change-Id: I45935654cbf05a55d740f1b04781022c271f7678
Gerrit-Change-Number: 20742
Gerrit-PatchSet: 1
Gerrit-Owner: Quanlong Huang <hu...@gmail.com>
Gerrit-Reviewer: Csaba Ringhofer <cs...@cloudera.com>
Gerrit-Reviewer: Fang-Yu Rao <fa...@cloudera.com>
Gerrit-Reviewer: Impala Public Jenkins <im...@cloudera.com>
Gerrit-Reviewer: Quanlong Huang <hu...@gmail.com>
Gerrit-Comment-Date: Thu, 30 Nov 2023 18:27:23 +0000
Gerrit-HasComments: No
[Impala-ASF-CR] IMPALA-11501: Add flag to allow catalog-cache operations on masked tables
Posted by "Impala Public Jenkins (Code Review)" <ge...@cloudera.org>.
Impala Public Jenkins has posted comments on this change. ( http://gerrit.cloudera.org:8080/20742 )
Change subject: IMPALA-11501: Add flag to allow catalog-cache operations on masked tables
......................................................................
Patch Set 1:
Build Successful
https://jenkins.impala.io/job/gerrit-code-review-checks/14556/ : Initial code review checks passed. Use gerrit-verify-dryrun-external or gerrit-verify-dryrun to run full precommit tests.
--
To view, visit http://gerrit.cloudera.org:8080/20742
To unsubscribe, visit http://gerrit.cloudera.org:8080/settings
Gerrit-Project: Impala-ASF
Gerrit-Branch: master
Gerrit-MessageType: comment
Gerrit-Change-Id: I45935654cbf05a55d740f1b04781022c271f7678
Gerrit-Change-Number: 20742
Gerrit-PatchSet: 1
Gerrit-Owner: Quanlong Huang <hu...@gmail.com>
Gerrit-Reviewer: Csaba Ringhofer <cs...@cloudera.com>
Gerrit-Reviewer: Fang-Yu Rao <fa...@cloudera.com>
Gerrit-Reviewer: Impala Public Jenkins <im...@cloudera.com>
Gerrit-Reviewer: Quanlong Huang <hu...@gmail.com>
Gerrit-Comment-Date: Thu, 30 Nov 2023 12:11:38 +0000
Gerrit-HasComments: No
[Impala-ASF-CR] IMPALA-11501: Add flag to allow catalog-cache operations on masked tables
Posted by "Impala Public Jenkins (Code Review)" <ge...@cloudera.org>.
Impala Public Jenkins has posted comments on this change. ( http://gerrit.cloudera.org:8080/20742 )
Change subject: IMPALA-11501: Add flag to allow catalog-cache operations on masked tables
......................................................................
Patch Set 2:
Build Successful
https://jenkins.impala.io/job/gerrit-code-review-checks/14578/ : Initial code review checks passed. Use gerrit-verify-dryrun-external or gerrit-verify-dryrun to run full precommit tests.
--
To view, visit http://gerrit.cloudera.org:8080/20742
To unsubscribe, visit http://gerrit.cloudera.org:8080/settings
Gerrit-Project: Impala-ASF
Gerrit-Branch: master
Gerrit-MessageType: comment
Gerrit-Change-Id: I45935654cbf05a55d740f1b04781022c271f7678
Gerrit-Change-Number: 20742
Gerrit-PatchSet: 2
Gerrit-Owner: Quanlong Huang <hu...@gmail.com>
Gerrit-Reviewer: Csaba Ringhofer <cs...@cloudera.com>
Gerrit-Reviewer: Fang-Yu Rao <fa...@cloudera.com>
Gerrit-Reviewer: Impala Public Jenkins <im...@cloudera.com>
Gerrit-Reviewer: Quanlong Huang <hu...@gmail.com>
Gerrit-Comment-Date: Mon, 04 Dec 2023 08:35:34 +0000
Gerrit-HasComments: No
[Impala-ASF-CR] IMPALA-11501: Add flag to allow catalog-cache operations on masked tables
Posted by "Fang-Yu Rao (Code Review)" <ge...@cloudera.org>.
Fang-Yu Rao has posted comments on this change. ( http://gerrit.cloudera.org:8080/20742 )
Change subject: IMPALA-11501: Add flag to allow catalog-cache operations on masked tables
......................................................................
Patch Set 3:
(1 comment)
Thanks for addressing my previous comments Quanlong! I do not have any additional suggestion. It should be fine to bump the vote of code-review if Csaba does not have more comments.
http://gerrit.cloudera.org:8080/#/c/20742/2/fe/src/main/java/org/apache/impala/catalog/local/MetaProvider.java
File fe/src/main/java/org/apache/impala/catalog/local/MetaProvider.java:
http://gerrit.cloudera.org:8080/#/c/20742/2/fe/src/main/java/org/apache/impala/catalog/local/MetaProvider.java@81
PS2, Line 81: Pair<Table, TableMetaRef> getTableIfPresent(String dbName, String tableName);
> catalog_.getMetaProvider() returns a MetaProvider. Adding this only in Cata
Ack
--
To view, visit http://gerrit.cloudera.org:8080/20742
To unsubscribe, visit http://gerrit.cloudera.org:8080/settings
Gerrit-Project: Impala-ASF
Gerrit-Branch: master
Gerrit-MessageType: comment
Gerrit-Change-Id: I45935654cbf05a55d740f1b04781022c271f7678
Gerrit-Change-Number: 20742
Gerrit-PatchSet: 3
Gerrit-Owner: Quanlong Huang <hu...@gmail.com>
Gerrit-Reviewer: Csaba Ringhofer <cs...@cloudera.com>
Gerrit-Reviewer: Fang-Yu Rao <fa...@cloudera.com>
Gerrit-Reviewer: Impala Public Jenkins <im...@cloudera.com>
Gerrit-Reviewer: Quanlong Huang <hu...@gmail.com>
Gerrit-Comment-Date: Mon, 11 Dec 2023 22:06:25 +0000
Gerrit-HasComments: Yes
[Impala-ASF-CR] IMPALA-11501: Add flag to allow catalog-cache operations on masked tables
Posted by "Quanlong Huang (Code Review)" <ge...@cloudera.org>.
Quanlong Huang has posted comments on this change. ( http://gerrit.cloudera.org:8080/20742 )
Change subject: IMPALA-11501: Add flag to allow catalog-cache operations on masked tables
......................................................................
Patch Set 3:
(4 comments)
Somehow I missed the previous comments. Sorry to be late here.
http://gerrit.cloudera.org:8080/#/c/20742/1/fe/src/main/java/org/apache/impala/authorization/BaseAuthorizationChecker.java
File fe/src/main/java/org/apache/impala/authorization/BaseAuthorizationChecker.java:
http://gerrit.cloudera.org:8080/#/c/20742/1/fe/src/main/java/org/apache/impala/authorization/BaseAuthorizationChecker.java@222
PS1, Line 222: oves the performance of "INVALIDATE METADATA <table>" statements. For REFRESH
: // statements, the performance doesn't differ a lot since there are ot
> I am trying to answer my questions above.
Sorry to be late here. Yes, exactly. This avoids getTable() triggering full table loading in local catalog mode. I left a comment in the JIRA about this: https://issues.apache.org/jira/browse/IMPALA-11501?focusedCommentId=17770339&page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel#comment-17770339
I'll add some comments to make this more clear.
http://gerrit.cloudera.org:8080/#/c/20742/2/fe/src/main/java/org/apache/impala/catalog/local/MetaProvider.java
File fe/src/main/java/org/apache/impala/catalog/local/MetaProvider.java:
http://gerrit.cloudera.org:8080/#/c/20742/2/fe/src/main/java/org/apache/impala/catalog/local/MetaProvider.java@81
PS2, Line 81: Pair<Table, TableMetaRef> getTableIfPresent(String dbName, String tableName);
> Should we add this method to CatalogdMetaProvider.java only? I am asking th
catalog_.getMetaProvider() returns a MetaProvider. Adding this only in CatalogdMetaProvider requires adding type checks after it. The current way seems more clean.
http://gerrit.cloudera.org:8080/#/c/20742/1/tests/authorization/test_ranger.py
File tests/authorization/test_ranger.py:
http://gerrit.cloudera.org:8080/#/c/20742/1/tests/authorization/test_ranger.py@1608
PS1, Line 1608: self.execute_query_expect_success(
: non_admin_client, "describe functional.alltypestiny", user=user)
: # Verify catalogd loads metadata of this table
> Thanks a lot for the detailed explanation Quanlong! Things are much clearer
Ack
http://gerrit.cloudera.org:8080/#/c/20742/2/tests/authorization/test_ranger.py
File tests/authorization/test_ranger.py:
http://gerrit.cloudera.org:8080/#/c/20742/2/tests/authorization/test_ranger.py@1615
PS2, Line 1615: ida
> Would the REFRESH privilege be sufficient in this case as mentioned in the
Yeah, just wanted to use a short grant statement. I can change it to the minimal one.
--
To view, visit http://gerrit.cloudera.org:8080/20742
To unsubscribe, visit http://gerrit.cloudera.org:8080/settings
Gerrit-Project: Impala-ASF
Gerrit-Branch: master
Gerrit-MessageType: comment
Gerrit-Change-Id: I45935654cbf05a55d740f1b04781022c271f7678
Gerrit-Change-Number: 20742
Gerrit-PatchSet: 3
Gerrit-Owner: Quanlong Huang <hu...@gmail.com>
Gerrit-Reviewer: Csaba Ringhofer <cs...@cloudera.com>
Gerrit-Reviewer: Fang-Yu Rao <fa...@cloudera.com>
Gerrit-Reviewer: Impala Public Jenkins <im...@cloudera.com>
Gerrit-Reviewer: Quanlong Huang <hu...@gmail.com>
Gerrit-Comment-Date: Mon, 11 Dec 2023 08:02:27 +0000
Gerrit-HasComments: Yes
[Impala-ASF-CR] IMPALA-11501: Add flag to allow catalog-cache operations on masked tables
Posted by "Impala Public Jenkins (Code Review)" <ge...@cloudera.org>.
Impala Public Jenkins has posted comments on this change. ( http://gerrit.cloudera.org:8080/20742 )
Change subject: IMPALA-11501: Add flag to allow catalog-cache operations on masked tables
......................................................................
Patch Set 4: Code-Review+2
--
To view, visit http://gerrit.cloudera.org:8080/20742
To unsubscribe, visit http://gerrit.cloudera.org:8080/settings
Gerrit-Project: Impala-ASF
Gerrit-Branch: master
Gerrit-MessageType: comment
Gerrit-Change-Id: I45935654cbf05a55d740f1b04781022c271f7678
Gerrit-Change-Number: 20742
Gerrit-PatchSet: 4
Gerrit-Owner: Quanlong Huang <hu...@gmail.com>
Gerrit-Reviewer: Csaba Ringhofer <cs...@cloudera.com>
Gerrit-Reviewer: Fang-Yu Rao <fa...@cloudera.com>
Gerrit-Reviewer: Impala Public Jenkins <im...@cloudera.com>
Gerrit-Reviewer: Quanlong Huang <hu...@gmail.com>
Gerrit-Comment-Date: Wed, 13 Dec 2023 23:32:44 +0000
Gerrit-HasComments: No
[Impala-ASF-CR] IMPALA-11501: Add flag to allow catalog-cache operations on masked tables
Posted by "Fang-Yu Rao (Code Review)" <ge...@cloudera.org>.
Fang-Yu Rao has posted comments on this change. ( http://gerrit.cloudera.org:8080/20742 )
Change subject: IMPALA-11501: Add flag to allow catalog-cache operations on masked tables
......................................................................
Patch Set 2: Code-Review+1
(2 comments)
Thanks for working on this Quanlong! I only have one additional minor question regarding whether we should add getTableIfPresent() to CatalogdMetaProvider.java only.
http://gerrit.cloudera.org:8080/#/c/20742/1/fe/src/main/java/org/apache/impala/authorization/BaseAuthorizationChecker.java
File fe/src/main/java/org/apache/impala/authorization/BaseAuthorizationChecker.java:
http://gerrit.cloudera.org:8080/#/c/20742/1/fe/src/main/java/org/apache/impala/authorization/BaseAuthorizationChecker.java@222
PS1, Line 222: (request.getPrivilege() != Privilege.REFRESH
: || !BackendConfig.INSTANCE.allowCatalogCacheOpFromMaskedUsers())
> This is just for my own understanding.
I am trying to answer my questions above.
It looks like db.getTable(authorizableTable.getTableName()) at https://gerrit.cloudera.org/c/20742/1/fe/src/main/java/org/apache/impala/authorization/BaseAuthorizationChecker.java#231 will fully load the table metadata only in the local catalog mode.
Therefore, I think this additional condition is to prevent fully loading the table metadata in the local catalog mode.
http://gerrit.cloudera.org:8080/#/c/20742/2/fe/src/main/java/org/apache/impala/catalog/local/MetaProvider.java
File fe/src/main/java/org/apache/impala/catalog/local/MetaProvider.java:
http://gerrit.cloudera.org:8080/#/c/20742/2/fe/src/main/java/org/apache/impala/catalog/local/MetaProvider.java@81
PS2, Line 81: Pair<Table, TableMetaRef> getTableIfPresent(String dbName, String tableName);
Should we add this method to CatalogdMetaProvider.java only? I am asking this because I saw at https://github.com/apache/impala/blob/master/fe/src/main/java/org/apache/impala/catalog/local/DirectMetaProvider.java#L76-L79 that DirectMetaProvider.java is a provider that calls out to the source systems without caching.
--
To view, visit http://gerrit.cloudera.org:8080/20742
To unsubscribe, visit http://gerrit.cloudera.org:8080/settings
Gerrit-Project: Impala-ASF
Gerrit-Branch: master
Gerrit-MessageType: comment
Gerrit-Change-Id: I45935654cbf05a55d740f1b04781022c271f7678
Gerrit-Change-Number: 20742
Gerrit-PatchSet: 2
Gerrit-Owner: Quanlong Huang <hu...@gmail.com>
Gerrit-Reviewer: Csaba Ringhofer <cs...@cloudera.com>
Gerrit-Reviewer: Fang-Yu Rao <fa...@cloudera.com>
Gerrit-Reviewer: Impala Public Jenkins <im...@cloudera.com>
Gerrit-Reviewer: Quanlong Huang <hu...@gmail.com>
Gerrit-Comment-Date: Mon, 11 Dec 2023 05:42:21 +0000
Gerrit-HasComments: Yes
[Impala-ASF-CR] IMPALA-11501: Add flag to allow catalog-cache operations on masked tables
Posted by "Impala Public Jenkins (Code Review)" <ge...@cloudera.org>.
Impala Public Jenkins has posted comments on this change. ( http://gerrit.cloudera.org:8080/20742 )
Change subject: IMPALA-11501: Add flag to allow catalog-cache operations on masked tables
......................................................................
Patch Set 3:
Build Successful
https://jenkins.impala.io/job/gerrit-code-review-checks/14635/ : Initial code review checks passed. Use gerrit-verify-dryrun-external or gerrit-verify-dryrun to run full precommit tests.
--
To view, visit http://gerrit.cloudera.org:8080/20742
To unsubscribe, visit http://gerrit.cloudera.org:8080/settings
Gerrit-Project: Impala-ASF
Gerrit-Branch: master
Gerrit-MessageType: comment
Gerrit-Change-Id: I45935654cbf05a55d740f1b04781022c271f7678
Gerrit-Change-Number: 20742
Gerrit-PatchSet: 3
Gerrit-Owner: Quanlong Huang <hu...@gmail.com>
Gerrit-Reviewer: Csaba Ringhofer <cs...@cloudera.com>
Gerrit-Reviewer: Fang-Yu Rao <fa...@cloudera.com>
Gerrit-Reviewer: Impala Public Jenkins <im...@cloudera.com>
Gerrit-Reviewer: Quanlong Huang <hu...@gmail.com>
Gerrit-Comment-Date: Mon, 11 Dec 2023 08:28:53 +0000
Gerrit-HasComments: No
[Impala-ASF-CR] IMPALA-11501: Add flag to allow catalog-cache operations on masked tables
Posted by "Impala Public Jenkins (Code Review)" <ge...@cloudera.org>.
Impala Public Jenkins has submitted this change and it was merged. ( http://gerrit.cloudera.org:8080/20742 )
Change subject: IMPALA-11501: Add flag to allow catalog-cache operations on masked tables
......................................................................
IMPALA-11501: Add flag to allow catalog-cache operations on masked tables
REFRESH/INVALIDATE METADATA <table> are the table level catalog-cache
operations. In Hive-Ranger plugin, when a table is masked (either by
column-masking or row-filtering policy) for a user, the user is unable
to perform any modification (insert/delete/update) on the table, i.e.
it's considered a read-only user (RANGER-1087, RANGER-1100). However,
Hive doesn't have these catalog-cache operations. It's a grey area
whether they should be blocked.
Before this patch, these catalog-cache operations are considered as
modifications on the table so they are also blocked for masked users.
Table metadata is required to be loaded so we have the column names to
fetch Ranger column masking policies. This causes a performance
regression on INVALIDATE METADATA <table> commands since in older
versions (e.g. CDH), IM commands don't need to load the table metadata
and runs pretty fast.
This patch adds a flag, allow_catalog_cache_op_from_masked_users, for
coordinators to skip checking masking policies for such statements. When
this flag is on, coordinators don't need to load the table metadata thus
fix the performance regression as well.
Note that Ranger ownership based policies can't be applied correctly
when the table is unloaded (so the owner is unknown). REFRESH/INVALIDATE
METADATA <table> commands could be denied on owners even if there are
Ranger policies allowing the owner's operations. This is a known issue
since IMPALA-8228. To ensure a user can always perform these operations,
grant REFRESH privilege to them to get rid of the unloaded table issue.
This patch also fixes a bug in local catalog mode which only occurs
after adding the new flag. The bug is that LocalDb#getTableIfCached()
doesn't make good use of the cache. If the table meta is cahced but
LocalDb#getTable() hasn't been invoked on the table, getTableIfCached()
will always return a LocalIncompleteTable which is missing some table
info, e.g. ownership. This causes REFRESH/INVALIDATE statements not able
to pass the ownership context to RangerAccessResourceImpl so ownership
policies can't be correctly applied.
Ideally, LocalDb#getTableIfCached() should return a LocalTable instance
if the table is cached. However, in local catalog mode, we don't cache
everything that constructs a LocalTable instance. Constructing a
LocalTable instance might still trigger external RPCs which should be
avoided. As an alternative, this patch checks if the msTable is cached.
If it's cached, add it to the LocalIncompleteTable instance so most of
the table info can be retrieved, including the ownership string.
Tests:
- Add e2e tests on both the legacy and local catalog mode.
Change-Id: I45935654cbf05a55d740f1b04781022c271f7678
Reviewed-on: http://gerrit.cloudera.org:8080/20742
Reviewed-by: Impala Public Jenkins <im...@cloudera.com>
Tested-by: Impala Public Jenkins <im...@cloudera.com>
---
M be/src/service/frontend.cc
M be/src/util/backend-gflag-util.cc
M common/thrift/BackendGflags.thrift
M fe/src/main/java/org/apache/impala/analysis/StmtMetadataLoader.java
M fe/src/main/java/org/apache/impala/authorization/BaseAuthorizationChecker.java
M fe/src/main/java/org/apache/impala/authorization/Privilege.java
M fe/src/main/java/org/apache/impala/catalog/Table.java
M fe/src/main/java/org/apache/impala/catalog/local/CatalogdMetaProvider.java
M fe/src/main/java/org/apache/impala/catalog/local/DirectMetaProvider.java
M fe/src/main/java/org/apache/impala/catalog/local/LocalDb.java
M fe/src/main/java/org/apache/impala/catalog/local/LocalIncompleteTable.java
M fe/src/main/java/org/apache/impala/catalog/local/LocalTable.java
M fe/src/main/java/org/apache/impala/catalog/local/MetaProvider.java
M fe/src/main/java/org/apache/impala/service/BackendConfig.java
M tests/authorization/test_ranger.py
15 files changed, 188 insertions(+), 12 deletions(-)
Approvals:
Impala Public Jenkins: Looks good to me, approved; Verified
--
To view, visit http://gerrit.cloudera.org:8080/20742
To unsubscribe, visit http://gerrit.cloudera.org:8080/settings
Gerrit-Project: Impala-ASF
Gerrit-Branch: master
Gerrit-MessageType: merged
Gerrit-Change-Id: I45935654cbf05a55d740f1b04781022c271f7678
Gerrit-Change-Number: 20742
Gerrit-PatchSet: 5
Gerrit-Owner: Quanlong Huang <hu...@gmail.com>
Gerrit-Reviewer: Csaba Ringhofer <cs...@cloudera.com>
Gerrit-Reviewer: Fang-Yu Rao <fa...@cloudera.com>
Gerrit-Reviewer: Impala Public Jenkins <im...@cloudera.com>
Gerrit-Reviewer: Quanlong Huang <hu...@gmail.com>
[Impala-ASF-CR] IMPALA-11501: Add flag to allow catalog-cache operations on masked tables
Posted by "Impala Public Jenkins (Code Review)" <ge...@cloudera.org>.
Impala Public Jenkins has posted comments on this change. ( http://gerrit.cloudera.org:8080/20742 )
Change subject: IMPALA-11501: Add flag to allow catalog-cache operations on masked tables
......................................................................
Patch Set 1:
Build started: https://jenkins.impala.io/job/gerrit-verify-dryrun/9972/ DRY_RUN=true
--
To view, visit http://gerrit.cloudera.org:8080/20742
To unsubscribe, visit http://gerrit.cloudera.org:8080/settings
Gerrit-Project: Impala-ASF
Gerrit-Branch: master
Gerrit-MessageType: comment
Gerrit-Change-Id: I45935654cbf05a55d740f1b04781022c271f7678
Gerrit-Change-Number: 20742
Gerrit-PatchSet: 1
Gerrit-Owner: Quanlong Huang <hu...@gmail.com>
Gerrit-Reviewer: Csaba Ringhofer <cs...@cloudera.com>
Gerrit-Reviewer: Fang-Yu Rao <fa...@cloudera.com>
Gerrit-Reviewer: Impala Public Jenkins <im...@cloudera.com>
Gerrit-Reviewer: Quanlong Huang <hu...@gmail.com>
Gerrit-Comment-Date: Thu, 30 Nov 2023 14:00:25 +0000
Gerrit-HasComments: No
[Impala-ASF-CR] IMPALA-11501: Add flag to allow catalog-cache operations on masked tables
Posted by "Fang-Yu Rao (Code Review)" <ge...@cloudera.org>.
Fang-Yu Rao has posted comments on this change. ( http://gerrit.cloudera.org:8080/20742 )
Change subject: IMPALA-11501: Add flag to allow catalog-cache operations on masked tables
......................................................................
Patch Set 2:
(3 comments)
> Patch Set 2:
>
> (11 comments)
Thanks a lot for the detailed explanation Quanlong! I left some very minor comments.
http://gerrit.cloudera.org:8080/#/c/20742/1/fe/src/main/java/org/apache/impala/authorization/BaseAuthorizationChecker.java
File fe/src/main/java/org/apache/impala/authorization/BaseAuthorizationChecker.java:
http://gerrit.cloudera.org:8080/#/c/20742/1/fe/src/main/java/org/apache/impala/authorization/BaseAuthorizationChecker.java@222
PS1, Line 222: (request.getPrivilege() != Privilege.REFRESH
: || !BackendConfig.INSTANCE.allowCatalogCacheOpFromMaskedUsers())
This is just for my own understanding.
Is it true that by adding this additional condition we could improve the performance of INVALIDATE METADATA <table> when '--allow_catalog_cache_op_from_masked_users' is true (in both catalog modes), because the following call to db.getTable(authorizableTable.getTableName()) at https://gerrit.cloudera.org/c/20742/1/fe/src/main/java/org/apache/impala/authorization/BaseAuthorizationChecker.java#231 is a heavy operation and will be avoided in this case?
In addition, according to our discussion at https://gerrit.cloudera.org/c/20742/1/tests/authorization/test_ranger.py#1610, since Impala REFRESH <table> statement in the local catalog mode currently still triggers the loading of table metadata in other place(s), this additional condition could only improve the performance of REFRESH <table> in the legacy catalog mode?
http://gerrit.cloudera.org:8080/#/c/20742/1/tests/authorization/test_ranger.py
File tests/authorization/test_ranger.py:
http://gerrit.cloudera.org:8080/#/c/20742/1/tests/authorization/test_ranger.py@1608
PS1, Line 1608: self.execute_query_expect_success(
: non_admin_client,
: "refresh functional.alltypestiny partition(year=2009, month=1)", user=user)
> Nice findings!
Thanks a lot for the detailed explanation Quanlong! Things are much clearer after your explanation. :-)
Now I understand that CatalogMetaProvider#updateCatalogCache() will be called to invalidate the table metadata after a DDL according to https://github.com/apache/impala/blob/master/fe/src/main/java/org/apache/impala/catalog/local/CatalogdMetaProvider.java#L1274-L1287.
http://gerrit.cloudera.org:8080/#/c/20742/2/tests/authorization/test_ranger.py
File tests/authorization/test_ranger.py:
http://gerrit.cloudera.org:8080/#/c/20742/2/tests/authorization/test_ranger.py@1615
PS2, Line 1615: all
Would the REFRESH privilege be sufficient in this case as mentioned in the commit message?
--
To view, visit http://gerrit.cloudera.org:8080/20742
To unsubscribe, visit http://gerrit.cloudera.org:8080/settings
Gerrit-Project: Impala-ASF
Gerrit-Branch: master
Gerrit-MessageType: comment
Gerrit-Change-Id: I45935654cbf05a55d740f1b04781022c271f7678
Gerrit-Change-Number: 20742
Gerrit-PatchSet: 2
Gerrit-Owner: Quanlong Huang <hu...@gmail.com>
Gerrit-Reviewer: Csaba Ringhofer <cs...@cloudera.com>
Gerrit-Reviewer: Fang-Yu Rao <fa...@cloudera.com>
Gerrit-Reviewer: Impala Public Jenkins <im...@cloudera.com>
Gerrit-Reviewer: Quanlong Huang <hu...@gmail.com>
Gerrit-Comment-Date: Thu, 07 Dec 2023 01:31:06 +0000
Gerrit-HasComments: Yes
[Impala-ASF-CR] IMPALA-11501: Add flag to allow catalog-cache operations on masked tables
Posted by "Impala Public Jenkins (Code Review)" <ge...@cloudera.org>.
Impala Public Jenkins has posted comments on this change. ( http://gerrit.cloudera.org:8080/20742 )
Change subject: IMPALA-11501: Add flag to allow catalog-cache operations on masked tables
......................................................................
Patch Set 4: Verified+1
--
To view, visit http://gerrit.cloudera.org:8080/20742
To unsubscribe, visit http://gerrit.cloudera.org:8080/settings
Gerrit-Project: Impala-ASF
Gerrit-Branch: master
Gerrit-MessageType: comment
Gerrit-Change-Id: I45935654cbf05a55d740f1b04781022c271f7678
Gerrit-Change-Number: 20742
Gerrit-PatchSet: 4
Gerrit-Owner: Quanlong Huang <hu...@gmail.com>
Gerrit-Reviewer: Csaba Ringhofer <cs...@cloudera.com>
Gerrit-Reviewer: Fang-Yu Rao <fa...@cloudera.com>
Gerrit-Reviewer: Impala Public Jenkins <im...@cloudera.com>
Gerrit-Reviewer: Quanlong Huang <hu...@gmail.com>
Gerrit-Comment-Date: Thu, 14 Dec 2023 03:58:12 +0000
Gerrit-HasComments: No
[Impala-ASF-CR] IMPALA-11501: Add flag to allow catalog-cache operations on masked tables
Posted by "Fang-Yu Rao (Code Review)" <ge...@cloudera.org>.
Fang-Yu Rao has posted comments on this change. ( http://gerrit.cloudera.org:8080/20742 )
Change subject: IMPALA-11501: Add flag to allow catalog-cache operations on masked tables
......................................................................
Patch Set 3: Code-Review+2
(1 comment)
http://gerrit.cloudera.org:8080/#/c/20742/2/tests/authorization/test_ranger.py
File tests/authorization/test_ranger.py:
http://gerrit.cloudera.org:8080/#/c/20742/2/tests/authorization/test_ranger.py@1615
PS2, Line 1615: ida
> Yeah, just wanted to use a short grant statement. I can change it to the mi
Ack
--
To view, visit http://gerrit.cloudera.org:8080/20742
To unsubscribe, visit http://gerrit.cloudera.org:8080/settings
Gerrit-Project: Impala-ASF
Gerrit-Branch: master
Gerrit-MessageType: comment
Gerrit-Change-Id: I45935654cbf05a55d740f1b04781022c271f7678
Gerrit-Change-Number: 20742
Gerrit-PatchSet: 3
Gerrit-Owner: Quanlong Huang <hu...@gmail.com>
Gerrit-Reviewer: Csaba Ringhofer <cs...@cloudera.com>
Gerrit-Reviewer: Fang-Yu Rao <fa...@cloudera.com>
Gerrit-Reviewer: Impala Public Jenkins <im...@cloudera.com>
Gerrit-Reviewer: Quanlong Huang <hu...@gmail.com>
Gerrit-Comment-Date: Wed, 13 Dec 2023 23:28:06 +0000
Gerrit-HasComments: Yes
[Impala-ASF-CR] IMPALA-11501: Add flag to allow catalog-cache operations on masked tables
Posted by "Fang-Yu Rao (Code Review)" <ge...@cloudera.org>.
Fang-Yu Rao has posted comments on this change. ( http://gerrit.cloudera.org:8080/20742 )
Change subject: IMPALA-11501: Add flag to allow catalog-cache operations on masked tables
......................................................................
Patch Set 1:
(5 comments)
Thanks for the help Quanlong!
In this round of review I tried to familiarize myself with the behavior of Impala after the flag is introduced based on the test cases added in test_ranger.py and found some differences between 2 catalog modes.
I will continue the review and let you know if there are additional questions or comments on other parts of the patch.
http://gerrit.cloudera.org:8080/#/c/20742/1//COMMIT_MSG
Commit Message:
http://gerrit.cloudera.org:8080/#/c/20742/1//COMMIT_MSG@40
PS1, Line 40: doens't
nit: doesn't
http://gerrit.cloudera.org:8080/#/c/20742/1//COMMIT_MSG@41
PS1, Line 41: can't
nit: not able to
http://gerrit.cloudera.org:8080/#/c/20742/1//COMMIT_MSG@44
PS1, Line 44: lookup
nit: look up
http://gerrit.cloudera.org:8080/#/c/20742/1/tests/authorization/test_ranger.py
File tests/authorization/test_ranger.py:
http://gerrit.cloudera.org:8080/#/c/20742/1/tests/authorization/test_ranger.py@1571
PS1, Line 1571: non_owner_client
Should this be renamed to 'non_admin_client' or 'owner_client'? It seems in this test we use this client to submit queries as the user getuser(), which is the owner of the table involved in the test and is a non-administrative user.
http://gerrit.cloudera.org:8080/#/c/20742/1/tests/authorization/test_ranger.py@1608
PS1, Line 1608: self.execute_query_expect_success(
: non_owner_client,
: "refresh functional.alltypestiny partition(year=2009, month=1)", user=user)
I observed the following 2 differences between the legacy and the local catalog modes when '--allow_catalog_cache_op_from_masked_users=true' is added. Don't know if I missed something. Are those differences expected?
The 1st difference: with respect to the REFRESH on a table.
Specifically, in the legacy catalog mode, I found this REFRESH on partitions is already allowed even without 'user' executing "describe functional.alltypestiny", whereas REFRESH on the same table is denied.
In addition, as shown in the following, in the legacy catalog mode, after a REFRESH on partitions is executed, the same "refresh functional.alltypestiny" will be allowed, which I think/guess is due to the table metadata being loaded (just like what happens after "describe functional.alltypestiny").
[localhost:21050] default> refresh functional.alltypestiny;
Query: refresh functional.alltypestiny
Query submitted at: 2023-12-03 11:38:56 (Coordinator: http://fangyu-upstream-dev.gce.cloudera.com:25000)
ERROR: AuthorizationException: User 'fangyurao' does not have privileges to execute 'INVALIDATE METADATA/REFRESH' on: functional.alltypestiny
[localhost:21050] default> refresh functional.alltypestiny partition(year=2009, month=1);
Query: refresh functional.alltypestiny partition(year=2009, month=1)
Query submitted at: 2023-12-03 11:39:04 (Coordinator: http://fangyu-upstream-dev.gce.cloudera.com:25000)
Query state can be monitored at: http://fangyu-upstream-dev.gce.cloudera.com:25000/query_plan?query_id=ba4e95cf064405e3:22bc528e00000000
[localhost:21050] default> refresh functional.alltypestiny;
Query: refresh functional.alltypestiny
Query submitted at: 2023-12-03 11:39:10 (Coordinator: http://fangyu-upstream-dev.gce.cloudera.com:25000)
Query state can be monitored at: http://fangyu-upstream-dev.gce.cloudera.com:25000/query_plan?query_id=7041cfffdf9bafac:0d1b547600000000
On the other hand, in the local catalog mode, both REFRESH on table and REFRESH on partitions are allowed.
The 2nd difference: with respect to INVALIDATE METADATA on a table following a REFRESH on the same table.
In the legacy catalog mode, a subsequent INVALIDATE METADATA on the same table is allowed once a REFRESH on partitions of this table is executed.
However, in the local catalog mode, even we execute both a REFRESH on the table and a REFRESH on partitions of the same table as 'user' successfully, an INVALIDATE METADATA on the same table is not allowed. In this case 'user' has to execute DESCRIBE on the table to execute INVALIDATE METADATA on the table successfully.
--
To view, visit http://gerrit.cloudera.org:8080/20742
To unsubscribe, visit http://gerrit.cloudera.org:8080/settings
Gerrit-Project: Impala-ASF
Gerrit-Branch: master
Gerrit-MessageType: comment
Gerrit-Change-Id: I45935654cbf05a55d740f1b04781022c271f7678
Gerrit-Change-Number: 20742
Gerrit-PatchSet: 1
Gerrit-Owner: Quanlong Huang <hu...@gmail.com>
Gerrit-Reviewer: Csaba Ringhofer <cs...@cloudera.com>
Gerrit-Reviewer: Fang-Yu Rao <fa...@cloudera.com>
Gerrit-Reviewer: Impala Public Jenkins <im...@cloudera.com>
Gerrit-Reviewer: Quanlong Huang <hu...@gmail.com>
Gerrit-Comment-Date: Sun, 03 Dec 2023 21:23:09 +0000
Gerrit-HasComments: Yes
[Impala-ASF-CR] IMPALA-11501: Add flag to allow catalog-cache operations on masked tables
Posted by "Quanlong Huang (Code Review)" <ge...@cloudera.org>.
Quanlong Huang has posted comments on this change. ( http://gerrit.cloudera.org:8080/20742 )
Change subject: IMPALA-11501: Add flag to allow catalog-cache operations on masked tables
......................................................................
Patch Set 2:
(11 comments)
http://gerrit.cloudera.org:8080/#/c/20742/1//COMMIT_MSG
Commit Message:
http://gerrit.cloudera.org:8080/#/c/20742/1//COMMIT_MSG@39
PS1, Line 39: doesn'
> nit: not always, as getTableIfCached() will return the correct table getTab
Ah, right. Let me rephrase this.
http://gerrit.cloudera.org:8080/#/c/20742/1//COMMIT_MSG@40
PS1, Line 40: ble, ge
> nit: doesn't
Done
http://gerrit.cloudera.org:8080/#/c/20742/1//COMMIT_MSG@41
PS1, Line 41: missi
> nit: not able to
Done
http://gerrit.cloudera.org:8080/#/c/20742/1//COMMIT_MSG@44
PS1, Line 44: can't
> nit: look up
Done
http://gerrit.cloudera.org:8080/#/c/20742/1/be/src/service/frontend.cc
File be/src/service/frontend.cc:
http://gerrit.cloudera.org:8080/#/c/20742/1/be/src/service/frontend.cc@94
PS1, Line 94: "level catalog-cache operations, i.e. REFRESH/INVALIDATE METADATA <table>, from users"
> line too long (91 > 90)
Done
http://gerrit.cloudera.org:8080/#/c/20742/1/fe/src/main/java/org/apache/impala/catalog/local/LocalDb.java
File fe/src/main/java/org/apache/impala/catalog/local/LocalDb.java:
http://gerrit.cloudera.org:8080/#/c/20742/1/fe/src/main/java/org/apache/impala/catalog/local/LocalDb.java@127
PS1, Line 127: tbl = new LocalIncompleteTable(this, tb
> This looks strange to me, as the function's name is getTableIfCached, but w
Yeah, for things that we won't cache in the local catalog of coordinator, we still trigger external RPCs to fetch them. I think we need a broader change to make the cache complete. There are some TODOs, e.g.
https://github.com/apache/impala/blob/2a8374d7eb17592e6280b15f9adb046a25f2fb85/fe/src/main/java/org/apache/impala/catalog/local/LocalFsTable.java#L194-L196
The alternative is a good idea! I'll use that instead.
http://gerrit.cloudera.org:8080/#/c/20742/1/fe/src/main/java/org/apache/impala/catalog/local/LocalDb.java@144
PS1, Line 144: tbl = LocalTable.load(this, tblName);
: } catch (TableLoadingException tle) {
: // If the table fails to load (eg a Kudu table that doesn't have
: // a backing table, or some other catalogd-side issue), turn it into
: // an IncompleteTable. This allows st
> This will load the table twice if loading it fails for some reason. Not rea
Resolved by using the alternative solution.
http://gerrit.cloudera.org:8080/#/c/20742/1/tests/authorization/test_ranger.py
File tests/authorization/test_ranger.py:
http://gerrit.cloudera.org:8080/#/c/20742/1/tests/authorization/test_ranger.py@1116
PS1, Line 1116: # getTableIfCached() in LocalCatalog loads a minimal incomplete table
: # that does not include the ownership information. Hence show tables
: # *never* show owned tables. TODO(bharathv): Fix in a follow up commit
: pytest.xfail("getTableIfCached() faulty behavior, known issue")
> Doesn't your change fix this too?
Not yet, getTableIfCached() still returns a LocalIncompleteTable if coordinator hasn't cached the table meta (TableMetaRefImpl).
http://gerrit.cloudera.org:8080/#/c/20742/1/tests/authorization/test_ranger.py@1562
PS1, Line 1562: catalogd_args=LOCAL_CATALOG_CATALOGD_ARGS)
: def test_allow_metadata_update_local_catalog(self, unique_name):
> Wouldn't it be better to run all tests with local catalog and add special h
Yeah, we should turn on local catalog by default and run all tests on it. Currently, we need to make sure the flag works in both catalog modes.
http://gerrit.cloudera.org:8080/#/c/20742/1/tests/authorization/test_ranger.py@1571
PS1, Line 1571: non_admin_client
> Should this be renamed to 'non_admin_client' or 'owner_client'? It seems in
Yeah, 'non_admin_client' is better.
http://gerrit.cloudera.org:8080/#/c/20742/1/tests/authorization/test_ranger.py@1608
PS1, Line 1608: self.execute_query_expect_success(
: non_admin_client,
: "refresh functional.alltypestiny partition(year=2009, month=1)", user=user)
Nice findings!
REFRESH on partitions always triggers metadata loading regardless of what catalog mode is used:
https://github.com/apache/impala/blob/4c762725c707f8d150fe250c03faf486008702d4/fe/src/main/java/org/apache/impala/analysis/ResetMetadataStmt.java#L144-L146
This is expected since we need metadata to analyze the partition columns. The ownership info is loaded by the way.
The difference on REFRESH on tables is due to this getTable() invocation:
https://github.com/apache/impala/blob/4c762725c707f8d150fe250c03faf486008702d4/fe/src/main/java/org/apache/impala/analysis/Analyzer.java#L3847
It's called from
https://github.com/apache/impala/blob/4c762725c707f8d150fe250c03faf486008702d4/fe/src/main/java/org/apache/impala/analysis/ResetMetadataStmt.java#L165
In local catalog mode, getTable() will trigger metadata loading so the ownership info is loaded. I think we should use getTableIfCached() instead, which matches the comments in ResetMetadataStmt#analyze():
> Don't call getTable() to avoid loading the table metadata if it is not yet in this impalad's catalog cache.
However, dbContainsTable() is used in several places. To limit the impact of this patch, it'd be better to revisit it in another JIRA. I filed IMPALA-12591 for this.
In the current patch, I think we should add a warning when the ownership is unknown (unloaded).
For the 2nd difference, it's due to whether the table is loaded in coordinator side. In the legacy catalog mode, coordinator mirros the catalog cache from catalogd. Once the table is loaded in catalogd, it's also loaded in the coordinator side. That's the state when the REFRESH finished.
However, in local catalog mode, coordinator maintains its own cache. When the REFRESH finishes in catalogd, coordinator invalidates the local cache of the table meta. It will be fetched next time it's needed. In this case, the ownership info is missing when analyzing the following INVALIDATE METADATA command. Note that we are calling getTableIfCached() for INVALIDATE METADATA. It won't load the table from catalogd.
--
To view, visit http://gerrit.cloudera.org:8080/20742
To unsubscribe, visit http://gerrit.cloudera.org:8080/settings
Gerrit-Project: Impala-ASF
Gerrit-Branch: master
Gerrit-MessageType: comment
Gerrit-Change-Id: I45935654cbf05a55d740f1b04781022c271f7678
Gerrit-Change-Number: 20742
Gerrit-PatchSet: 2
Gerrit-Owner: Quanlong Huang <hu...@gmail.com>
Gerrit-Reviewer: Csaba Ringhofer <cs...@cloudera.com>
Gerrit-Reviewer: Fang-Yu Rao <fa...@cloudera.com>
Gerrit-Reviewer: Impala Public Jenkins <im...@cloudera.com>
Gerrit-Reviewer: Quanlong Huang <hu...@gmail.com>
Gerrit-Comment-Date: Mon, 04 Dec 2023 08:11:43 +0000
Gerrit-HasComments: Yes
[Impala-ASF-CR] IMPALA-11501: Add flag to allow catalog-cache operations on masked tables
Posted by "Impala Public Jenkins (Code Review)" <ge...@cloudera.org>.
Impala Public Jenkins has posted comments on this change. ( http://gerrit.cloudera.org:8080/20742 )
Change subject: IMPALA-11501: Add flag to allow catalog-cache operations on masked tables
......................................................................
Patch Set 1:
(1 comment)
http://gerrit.cloudera.org:8080/#/c/20742/1/be/src/service/frontend.cc
File be/src/service/frontend.cc:
http://gerrit.cloudera.org:8080/#/c/20742/1/be/src/service/frontend.cc@94
PS1, Line 94: "level catalog-cache operations, i.e. REFRESH/INVALIDATE METADATA <table>, from users "
line too long (91 > 90)
--
To view, visit http://gerrit.cloudera.org:8080/20742
To unsubscribe, visit http://gerrit.cloudera.org:8080/settings
Gerrit-Project: Impala-ASF
Gerrit-Branch: master
Gerrit-MessageType: comment
Gerrit-Change-Id: I45935654cbf05a55d740f1b04781022c271f7678
Gerrit-Change-Number: 20742
Gerrit-PatchSet: 1
Gerrit-Owner: Quanlong Huang <hu...@gmail.com>
Gerrit-Reviewer: Impala Public Jenkins <im...@cloudera.com>
Gerrit-Comment-Date: Thu, 30 Nov 2023 11:45:28 +0000
Gerrit-HasComments: Yes
[Impala-ASF-CR] IMPALA-11501: Add flag to allow catalog-cache operations on masked tables
Posted by "Csaba Ringhofer (Code Review)" <ge...@cloudera.org>.
Csaba Ringhofer has posted comments on this change. ( http://gerrit.cloudera.org:8080/20742 )
Change subject: IMPALA-11501: Add flag to allow catalog-cache operations on masked tables
......................................................................
Patch Set 1:
(5 comments)
http://gerrit.cloudera.org:8080/#/c/20742/1//COMMIT_MSG
Commit Message:
http://gerrit.cloudera.org:8080/#/c/20742/1//COMMIT_MSG@39
PS1, Line 39: always
nit: not always, as getTableIfCached() will return the correct table getTable() was called first as the loaded table will be put to tables_.
http://gerrit.cloudera.org:8080/#/c/20742/1/fe/src/main/java/org/apache/impala/catalog/local/LocalDb.java
File fe/src/main/java/org/apache/impala/catalog/local/LocalDb.java:
http://gerrit.cloudera.org:8080/#/c/20742/1/fe/src/main/java/org/apache/impala/catalog/local/LocalDb.java@127
PS1, Line 127: tbl = LocalTable.load(this, tblMeta);
This looks strange to me, as the function's name is getTableIfCached, but we seem to load the table if it is not cached. I checked the Kudu path, and this will actually use the Kudu client to fetch metadata from Kudu, so not all metadata used here comes from the cache.
This may be the right thing to do in local catalog, but some comments could be added to make this clearer.
An alternative could be to call setMetaStoreTable(msTbl) on the LocalIncompleteTable so that the owner will be known.
http://gerrit.cloudera.org:8080/#/c/20742/1/fe/src/main/java/org/apache/impala/catalog/local/LocalDb.java@144
PS1, Line 144: FeTable tbl = getTableIfCached(tblName);
: if (tbl instanceof LocalIncompleteTable) {
: // The table exists but hasn't been loaded yet.
: try {
: tbl = LocalTable.load(this, tblName);
This will load the table twice if loading it fails for some reason. Not really a bug but it looks strange.
http://gerrit.cloudera.org:8080/#/c/20742/1/tests/authorization/test_ranger.py
File tests/authorization/test_ranger.py:
http://gerrit.cloudera.org:8080/#/c/20742/1/tests/authorization/test_ranger.py@1116
PS1, Line 1116: # getTableIfCached() in LocalCatalog loads a minimal incomplete table
: # that does not include the ownership information. Hence show tables
: # *never* show owned tables. TODO(bharathv): Fix in a follow up commit
: pytest.xfail("getTableIfCached() faulty behavior, known issue")
Doesn't your change fix this too?
http://gerrit.cloudera.org:8080/#/c/20742/1/tests/authorization/test_ranger.py@1562
PS1, Line 1562: catalogd_args=LOCAL_CATALOG_CATALOGD_ARGS)
: def test_allow_metadata_update_local_catalog(self, unique_name):
Wouldn't it be better to run all tests with local catalog and add special handling to the ones where this makes a difference?
It looks strange to me that several tests do not run with local catalog while it local catalog seems to be the main direction for Impala.
--
To view, visit http://gerrit.cloudera.org:8080/20742
To unsubscribe, visit http://gerrit.cloudera.org:8080/settings
Gerrit-Project: Impala-ASF
Gerrit-Branch: master
Gerrit-MessageType: comment
Gerrit-Change-Id: I45935654cbf05a55d740f1b04781022c271f7678
Gerrit-Change-Number: 20742
Gerrit-PatchSet: 1
Gerrit-Owner: Quanlong Huang <hu...@gmail.com>
Gerrit-Reviewer: Csaba Ringhofer <cs...@cloudera.com>
Gerrit-Reviewer: Fang-Yu Rao <fa...@cloudera.com>
Gerrit-Reviewer: Impala Public Jenkins <im...@cloudera.com>
Gerrit-Reviewer: Quanlong Huang <hu...@gmail.com>
Gerrit-Comment-Date: Fri, 01 Dec 2023 12:10:41 +0000
Gerrit-HasComments: Yes
[Impala-ASF-CR] IMPALA-11501: Add flag to allow catalog-cache operations on masked tables
Posted by "Quanlong Huang (Code Review)" <ge...@cloudera.org>.
Hello Fang-Yu Rao, Csaba Ringhofer, Impala Public Jenkins,
I'd like you to reexamine a change. Please visit
http://gerrit.cloudera.org:8080/20742
to look at the new patch set (#2).
Change subject: IMPALA-11501: Add flag to allow catalog-cache operations on masked tables
......................................................................
IMPALA-11501: Add flag to allow catalog-cache operations on masked tables
REFRESH/INVALIDATE METADATA <table> are the table level catalog-cache
operations. In Hive-Ranger plugin, when a table is masked (either by
column-masking or row-filtering policy) for a user, the user is unable
to perform any modification (insert/delete/update) on the table, i.e.
it's considered a read-only user (RANGER-1087, RANGER-1100). However,
Hive doesn't have these catalog-cache operations. It's a grey area
whether they should be blocked.
Before this patch, these catalog-cache operations are considered as
modifications on the table so they are also blocked for masked users.
Table metadata is required to be loaded so we have the column names to
fetch Ranger column masking policies. This causes a performance
regression on INVALIDATE METADATA <table> commands since in older
versions (e.g. CDH), IM commands don't need to load the table metadata
and runs pretty fast.
This patch adds a flag, allow_catalog_cache_op_from_masked_users, for
coordinators to skip checking masking policies for such statements. When
this flag is on, coordinators don't need to load the table metadata thus
fix the performance regression as well.
Note that Ranger ownership based policies can't be applied correctly
when the table is unloaded (so the owner is unknown). REFRESH/INVALIDATE
METADATA <table> commands could be denied on owners even if there are
Ranger policies allowing the owner's operations. This is a known issue
since IMPALA-8228. To ensure a user can always perform these operations,
grant REFRESH privilege to them to get rid of the unloaded table issue.
This patch also fixes a bug in local catalog mode which only occurs
after adding the new flag. The bug is that LocalDb#getTableIfCached()
doesn't make good use of the cache. If the table meta is cahced but
LocalDb#getTable() hasn't been invoked on the table, getTableIfCached()
will always return a LocalIncompleteTable which is missing some table
info, e.g. ownership. This causes REFRESH/INVALIDATE statements not able
to pass the ownership context to RangerAccessResourceImpl so ownership
policies can't be correctly applied.
Ideally, LocalDb#getTableIfCached() should return a LocalTable instance
if the table is cached. However, in local catalog mode, we don't cache
everything that constructs a LocalTable instance. Constructing a
LocalTable instance might still trigger external RPCs which should be
avoided. As an alternative, this patch checks if the msTable is cached.
If it's cached, add it to the LocalIncompleteTable instance so most of
the table info can be retrieved, including the ownership string.
Tests:
- Add e2e tests on both the legacy and local catalog mode.
Change-Id: I45935654cbf05a55d740f1b04781022c271f7678
---
M be/src/service/frontend.cc
M be/src/util/backend-gflag-util.cc
M common/thrift/BackendGflags.thrift
M fe/src/main/java/org/apache/impala/analysis/StmtMetadataLoader.java
M fe/src/main/java/org/apache/impala/authorization/BaseAuthorizationChecker.java
M fe/src/main/java/org/apache/impala/authorization/Privilege.java
M fe/src/main/java/org/apache/impala/catalog/Table.java
M fe/src/main/java/org/apache/impala/catalog/local/CatalogdMetaProvider.java
M fe/src/main/java/org/apache/impala/catalog/local/DirectMetaProvider.java
M fe/src/main/java/org/apache/impala/catalog/local/LocalDb.java
M fe/src/main/java/org/apache/impala/catalog/local/LocalIncompleteTable.java
M fe/src/main/java/org/apache/impala/catalog/local/LocalTable.java
M fe/src/main/java/org/apache/impala/catalog/local/MetaProvider.java
M fe/src/main/java/org/apache/impala/service/BackendConfig.java
M tests/authorization/test_ranger.py
15 files changed, 181 insertions(+), 12 deletions(-)
git pull ssh://gerrit.cloudera.org:29418/Impala-ASF refs/changes/42/20742/2
--
To view, visit http://gerrit.cloudera.org:8080/20742
To unsubscribe, visit http://gerrit.cloudera.org:8080/settings
Gerrit-Project: Impala-ASF
Gerrit-Branch: master
Gerrit-MessageType: newpatchset
Gerrit-Change-Id: I45935654cbf05a55d740f1b04781022c271f7678
Gerrit-Change-Number: 20742
Gerrit-PatchSet: 2
Gerrit-Owner: Quanlong Huang <hu...@gmail.com>
Gerrit-Reviewer: Csaba Ringhofer <cs...@cloudera.com>
Gerrit-Reviewer: Fang-Yu Rao <fa...@cloudera.com>
Gerrit-Reviewer: Impala Public Jenkins <im...@cloudera.com>
Gerrit-Reviewer: Quanlong Huang <hu...@gmail.com>
[Impala-ASF-CR] IMPALA-11501: Add flag to allow catalog-cache operations on masked tables
Posted by "Impala Public Jenkins (Code Review)" <ge...@cloudera.org>.
Impala Public Jenkins has posted comments on this change. ( http://gerrit.cloudera.org:8080/20742 )
Change subject: IMPALA-11501: Add flag to allow catalog-cache operations on masked tables
......................................................................
Patch Set 4:
Build started: https://jenkins.impala.io/job/gerrit-verify-dryrun/10030/ DRY_RUN=false
--
To view, visit http://gerrit.cloudera.org:8080/20742
To unsubscribe, visit http://gerrit.cloudera.org:8080/settings
Gerrit-Project: Impala-ASF
Gerrit-Branch: master
Gerrit-MessageType: comment
Gerrit-Change-Id: I45935654cbf05a55d740f1b04781022c271f7678
Gerrit-Change-Number: 20742
Gerrit-PatchSet: 4
Gerrit-Owner: Quanlong Huang <hu...@gmail.com>
Gerrit-Reviewer: Csaba Ringhofer <cs...@cloudera.com>
Gerrit-Reviewer: Fang-Yu Rao <fa...@cloudera.com>
Gerrit-Reviewer: Impala Public Jenkins <im...@cloudera.com>
Gerrit-Reviewer: Quanlong Huang <hu...@gmail.com>
Gerrit-Comment-Date: Wed, 13 Dec 2023 23:32:45 +0000
Gerrit-HasComments: No
[Impala-ASF-CR] IMPALA-11501: Add flag to allow catalog-cache operations on masked tables
Posted by "Csaba Ringhofer (Code Review)" <ge...@cloudera.org>.
Csaba Ringhofer has posted comments on this change. ( http://gerrit.cloudera.org:8080/20742 )
Change subject: IMPALA-11501: Add flag to allow catalog-cache operations on masked tables
......................................................................
Patch Set 2: Code-Review+1
--
To view, visit http://gerrit.cloudera.org:8080/20742
To unsubscribe, visit http://gerrit.cloudera.org:8080/settings
Gerrit-Project: Impala-ASF
Gerrit-Branch: master
Gerrit-MessageType: comment
Gerrit-Change-Id: I45935654cbf05a55d740f1b04781022c271f7678
Gerrit-Change-Number: 20742
Gerrit-PatchSet: 2
Gerrit-Owner: Quanlong Huang <hu...@gmail.com>
Gerrit-Reviewer: Csaba Ringhofer <cs...@cloudera.com>
Gerrit-Reviewer: Fang-Yu Rao <fa...@cloudera.com>
Gerrit-Reviewer: Impala Public Jenkins <im...@cloudera.com>
Gerrit-Reviewer: Quanlong Huang <hu...@gmail.com>
Gerrit-Comment-Date: Thu, 07 Dec 2023 09:30:12 +0000
Gerrit-HasComments: No
[Impala-ASF-CR] IMPALA-11501: Add flag to allow catalog-cache operations on masked tables
Posted by "Quanlong Huang (Code Review)" <ge...@cloudera.org>.
Hello Fang-Yu Rao, Csaba Ringhofer, Impala Public Jenkins,
I'd like you to reexamine a change. Please visit
http://gerrit.cloudera.org:8080/20742
to look at the new patch set (#3).
Change subject: IMPALA-11501: Add flag to allow catalog-cache operations on masked tables
......................................................................
IMPALA-11501: Add flag to allow catalog-cache operations on masked tables
REFRESH/INVALIDATE METADATA <table> are the table level catalog-cache
operations. In Hive-Ranger plugin, when a table is masked (either by
column-masking or row-filtering policy) for a user, the user is unable
to perform any modification (insert/delete/update) on the table, i.e.
it's considered a read-only user (RANGER-1087, RANGER-1100). However,
Hive doesn't have these catalog-cache operations. It's a grey area
whether they should be blocked.
Before this patch, these catalog-cache operations are considered as
modifications on the table so they are also blocked for masked users.
Table metadata is required to be loaded so we have the column names to
fetch Ranger column masking policies. This causes a performance
regression on INVALIDATE METADATA <table> commands since in older
versions (e.g. CDH), IM commands don't need to load the table metadata
and runs pretty fast.
This patch adds a flag, allow_catalog_cache_op_from_masked_users, for
coordinators to skip checking masking policies for such statements. When
this flag is on, coordinators don't need to load the table metadata thus
fix the performance regression as well.
Note that Ranger ownership based policies can't be applied correctly
when the table is unloaded (so the owner is unknown). REFRESH/INVALIDATE
METADATA <table> commands could be denied on owners even if there are
Ranger policies allowing the owner's operations. This is a known issue
since IMPALA-8228. To ensure a user can always perform these operations,
grant REFRESH privilege to them to get rid of the unloaded table issue.
This patch also fixes a bug in local catalog mode which only occurs
after adding the new flag. The bug is that LocalDb#getTableIfCached()
doesn't make good use of the cache. If the table meta is cahced but
LocalDb#getTable() hasn't been invoked on the table, getTableIfCached()
will always return a LocalIncompleteTable which is missing some table
info, e.g. ownership. This causes REFRESH/INVALIDATE statements not able
to pass the ownership context to RangerAccessResourceImpl so ownership
policies can't be correctly applied.
Ideally, LocalDb#getTableIfCached() should return a LocalTable instance
if the table is cached. However, in local catalog mode, we don't cache
everything that constructs a LocalTable instance. Constructing a
LocalTable instance might still trigger external RPCs which should be
avoided. As an alternative, this patch checks if the msTable is cached.
If it's cached, add it to the LocalIncompleteTable instance so most of
the table info can be retrieved, including the ownership string.
Tests:
- Add e2e tests on both the legacy and local catalog mode.
Change-Id: I45935654cbf05a55d740f1b04781022c271f7678
---
M be/src/service/frontend.cc
M be/src/util/backend-gflag-util.cc
M common/thrift/BackendGflags.thrift
M fe/src/main/java/org/apache/impala/analysis/StmtMetadataLoader.java
M fe/src/main/java/org/apache/impala/authorization/BaseAuthorizationChecker.java
M fe/src/main/java/org/apache/impala/authorization/Privilege.java
M fe/src/main/java/org/apache/impala/catalog/Table.java
M fe/src/main/java/org/apache/impala/catalog/local/CatalogdMetaProvider.java
M fe/src/main/java/org/apache/impala/catalog/local/DirectMetaProvider.java
M fe/src/main/java/org/apache/impala/catalog/local/LocalDb.java
M fe/src/main/java/org/apache/impala/catalog/local/LocalIncompleteTable.java
M fe/src/main/java/org/apache/impala/catalog/local/LocalTable.java
M fe/src/main/java/org/apache/impala/catalog/local/MetaProvider.java
M fe/src/main/java/org/apache/impala/service/BackendConfig.java
M tests/authorization/test_ranger.py
15 files changed, 188 insertions(+), 12 deletions(-)
git pull ssh://gerrit.cloudera.org:29418/Impala-ASF refs/changes/42/20742/3
--
To view, visit http://gerrit.cloudera.org:8080/20742
To unsubscribe, visit http://gerrit.cloudera.org:8080/settings
Gerrit-Project: Impala-ASF
Gerrit-Branch: master
Gerrit-MessageType: newpatchset
Gerrit-Change-Id: I45935654cbf05a55d740f1b04781022c271f7678
Gerrit-Change-Number: 20742
Gerrit-PatchSet: 3
Gerrit-Owner: Quanlong Huang <hu...@gmail.com>
Gerrit-Reviewer: Csaba Ringhofer <cs...@cloudera.com>
Gerrit-Reviewer: Fang-Yu Rao <fa...@cloudera.com>
Gerrit-Reviewer: Impala Public Jenkins <im...@cloudera.com>
Gerrit-Reviewer: Quanlong Huang <hu...@gmail.com>