You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@inlong.apache.org by "justinwwhuang (via GitHub)" <gi...@apache.org> on 2024/04/28 07:13:17 UTC

[PR] [INLONG-10094][agent] Fix the bug: the task record for data supplementation has not expired [inlong]

justinwwhuang opened a new pull request, #10095:
URL: https://github.com/apache/inlong/pull/10095

   Fixes #10094
   
   ### Motivation
   
   Fix the bug: the task record for data supplementation has not expired
   ### Modifications
   
   Put the logic of deleting expired records into OffsetManager for unified management
   
   ### Verifying this change
   
   *(Please pick either of the following options)*
   
   - [ ] This change is a trivial rework/code cleanup without any test coverage.
   
   - [ ] This change is already covered by existing tests, such as:
     *(please describe tests)*
   
   - [ ] This change added tests and can be verified as follows:
   
     *(example:)*
     - *Added integration tests for end-to-end deployment with large payloads (10MB)*
     - *Extended integration test for recovery after broker failure*
   
   ### Documentation
   
   No doc needed
   


-- 
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: commits-unsubscribe@inlong.apache.org

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


Re: [PR] [INLONG-10094][agent] Fix the bug: the task record for data supplementation has not expired [inlong]

Posted by "justinwwhuang (via GitHub)" <gi...@apache.org>.
justinwwhuang commented on code in PR #10095:
URL: https://github.com/apache/inlong/pull/10095#discussion_r1582063251


##########
inlong-agent/agent-core/src/main/java/org/apache/inlong/agent/core/task/OffsetManager.java:
##########
@@ -115,6 +117,63 @@ public OffsetProfile getOffset(String taskId, String instanceId) {
         return offsetDb.getOffset(taskId, instanceId);
     }
 
+    private void cleanDbOffset() {
+        List<OffsetProfile> offsets = offsetDb.listAllOffsets();
+        offsets.forEach(offset -> {
+            String taskId = offset.getTaskId();
+            String instanceId = offset.getInstanceId();
+            InstanceProfile instanceProfile = instanceDb.getInstance(taskId, instanceId);
+            if (instanceProfile == null) {
+                deleteOffset(taskId, instanceId);
+                LOGGER.info("instance not found, delete offset taskId {} instanceId {}", taskId,
+                        instanceId);
+            }
+        });
+        LOGGER.info("offsetManager running! offsets count {}", offsets.size());
+    }
+
+    private void cleanDbInstance() {
+        AtomicInteger cleanCount = new AtomicInteger();
+        Iterator<InstanceProfile> iterator = instanceDb.listAllInstances().listIterator();
+        while (iterator.hasNext()) {
+            if (cleanCount.get() > CLEAN_INSTANCE_ONCE_LIMIT) {
+                return;
+            }
+            InstanceProfile instanceFromDb = iterator.next();
+            String taskId = instanceFromDb.getTaskId();
+            String instanceId = instanceFromDb.getInstanceId();
+            if (instanceFromDb.getState() != InstanceStateEnum.FINISHED) {
+                return;

Review Comment:
   yes



-- 
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: commits-unsubscribe@inlong.apache.org

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


Re: [PR] [INLONG-10094][agent] Fix the bug: the task record for data supplementation has not expired [inlong]

Posted by "justinwwhuang (via GitHub)" <gi...@apache.org>.
justinwwhuang merged PR #10095:
URL: https://github.com/apache/inlong/pull/10095


-- 
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: commits-unsubscribe@inlong.apache.org

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


Re: [PR] [INLONG-10094][agent] Fix the bug: the task record for data supplementation has not expired [inlong]

Posted by "aloyszhang (via GitHub)" <gi...@apache.org>.
aloyszhang commented on code in PR #10095:
URL: https://github.com/apache/inlong/pull/10095#discussion_r1582061654


##########
inlong-agent/agent-core/src/main/java/org/apache/inlong/agent/core/task/OffsetManager.java:
##########
@@ -115,6 +117,63 @@ public OffsetProfile getOffset(String taskId, String instanceId) {
         return offsetDb.getOffset(taskId, instanceId);
     }
 
+    private void cleanDbOffset() {
+        List<OffsetProfile> offsets = offsetDb.listAllOffsets();
+        offsets.forEach(offset -> {
+            String taskId = offset.getTaskId();
+            String instanceId = offset.getInstanceId();
+            InstanceProfile instanceProfile = instanceDb.getInstance(taskId, instanceId);
+            if (instanceProfile == null) {
+                deleteOffset(taskId, instanceId);
+                LOGGER.info("instance not found, delete offset taskId {} instanceId {}", taskId,
+                        instanceId);
+            }
+        });
+        LOGGER.info("offsetManager running! offsets count {}", offsets.size());
+    }
+
+    private void cleanDbInstance() {
+        AtomicInteger cleanCount = new AtomicInteger();
+        Iterator<InstanceProfile> iterator = instanceDb.listAllInstances().listIterator();
+        while (iterator.hasNext()) {
+            if (cleanCount.get() > CLEAN_INSTANCE_ONCE_LIMIT) {
+                return;
+            }
+            InstanceProfile instanceFromDb = iterator.next();
+            String taskId = instanceFromDb.getTaskId();
+            String instanceId = instanceFromDb.getInstanceId();
+            if (instanceFromDb.getState() != InstanceStateEnum.FINISHED) {
+                return;

Review Comment:
    Should we also check the state of following instances?



-- 
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: commits-unsubscribe@inlong.apache.org

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