[ 
https://issues.apache.org/jira/browse/PHOENIX-6155?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=17233563#comment-17233563
 ] 

ASF GitHub Bot commented on PHOENIX-6155:
-----------------------------------------

virajjasani commented on a change in pull request #960:
URL: https://github.com/apache/phoenix/pull/960#discussion_r524928082



##########
File path: phoenix-core/src/main/java/org/apache/phoenix/schema/task/Task.java
##########
@@ -75,6 +87,55 @@ public Void run() throws Exception {
         }
     }
 
+    private static List<Mutation> getMutationsForSystemTaskTable(
+            PhoenixConnection conn, PreparedStatement stmt,
+            boolean accessCheckEnabled) throws IOException {
+        // we need to mutate SYSTEM.TASK with HBase/login user if access is 
enabled.
+        if (accessCheckEnabled) {
+            return User.runAsLoginUser(() -> {
+                final RpcCall rpcContext = RpcUtil.getRpcContext();
+                // setting RPC context as null so that user can be reset
+                try {
+                    RpcUtil.setRpcContext(null);
+                    stmt.execute();
+                    // retrieve mutations for SYSTEM.TASK upsert query
+                    Iterator<Pair<byte[], List<Mutation>>> iterator =
+                        conn.getMutationState().toMutations();
+                    List<Mutation> taskMutations = iterator.next().getSecond();
+                    // we are expecting conn to be used for single upsert

Review comment:
       Added new connection in `getMutationsForAddTask()` to resolve this.
   Thanks




----------------------------------------------------------------
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:
us...@infra.apache.org


> Prevent doing direct upserts into SYSTEM.TASK from the client
> -------------------------------------------------------------
>
>                 Key: PHOENIX-6155
>                 URL: https://issues.apache.org/jira/browse/PHOENIX-6155
>             Project: Phoenix
>          Issue Type: Improvement
>    Affects Versions: 5.0.0, 4.15.0
>            Reporter: Chinmay Kulkarni
>            Assignee: Viraj Jasani
>            Priority: Major
>             Fix For: 5.1.0, 4.16.0
>
>         Attachments: PHOENIX-6155.4.x.000.patch, PHOENIX-6155.4.x.001.patch, 
> PHOENIX-6155.4.x.002.patch
>
>
> In environments with namespace-mapping enabled, we will have to grant write 
> access to clients in order to make direct upserts into SYSTEM.TASK. Currently 
> we add a task from the client-side 
> [here|https://github.com/apache/phoenix/blob/4.x/phoenix-core/src/main/java/org/apache/phoenix/schema/MetaDataClient.java#L4654].
>  In order to implement other Jiras like 
> [PHOENIX-6154|https://issues.apache.org/jira/browse/PHOENIX-6154] we also may 
> need to interact with the SYSTEM.TASK table from the client-side.
> Instead of doing direct upserts into this table, we should add an endpoint on 
> SYSTEM.TASK and clients should interact with that.



--
This message was sent by Atlassian Jira
(v8.3.4#803005)

Reply via email to