You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@shardingsphere.apache.org by GitBox <gi...@apache.org> on 2022/08/26 03:28:45 UTC

[GitHub] [shardingsphere] azexcy opened a new pull request, #20537: Add pipeline TPS rate limiter

azexcy opened a new pull request, #20537:
URL: https://github.com/apache/shardingsphere/pull/20537

   
   Changes proposed in this pull request:
   - Add pipeline TPS rate limiter


-- 
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.

To unsubscribe, e-mail: notifications-unsubscribe@shardingsphere.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [shardingsphere] sandynz merged pull request #20537: Enable pipeline TPS rate limiter

Posted by GitBox <gi...@apache.org>.
sandynz merged PR #20537:
URL: https://github.com/apache/shardingsphere/pull/20537


-- 
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.

To unsubscribe, e-mail: notifications-unsubscribe@shardingsphere.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [shardingsphere] sandynz commented on a diff in pull request #20537: Enable pipeline TPS rate limiter

Posted by GitBox <gi...@apache.org>.
sandynz commented on code in PR #20537:
URL: https://github.com/apache/shardingsphere/pull/20537#discussion_r955645207


##########
shardingsphere-kernel/shardingsphere-data-pipeline/shardingsphere-data-pipeline-core/src/main/java/org/apache/shardingsphere/data/pipeline/core/spi/ratelimit/TPSJobRateLimitAlgorithm.java:
##########
@@ -56,13 +56,8 @@ public String getType() {
     
     @Override
     public void intercept(final JobOperationType type, final Number data) {
-        switch (type) {
-            case INSERT:
-            case DELETE:
-            case UPDATE:
-                break;
-            default:
-                return;
+        if (JobOperationType.SELECT == type) {
+            return;
         }

Review Comment:
   It's better to keep INSERT/DELETE/UPDATE, since JobOperationType might add new type, then it might cause issue



##########
shardingsphere-kernel/shardingsphere-data-pipeline/shardingsphere-data-pipeline-core/src/main/java/org/apache/shardingsphere/data/pipeline/scenario/migration/MigrationJobAPI.java:
##########
@@ -45,9 +46,11 @@ public interface MigrationJobAPI extends PipelineJobAPI, MigrationJobPublicAPI,
      * @param jobConfig job configuration
      * @param jobShardingItem job sharding item
      * @param pipelineProcessConfig pipeline process configuration
+     * @param writeRateLimitAlgorithm write rate limit algorithm
      * @return task configuration
      */
-    TaskConfiguration buildTaskConfiguration(MigrationJobConfiguration jobConfig, int jobShardingItem, PipelineProcessConfiguration pipelineProcessConfig);
+    TaskConfiguration buildTaskConfiguration(MigrationJobConfiguration jobConfig, int jobShardingItem, PipelineProcessConfiguration pipelineProcessConfig,
+                                             JobRateLimitAlgorithm writeRateLimitAlgorithm);

Review Comment:
   Looks it's not necessary to add new parameter `JobRateLimitAlgorithm writeRateLimitAlgorithm` for `buildTaskConfiguration` method, since AbstractPipelineProcessContext's constructor `AbstractPipelineProcessContext(final String jobId, final PipelineProcessConfiguration originalProcessConfig)`, we could just build a PipelineProcessContext instance to get writeRateLimitAlgorithm (need to add get writeRateLimitAlgorithm method in PipelineProcessContext interface).
   



##########
shardingsphere-kernel/shardingsphere-data-pipeline/shardingsphere-data-pipeline-core/src/main/java/org/apache/shardingsphere/data/pipeline/core/importer/DefaultImporter.java:
##########
@@ -144,12 +149,21 @@ private void doFlush(final DataSource dataSource, final List<DataRecord> buffer)
             connection.setAutoCommit(false);
             switch (buffer.get(0).getType()) {
                 case IngestDataChangeType.INSERT:
+                    if (null != rateLimitAlgorithm) {
+                        rateLimitAlgorithm.intercept(JobOperationType.INSERT, buffer.size());
+                    }
                     executeBatchInsert(connection, buffer);
                     break;
                 case IngestDataChangeType.UPDATE:
+                    if (null != rateLimitAlgorithm) {
+                        rateLimitAlgorithm.intercept(JobOperationType.UPDATE, buffer.size());
+                    }
                     executeUpdate(connection, buffer);
                     break;
                 case IngestDataChangeType.DELETE:
+                    if (null != rateLimitAlgorithm) {
+                        rateLimitAlgorithm.intercept(JobOperationType.DELETE, buffer.size());
+                    }

Review Comment:
   It's better to use `1` instread of `buffer.size()`, since INSERT/UPDATE/DELETE is in transaction.



##########
shardingsphere-test/shardingsphere-pipeline-test/src/test/java/org/apache/shardingsphere/data/pipeline/core/util/PipelineContextUtil.java:
##########
@@ -159,8 +159,8 @@ public static MigrationJobItemContext mockMigrationJobItemContext(final Migratio
         PipelineProcessConfiguration processConfig = mockPipelineProcessConfiguration();
         MigrationProcessContext processContext = new MigrationProcessContext(jobConfig.getJobId(), processConfig);
         int jobShardingItem = 0;
-        TaskConfiguration taskConfig = new MigrationJobAPIImpl().buildTaskConfiguration(jobConfig, jobShardingItem, processConfig);
-        return new MigrationJobItemContext(jobConfig, jobShardingItem, null,
+        TaskConfiguration taskConfig = new MigrationJobAPIImpl().buildTaskConfiguration(jobConfig, jobShardingItem, processConfig, processContext.getWriteRateLimitAlgorithm());
+        return new MigrationJobItemContext(jobConfig, jobShardingItem, null, 
                 processContext, taskConfig, new DefaultPipelineDataSourceManager());

Review Comment:
   The last blank character at end of line could be removed. And it's better to merge the last two lines into one line.



-- 
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.

To unsubscribe, e-mail: notifications-unsubscribe@shardingsphere.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [shardingsphere] codecov-commenter commented on pull request #20537: Enable pipeline TPS rate limiter

Posted by GitBox <gi...@apache.org>.
codecov-commenter commented on PR #20537:
URL: https://github.com/apache/shardingsphere/pull/20537#issuecomment-1228034364

   # [Codecov](https://codecov.io/gh/apache/shardingsphere/pull/20537?src=pr&el=h1&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation) Report
   > Merging [#20537](https://codecov.io/gh/apache/shardingsphere/pull/20537?src=pr&el=desc&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation) (72fdc1f) into [master](https://codecov.io/gh/apache/shardingsphere/commit/02d3b0f350f7c2886e2ba4668dedf9e1c749650a?el=desc&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation) (02d3b0f) will **decrease** coverage by `0.02%`.
   > The diff coverage is `8.00%`.
   
   > :exclamation: Current head 72fdc1f differs from pull request most recent head d383ee8. Consider uploading reports for the commit d383ee8 to get more accurate results
   
   ```diff
   @@             Coverage Diff              @@
   ##             master   #20537      +/-   ##
   ============================================
   - Coverage     60.93%   60.90%   -0.03%     
     Complexity     2415     2415              
   ============================================
     Files          3928     3928              
     Lines         54813    54787      -26     
     Branches       9320     9312       -8     
   ============================================
   - Hits          33398    33369      -29     
   - Misses        18573    18580       +7     
   + Partials       2842     2838       -4     
   ```
   
   
   | [Impacted Files](https://codecov.io/gh/apache/shardingsphere/pull/20537?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation) | Coverage Δ | |
   |---|---|---|
   | [...ata/pipeline/api/config/ImporterConfiguration.java](https://codecov.io/gh/apache/shardingsphere/pull/20537/diff?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation#diff-c2hhcmRpbmdzcGhlcmUta2VybmVsL3NoYXJkaW5nc3BoZXJlLWRhdGEtcGlwZWxpbmUvc2hhcmRpbmdzcGhlcmUtZGF0YS1waXBlbGluZS1hcGkvc3JjL21haW4vamF2YS9vcmcvYXBhY2hlL3NoYXJkaW5nc3BoZXJlL2RhdGEvcGlwZWxpbmUvYXBpL2NvbmZpZy9JbXBvcnRlckNvbmZpZ3VyYXRpb24uamF2YQ==) | `0.00% <ø> (ø)` | |
   | [...e/data/pipeline/core/importer/DefaultImporter.java](https://codecov.io/gh/apache/shardingsphere/pull/20537/diff?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation#diff-c2hhcmRpbmdzcGhlcmUta2VybmVsL3NoYXJkaW5nc3BoZXJlLWRhdGEtcGlwZWxpbmUvc2hhcmRpbmdzcGhlcmUtZGF0YS1waXBlbGluZS1jb3JlL3NyYy9tYWluL2phdmEvb3JnL2FwYWNoZS9zaGFyZGluZ3NwaGVyZS9kYXRhL3BpcGVsaW5lL2NvcmUvaW1wb3J0ZXIvRGVmYXVsdEltcG9ydGVyLmphdmE=) | `0.00% <0.00%> (ø)` | |
   | [...e/core/spi/ratelimit/TPSJobRateLimitAlgorithm.java](https://codecov.io/gh/apache/shardingsphere/pull/20537/diff?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation#diff-c2hhcmRpbmdzcGhlcmUta2VybmVsL3NoYXJkaW5nc3BoZXJlLWRhdGEtcGlwZWxpbmUvc2hhcmRpbmdzcGhlcmUtZGF0YS1waXBlbGluZS1jb3JlL3NyYy9tYWluL2phdmEvb3JnL2FwYWNoZS9zaGFyZGluZ3NwaGVyZS9kYXRhL3BpcGVsaW5lL2NvcmUvc3BpL3JhdGVsaW1pdC9UUFNKb2JSYXRlTGltaXRBbGdvcml0aG0uamF2YQ==) | `0.00% <0.00%> (ø)` | |
   | [...data/pipeline/scenario/migration/MigrationJob.java](https://codecov.io/gh/apache/shardingsphere/pull/20537/diff?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation#diff-c2hhcmRpbmdzcGhlcmUta2VybmVsL3NoYXJkaW5nc3BoZXJlLWRhdGEtcGlwZWxpbmUvc2hhcmRpbmdzcGhlcmUtZGF0YS1waXBlbGluZS1jb3JlL3NyYy9tYWluL2phdmEvb3JnL2FwYWNoZS9zaGFyZGluZ3NwaGVyZS9kYXRhL3BpcGVsaW5lL3NjZW5hcmlvL21pZ3JhdGlvbi9NaWdyYXRpb25Kb2IuamF2YQ==) | `0.00% <0.00%> (ø)` | |
   | [...peline/scenario/migration/MigrationJobAPIImpl.java](https://codecov.io/gh/apache/shardingsphere/pull/20537/diff?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation#diff-c2hhcmRpbmdzcGhlcmUta2VybmVsL3NoYXJkaW5nc3BoZXJlLWRhdGEtcGlwZWxpbmUvc2hhcmRpbmdzcGhlcmUtZGF0YS1waXBlbGluZS1jb3JlL3NyYy9tYWluL2phdmEvb3JnL2FwYWNoZS9zaGFyZGluZ3NwaGVyZS9kYXRhL3BpcGVsaW5lL3NjZW5hcmlvL21pZ3JhdGlvbi9NaWdyYXRpb25Kb2JBUElJbXBsLmphdmE=) | `2.72% <0.00%> (ø)` | |
   | [.../cluster/zookeeper/lock/ZookeeperInternalLock.java](https://codecov.io/gh/apache/shardingsphere/pull/20537/diff?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation#diff-c2hhcmRpbmdzcGhlcmUtbW9kZS9zaGFyZGluZ3NwaGVyZS1tb2RlLXR5cGUvc2hhcmRpbmdzcGhlcmUtY2x1c3Rlci1tb2RlL3NoYXJkaW5nc3BoZXJlLWNsdXN0ZXItbW9kZS1yZXBvc2l0b3J5L3NoYXJkaW5nc3BoZXJlLWNsdXN0ZXItbW9kZS1yZXBvc2l0b3J5LXByb3ZpZGVyL3NoYXJkaW5nc3BoZXJlLWNsdXN0ZXItbW9kZS1yZXBvc2l0b3J5LXpvb2tlZXBlci1jdXJhdG9yL3NyYy9tYWluL2phdmEvb3JnL2FwYWNoZS9zaGFyZGluZ3NwaGVyZS9tb2RlL3JlcG9zaXRvcnkvY2x1c3Rlci96b29rZWVwZXIvbG9jay9ab29rZWVwZXJJbnRlcm5hbExvY2suamF2YQ==) | `0.00% <0.00%> (ø)` | |
   | [...er/zookeeper/lock/ZookeeperInternalLockHolder.java](https://codecov.io/gh/apache/shardingsphere/pull/20537/diff?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation#diff-c2hhcmRpbmdzcGhlcmUtbW9kZS9zaGFyZGluZ3NwaGVyZS1tb2RlLXR5cGUvc2hhcmRpbmdzcGhlcmUtY2x1c3Rlci1tb2RlL3NoYXJkaW5nc3BoZXJlLWNsdXN0ZXItbW9kZS1yZXBvc2l0b3J5L3NoYXJkaW5nc3BoZXJlLWNsdXN0ZXItbW9kZS1yZXBvc2l0b3J5LXByb3ZpZGVyL3NoYXJkaW5nc3BoZXJlLWNsdXN0ZXItbW9kZS1yZXBvc2l0b3J5LXpvb2tlZXBlci1jdXJhdG9yL3NyYy9tYWluL2phdmEvb3JnL2FwYWNoZS9zaGFyZGluZ3NwaGVyZS9tb2RlL3JlcG9zaXRvcnkvY2x1c3Rlci96b29rZWVwZXIvbG9jay9ab29rZWVwZXJJbnRlcm5hbExvY2tIb2xkZXIuamF2YQ==) | `0.00% <ø> (ø)` | |
   | [.../standalone/lock/ShardingSphereStandaloneLock.java](https://codecov.io/gh/apache/shardingsphere/pull/20537/diff?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation#diff-c2hhcmRpbmdzcGhlcmUtbW9kZS9zaGFyZGluZ3NwaGVyZS1tb2RlLXR5cGUvc2hhcmRpbmdzcGhlcmUtc3RhbmRhbG9uZS1tb2RlL3NoYXJkaW5nc3BoZXJlLXN0YW5kYWxvbmUtbW9kZS1jb3JlL3NyYy9tYWluL2phdmEvb3JnL2FwYWNoZS9zaGFyZGluZ3NwaGVyZS9tb2RlL21hbmFnZXIvc3RhbmRhbG9uZS9sb2NrL1NoYXJkaW5nU3BoZXJlU3RhbmRhbG9uZUxvY2suamF2YQ==) | `14.28% <0.00%> (ø)` | |
   | [...nager/standalone/lock/StandaloneExclusiveLock.java](https://codecov.io/gh/apache/shardingsphere/pull/20537/diff?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation#diff-c2hhcmRpbmdzcGhlcmUtbW9kZS9zaGFyZGluZ3NwaGVyZS1tb2RlLXR5cGUvc2hhcmRpbmdzcGhlcmUtc3RhbmRhbG9uZS1tb2RlL3NoYXJkaW5nc3BoZXJlLXN0YW5kYWxvbmUtbW9kZS1jb3JlL3NyYy9tYWluL2phdmEvb3JnL2FwYWNoZS9zaGFyZGluZ3NwaGVyZS9tb2RlL21hbmFnZXIvc3RhbmRhbG9uZS9sb2NrL1N0YW5kYWxvbmVFeGNsdXNpdmVMb2NrLmphdmE=) | `0.00% <0.00%> (ø)` | |
   | [...ingsphere/mode/lock/ShardingSphereLockContext.java](https://codecov.io/gh/apache/shardingsphere/pull/20537/diff?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation#diff-c2hhcmRpbmdzcGhlcmUtbW9kZS9zaGFyZGluZ3NwaGVyZS1tb2RlLWNvcmUvc3JjL21haW4vamF2YS9vcmcvYXBhY2hlL3NoYXJkaW5nc3BoZXJlL21vZGUvbG9jay9TaGFyZGluZ1NwaGVyZUxvY2tDb250ZXh0LmphdmE=) | `100.00% <100.00%> (+22.22%)` | :arrow_up: |
   | ... and [1 more](https://codecov.io/gh/apache/shardingsphere/pull/20537/diff?src=pr&el=tree-more&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation) | |
   
   :mega: We’re building smart automated test selection to slash your CI/CD build times. [Learn more](https://about.codecov.io/iterative-testing/?utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation)
   


-- 
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.

To unsubscribe, e-mail: notifications-unsubscribe@shardingsphere.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org