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

Geoffrey Jacoby commented on PHOENIX-5362:
------------------------------------------

[~ckulkarni] - Right, I'd traced through the code and figured out that that was 
the general flow, but I still don't see the source of the problem, since HBase 
Scans are meant to ride over region boundaries. Phoenix breaks a simple query 
up into multiple Scans for reasons of performance and scalability so they can 
be run in parallel, not correctness. So so long as the Scans cover the whole 
keyspace you're looking for (and for an index rebuild it's the whole keyspace), 
an old "out-of-date" Scan should still be fine. It'll just be less efficient if 
it spans regions. 

What I've been trying to figure out is if there's a scenario where retrying a 
mapper, and having an out-of-sync Scan and query plan can somehow change the 
semantics of the query, causing us to miss things. 

As for the timestamps, I don't _think_ it's a problem unless the index gets 
disabled (fixed recently by PHOENIX-5473), but please let me know if I'm 
missing something with any of the above. 

> Mappers should use the queryPlan from the driver rather than regenerating the 
> plan
> ----------------------------------------------------------------------------------
>
>                 Key: PHOENIX-5362
>                 URL: https://issues.apache.org/jira/browse/PHOENIX-5362
>             Project: Phoenix
>          Issue Type: Improvement
>            Reporter: Chinmay Kulkarni
>            Priority: Major
>             Fix For: 4.15.1, 5.1.1
>
>
> Currently, PhoenixInputFormat#getQueryPlan already generates a queryPlan and 
> we use this plan to get the scans and splits for the MR job. In 
> PhoenixInputFormat#createRecordReader which is called inside each mapper, we 
> again create a queryPlan and pass this to the PhoenixRecordReader instance.
> There are multiple problems with this approach:
> # The mappers already have information about the scans from the driver code. 
> We potentially just need to wrap these scans in an iterator and create a 
> subsequent ResultSet.
> # The mappers don't need most of the information embedded within a queryPlan, 
> so they shouldn't need to regenerate the plan.
> # There are weird corner cases that can occur if we replan the query in each 
> mapper. For ex: If there is an index creation or metadata change in between 
> when the MR job was created, and when the mappers actually launch. In this 
> case, the mappers have the scans created for the first queryPlan, but the 
> mappers will use iterators created for the second queryPlan. In such cases, 
> the issued scans would not match the queryPlan embedded in the mappers' 
> iterators/ResultSet. We could potentially miss some scans/be looking for more 
> than we actually require since we check the original scans for this size. The 
> resolved table would be as per the new queryPlan, and there could be a 
> mismatch here as well (considering the index creation case). There are 
> potentially other repercussions in case of intermediary metadata changes as 
> well.
> Serializing a subset of the information (like the projector, which iterator 
> to use, etc.) of a QueryPlan and passing it from the driver to the mappers 
> without having them regenerate the plans seems like the best way forward.



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

Reply via email to