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

Samarth Jain commented on PHOENIX-2901:
---------------------------------------

Thanks for the patch, [~an...@apache.org]. Looking at this piece of code in 
MetadataClient#createIndex,

{code}
if (allocateIndexId && indexId == null) {
                    Long scn = connection.getSCN();
                    PName tenantId = connection.getTenantId();
                    String tenantIdStr = tenantId == null ? null : 
connection.getTenantId().getString();
                    PName physicalName = dataTable.getPhysicalName();
                    int nSequenceSaltBuckets = 
connection.getQueryServices().getSequenceSaltBuckets();
                    SequenceKey key = 
MetaDataUtil.getViewIndexSequenceKey(tenantIdStr, physicalName, 
nSequenceSaltBuckets);
                    // if scn is set create at scn-1, so we can see the 
sequence or else use latest timestamp (so that latest server time is used)
                    long sequenceTimestamp = scn!=null ? scn-1 : 
HConstants.LATEST_TIMESTAMP;
                    createSequence(key.getTenantId(), key.getSchemaName(), 
key.getSequenceName(),
                        true, Short.MIN_VALUE, 1, 1, false, Long.MIN_VALUE, 
Long.MAX_VALUE,
                        sequenceTimestamp);
{code}
it looks like for tenant specific indexes on views, view index sequences have 
tenantids too. So I am not sure if MetadataUtil#deleteViewIndexSequences is 
dropping those view index sequences too. In any case, it is worth writing test 
cases for multi-tenant tables, creating tenant specific and non-tenant specific 
(global) views on them, creating tenant-specific  and global view indexes on 
them, asserting correct sequences are created and whether they get deleted with 
and without namespace mapping enabled. 

Also, it would be good to add a test where you are creating a sequence by 
setting the namespace name as a property on the PhoenixConnection.

> If namespaces are enabled, check for existence of schema when sequence created
> ------------------------------------------------------------------------------
>
>                 Key: PHOENIX-2901
>                 URL: https://issues.apache.org/jira/browse/PHOENIX-2901
>             Project: Phoenix
>          Issue Type: Bug
>    Affects Versions: 4.8.0
>            Reporter: James Taylor
>            Assignee: Ankit Singhal
>             Fix For: 4.8.0
>
>         Attachments: PHOENIX-2901.patch, PHOENIX-2901_withMoreTestCases.patch
>
>
> If namespaces are enabled, we should check for the existence of the sequence 
> schema before creating the sequence. There are some sequences that are 
> generated by Phoenix to manage indexes over views which auto generate a 
> schema name. Perhaps it'd be better if those used the SYSTEM schema instead 
> and prepended the sequence name with the previous schema name to ensure 
> uniqueness.



--
This message was sent by Atlassian JIRA
(v6.3.4#6332)

Reply via email to