You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@hive.apache.org by "Lefty Leverenz (JIRA)" <ji...@apache.org> on 2018/01/02 05:10:00 UTC

[jira] [Commented] (HIVE-16143) Improve msck repair batching

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

Lefty Leverenz commented on HIVE-16143:
---------------------------------------

Doc note:  This adds *hive.msck.repair.batch.max.retries* and revises the description of *hive.msck.repair.batch.size* in release 2.4.0, so the wiki needs to be updated.

* [Configuration Properties -- hive.msck.repair.batch.size | https://cwiki.apache.org/confluence/display/Hive/Configuration+Properties#ConfigurationProperties-hive.msck.repair.batch.size]
* [Configuration Properties -- hive.msck.repair.batch.max.retries | https://cwiki.apache.org/confluence/display/Hive/Configuration+Properties#ConfigurationProperties-hive.msck.repair.batch.max.retries] (this link won't work until the parameter is documented)

Added a TODOC2.4 label.  (Please add your own TODOC labels and doc notes from now on.  I no longer monitor Hive email for doc issues.)

> Improve msck repair batching
> ----------------------------
>
>                 Key: HIVE-16143
>                 URL: https://issues.apache.org/jira/browse/HIVE-16143
>             Project: Hive
>          Issue Type: Improvement
>            Reporter: Vihang Karajgaonkar
>            Assignee: Vihang Karajgaonkar
>              Labels: TODOC2.4
>             Fix For: 3.0.0, 2.4.0
>
>         Attachments: HIVE-16143.01.patch, HIVE-16143.02.patch, HIVE-16143.03.patch, HIVE-16143.04.patch, HIVE-16143.05.patch, HIVE-16143.06.patch, HIVE-16143.07.patch, HIVE-16143.08.patch, HIVE-16143.09.patch, HIVE-16143.10-branch-2.patch, HIVE-16143.10-branch-2.patch
>
>
> Currently, the {{msck repair table}} command batches the number of partitions created in the metastore using the config {{HIVE_MSCK_REPAIR_BATCH_SIZE}}. Following snippet shows the batching logic. There can be couple of improvements to this batching logic:
> {noformat} 
> int batch_size = conf.getIntVar(ConfVars.HIVE_MSCK_REPAIR_BATCH_SIZE);
>           if (batch_size > 0 && partsNotInMs.size() > batch_size) {
>             int counter = 0;
>             for (CheckResult.PartitionResult part : partsNotInMs) {
>               counter++;
>               apd.addPartition(Warehouse.makeSpecFromName(part.getPartitionName()), null);
>               repairOutput.add("Repair: Added partition to metastore " + msckDesc.getTableName()
>                   + ':' + part.getPartitionName());
>               if (counter % batch_size == 0 || counter == partsNotInMs.size()) {
>                 db.createPartitions(apd);
>                 apd = new AddPartitionDesc(table.getDbName(), table.getTableName(), false);
>               }
>             }
>           } else {
>             for (CheckResult.PartitionResult part : partsNotInMs) {
>               apd.addPartition(Warehouse.makeSpecFromName(part.getPartitionName()), null);
>               repairOutput.add("Repair: Added partition to metastore " + msckDesc.getTableName()
>                   + ':' + part.getPartitionName());
>             }
>             db.createPartitions(apd);
>           }
>         } catch (Exception e) {
>           LOG.info("Could not bulk-add partitions to metastore; trying one by one", e);
>           repairOutput.clear();
>           msckAddPartitionsOneByOne(db, table, partsNotInMs, repairOutput);
>         }
> {noformat}
> 1. If the batch size is too aggressive the code falls back to adding partitions one by one which is almost always very slow. It is easily possible that users increase the batch size to higher value to make the command run faster but end up with a worse performance because code falls back to adding one by one. Users are then expected to determine the tuned value of batch size which works well for their environment. I think the code could handle this situation better by exponentially decaying the batch size instead of falling back to one by one.
> 2. The other issue with this implementation is if lets say first batch succeeds and the second one fails, the code tries to add all the partitions one by one irrespective of whether some of the were successfully added or not. If we need to fall back to one by one we should atleast remove the ones which we know for sure are already added successfully.



--
This message was sent by Atlassian JIRA
(v6.4.14#64029)