You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@dolphinscheduler.apache.org by GitBox <gi...@apache.org> on 2022/06/25 09:48:22 UTC

[GitHub] [dolphinscheduler] ruanwenjun commented on a diff in pull request #10612: [Bug] [Worker] If the log file is large but has small number of rows, it will causes the View Log page to hang

ruanwenjun commented on code in PR #10612:
URL: https://github.com/apache/dolphinscheduler/pull/10612#discussion_r906662332


##########
dolphinscheduler-log-server/src/main/java/org/apache/dolphinscheduler/server/log/LoggerRequestProcessor.java:
##########
@@ -113,8 +114,22 @@ public void process(Channel channel, Command command) {
                 List<String> lines = readPartFileContent(rollViewLogPath,
                         rollViewLogRequest.getSkipLineNum(), rollViewLogRequest.getLimit());
                 StringBuilder builder = new StringBuilder();
+                final int MaxResponseLogSize = 65535;
                 for (String line : lines) {
-                    builder.append(line).append("\r\n");
+                    //If a single line of log is exceed max response size, cut off the line
+                    if (line.getBytes(StandardCharsets.UTF_8).length >= MaxResponseLogSize) {
+                        builder.append(line, 0, MaxResponseLogSize)
+                                .append(" [this line' size is exceed ")
+                                .append(MaxResponseLogSize).append(" bytes, so only ")
+                                .append(MaxResponseLogSize).append(" characters are reserved for performance reasons.]")
+                                .append("\r\n");
+                    }else {
+                        builder.append(line).append("\r\n");
+                    }
+
+                    if (builder.toString().getBytes(StandardCharsets.UTF_8).length >= MaxResponseLogSize) {
+                        break;

Review Comment:
   I worry this method will be very slow, you already calculate the size of each line, you don't need to calculate the size again.



-- 
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@dolphinscheduler.apache.org

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