You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@phoenix.apache.org by ankitsinghal <gi...@git.apache.org> on 2016/09/27 09:29:59 UTC

[GitHub] phoenix pull request #211: PHOENIX-3254 IndexId Sequence is incremented even...

GitHub user ankitsinghal opened a pull request:

    https://github.com/apache/phoenix/pull/211

    PHOENIX-3254 IndexId Sequence is incremented even if index exists alr\u2026

    \u2026eady

You can merge this pull request into a Git repository by running:

    $ git pull https://github.com/ankitsinghal/phoenix PHOENIX-3254

Alternatively you can review and apply these changes as the patch at:

    https://github.com/apache/phoenix/pull/211.patch

To close this pull request, make a commit to your master/trunk branch
with (at least) the following in the commit message:

    This closes #211
    
----
commit 5268a90d38c21e8f93b8b2782f2d9e146642a463
Author: Ankit Singhal <an...@gmail.com>
Date:   2016-09-27T09:29:11Z

    PHOENIX-3254 IndexId Sequence is incremented even if index exists already

----


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

[GitHub] phoenix pull request #211: PHOENIX-3254 IndexId Sequence is incremented even...

Posted by chrajeshbabu <gi...@git.apache.org>.
Github user chrajeshbabu commented on a diff in the pull request:

    https://github.com/apache/phoenix/pull/211#discussion_r80916280
  
    --- Diff: phoenix-core/src/main/java/org/apache/phoenix/coprocessor/MetaDataEndpointImpl.java ---
    @@ -1499,6 +1502,53 @@ public void createTable(RpcController controller, CreateTableRequest request,
                             cell.getTimestamp(), Type.codeToType(cell.getTypeByte()), bytes);
                         cells.add(viewConstantCell);
                     }
    +                Short indexId = null;
    +                if (request.hasAllocateIndexId() && request.getAllocateIndexId()) {
    +                    String tenantIdStr = tenantIdBytes.length == 0 ? null : Bytes.toString(tenantIdBytes);
    +                    final Properties props = new Properties();
    +                    UpgradeUtil.doNotUpgradeOnFirstConnection(props);
    +                    try (PhoenixConnection connection = DriverManager.getConnection(MetaDataUtil.getJdbcUrl(env), props).unwrap(PhoenixConnection.class)){
    +                    PName physicalName = parentTable.getPhysicalName();
    +                    int nSequenceSaltBuckets = connection.getQueryServices().getSequenceSaltBuckets();
    +                    SequenceKey key = MetaDataUtil.getViewIndexSequenceKey(tenantIdStr, physicalName,
    +                            nSequenceSaltBuckets, parentTable.isNamespaceMapped() );
    +                        // TODO Review Earlier sequence was created at (SCN-1/LATEST_TIMESTAMP) and incremented at the client max(SCN,dataTable.getTimestamp), but it seems we should
    +                        // use always LATEST_TIMESTAMP to avoid seeing wrong sequence values by different connection having SCN
    +                        // or not. 
    +                    long sequenceTimestamp = HConstants.LATEST_TIMESTAMP;
    +                    try {
    +                        connection.getQueryServices().createSequence(key.getTenantId(), key.getSchemaName(), key.getSequenceName(),
    --- End diff --
    
    @ankitsinghal  This patch introducing inter table rpc calls but seems it's needed. What do you think of moving create sequence to meta data client and perform sequence increment alone here? So that atleast we can reduce the rpc calls here.


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

[GitHub] phoenix pull request #211: PHOENIX-3254 IndexId Sequence is incremented even...

Posted by chrajeshbabu <gi...@git.apache.org>.
Github user chrajeshbabu commented on a diff in the pull request:

    https://github.com/apache/phoenix/pull/211#discussion_r80925250
  
    --- Diff: phoenix-core/src/main/java/org/apache/phoenix/query/ConnectionQueryServicesImpl.java ---
    @@ -1445,6 +1445,9 @@ public MetaDataResponse call(MetaDataService instance) throws IOException {
                         builder.addTableMetadataMutations(mp.toByteString());
                     }
                     builder.setClientVersion(VersionUtil.encodeVersion(PHOENIX_MAJOR_VERSION, PHOENIX_MINOR_VERSION, PHOENIX_PATCH_NUMBER));
    +                        if (allocateIndexId) {
    --- End diff --
    
    nit: just format code here.


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

[GitHub] phoenix issue #211: PHOENIX-3254 IndexId Sequence is incremented even if ind...

Posted by JamesRTaylor <gi...@git.apache.org>.
Github user JamesRTaylor commented on the issue:

    https://github.com/apache/phoenix/pull/211
  
    +1 on the changes (but please fix any formatting issues). Nice work, @ankitsinghal.


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

[GitHub] phoenix pull request #211: PHOENIX-3254 IndexId Sequence is incremented even...

Posted by JamesRTaylor <gi...@git.apache.org>.
Github user JamesRTaylor commented on a diff in the pull request:

    https://github.com/apache/phoenix/pull/211#discussion_r80950387
  
    --- Diff: phoenix-core/src/main/java/org/apache/phoenix/coprocessor/MetaDataEndpointImpl.java ---
    @@ -1499,6 +1502,53 @@ public void createTable(RpcController controller, CreateTableRequest request,
                             cell.getTimestamp(), Type.codeToType(cell.getTypeByte()), bytes);
                         cells.add(viewConstantCell);
                     }
    +                Short indexId = null;
    +                if (request.hasAllocateIndexId() && request.getAllocateIndexId()) {
    +                    String tenantIdStr = tenantIdBytes.length == 0 ? null : Bytes.toString(tenantIdBytes);
    +                    final Properties props = new Properties();
    +                    UpgradeUtil.doNotUpgradeOnFirstConnection(props);
    +                    try (PhoenixConnection connection = DriverManager.getConnection(MetaDataUtil.getJdbcUrl(env), props).unwrap(PhoenixConnection.class)){
    +                    PName physicalName = parentTable.getPhysicalName();
    +                    int nSequenceSaltBuckets = connection.getQueryServices().getSequenceSaltBuckets();
    +                    SequenceKey key = MetaDataUtil.getViewIndexSequenceKey(tenantIdStr, physicalName,
    +                            nSequenceSaltBuckets, parentTable.isNamespaceMapped() );
    +                        // TODO Review Earlier sequence was created at (SCN-1/LATEST_TIMESTAMP) and incremented at the client max(SCN,dataTable.getTimestamp), but it seems we should
    +                        // use always LATEST_TIMESTAMP to avoid seeing wrong sequence values by different connection having SCN
    +                        // or not. 
    +                    long sequenceTimestamp = HConstants.LATEST_TIMESTAMP;
    +                    try {
    +                        connection.getQueryServices().createSequence(key.getTenantId(), key.getSchemaName(), key.getSequenceName(),
    --- End diff --
    
    The RPCs are minimal here because of the way sequences are implemented. By default, we cache 100 sequences and dole them out as needed. So there's only a single RPC per 100 invocations of this.


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastructure@apache.org or file a JIRA ticket
with INFRA.
---