limowang commented on code in PR #2191:
URL: 
https://github.com/apache/incubator-pegasus/pull/2191#discussion_r1952200057


##########
admin_tools/pegasus_manual_compact.sh:
##########
@@ -119,10 +119,10 @@ function wait_manual_compact()
         query_log_file="/tmp/$UID.$PID.pegasus.query_compact.${app_id}"
         echo "${query_cmd}" | ./run.sh shell --cluster ${cluster} 
&>${query_log_file}
 
-        queue_count=`grep 'recent enqueue at' ${query_log_file} | grep -v 
'recent start at' | wc -l`
-        running_count=`grep 'recent start at' ${query_log_file} | wc -l`
+        queue_count=$(awk 'BEGIN {count=0} {match($0, 
/"recent_enqueue_at":"([^"]+)"/, enqueue); match($0, 
/"recent_start_at":"([^"]+)"/, start); if (enqueue[1] != "-" && start[1] == 
"-") {count++}} END {print count}' "$query_log_file")
+        running_count=$(awk 'BEGIN {count=0} {match($0, 
/"recent_start_at":"([^"]+)"/, start); if (start[1] != "-" && length(start[1]) 
> 0) {count++}} END {print count}' "$query_log_file")
         processing_count=$((queue_count+running_count))
-        finish_count=`grep "last finish at" ${query_log_file} | grep -v 
"recent enqueue at" | grep -v "recent start at" | grep -o 'last finish at 
[^,]*' | sed 's/\[/,/;s/\]//' | awk -F"," -v date="$earliest_finish_time_ms" 
'BEGIN{count=0}{if(length($2)==23 && $2>=date){count++;}}END{print count}'`
+        finish_count=$(awk 'BEGIN {count=0} {match($0, 
/"last_finish":"([^"]+)"/, finish); if (finish[1] != "-" && length(finish[1]) > 
0) {count++}} END {print count}' "$query_log_file")

Review Comment:
   The `$earliest_finish_time_ms` parameter represents the trigger time 
(`trigger_time`) for the `manual_compact` task. The progress of regular 
background compaction tasks will not be output in the `remote_command -t 
replica-server replica.query-compact ${app_id}` shell command, so the 
`manual_compact` task and regular background compaction tasks do not conflict, 
preventing output errors. Therefore, when parsing the results, 
`$earliest_finish_time_ms` can be ignored.



-- 
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: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to