You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@skywalking.apache.org by wu...@apache.org on 2022/10/10 03:35:12 UTC

[skywalking] branch master updated: optimize the creation conditions of profiling task (#9744)

This is an automated email from the ASF dual-hosted git repository.

wusheng pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/skywalking.git


The following commit(s) were added to refs/heads/master by this push:
     new 4752d7b74e optimize the creation conditions of profiling task (#9744)
4752d7b74e is described below

commit 4752d7b74e1bcca4b6be2d9507ea61abbfb320ce
Author: xzyJavaX <49...@users.noreply.github.com>
AuthorDate: Mon Oct 10 11:35:03 2022 +0800

    optimize the creation conditions of profiling task (#9744)
---
 docs/en/changes/changes.md                                   |  1 +
 .../core/profiling/trace/ProfileTaskMutationService.java     | 12 +++++++-----
 2 files changed, 8 insertions(+), 5 deletions(-)

diff --git a/docs/en/changes/changes.md b/docs/en/changes/changes.md
index 181c3d7f83..394fa0e287 100644
--- a/docs/en/changes/changes.md
+++ b/docs/en/changes/changes.md
@@ -50,6 +50,7 @@
 * [**Breaking Change**] Limit the max length of trace/log/alarm tag's `key=value`, set the max length of column `tags`
   in tables`log_tag/segment_tag/alarm_record_tag` and column `query` in `zipkin_query` and column `tag_value` in `tag_autocomplete` to 256.
   SQL-Database requires altering these columns' length or removing these tables before OAP starts, if bump up from previous releases.
+* Optimize the creation conditions of profiling task
 
 #### UI
 
diff --git a/oap-server/server-core/src/main/java/org/apache/skywalking/oap/server/core/profiling/trace/ProfileTaskMutationService.java b/oap-server/server-core/src/main/java/org/apache/skywalking/oap/server/core/profiling/trace/ProfileTaskMutationService.java
index f2be4d19e7..535a7d757f 100644
--- a/oap-server/server-core/src/main/java/org/apache/skywalking/oap/server/core/profiling/trace/ProfileTaskMutationService.java
+++ b/oap-server/server-core/src/main/java/org/apache/skywalking/oap/server/core/profiling/trace/ProfileTaskMutationService.java
@@ -139,15 +139,17 @@ public class ProfileTaskMutationService implements Service {
         }
 
         // Each service can monitor up to 1 endpoints during the execution of tasks
-        long startTimeBucket = TimeBucket.getMinuteTimeBucket(monitorStartTime);
         long endTimeBucket = TimeBucket.getMinuteTimeBucket(monitorEndTime);
         final List<ProfileTask> alreadyHaveTaskList = getProfileTaskDAO().getTaskList(
-            serviceId, null, startTimeBucket, endTimeBucket, 1);
+            serviceId, null, null, endTimeBucket, 1);
         if (CollectionUtils.isNotEmpty(alreadyHaveTaskList)) {
-            // if any task time bucket in this range, means already have task, because time bucket is base on task end time
-            return "current service already has monitor task execute at this time";
+            for (ProfileTask profileTask : alreadyHaveTaskList) {
+                if (profileTask.getStartTime() + TimeUnit.MINUTES.toMillis(profileTask.getDuration()) >= monitorStartTime) {
+                    // if the endTime is greater or equal than the startTime of the newly created task, i.e. there is overlap between two tasks, it is an invalid case
+                    return "current service already has monitor task execute at this time";
+                }
+            }
         }
-
         return null;
     }