-
Notifications
You must be signed in to change notification settings - Fork 19
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Spark applications using the Loki appender hang at shutdown #99
Comments
Hi, sorry for late reply. This should not happen. Can you do thread dump (jstack) of the app so we could see which threads are keeping it from closing? |
Hello, I think the same issue is happening on Spring Boot as well. It seems that thread hangs at |
Sorry for my very, very, very late reply. I did not follow this issue since it seems that this is an issue specific to |
Hi, yes please. If you can provide any more data I would greatly appreciate that. I was recently looking into this. @theaob mentioned |
I think i meet the same problem, it hang my spring boot application at shutdown. The test project has only 3 files.
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<parent>
<groupId>com.lanyuanxiaoyao.micro.service</groupId>
<artifactId>center</artifactId>
<version>1.0.0</version>
</parent>
<artifactId>test</artifactId>
<dependencies>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter</artifactId>
<version>2.6.13</version>
</dependency>
<dependency>
<groupId>pl.tkowalcz.tjahzi</groupId>
<artifactId>logback-appender</artifactId>
<version>0.9.26</version>
</dependency>
</dependencies>
<build>
<plugins>
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
<version>2.6.13</version>
</plugin>
</plugins>
</build>
</project>
package com.lanyuanxiaoyao.micro.service.test;
import org.springframework.boot.ApplicationArguments;
import org.springframework.boot.ApplicationRunner;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
/**
* @author lanyuanxiaoyao
* @date 2023-02-02
*/
@SpringBootApplication
public class TestApplication implements ApplicationRunner {
public static void main(String[] args) {
SpringApplication.run(TestApplication.class, args);
}
@Override
public void run(ApplicationArguments args) {
System.out.println("hello world");
}
}
<configuration>
<conversionRule conversionWord="clr" converterClass="org.springframework.boot.logging.logback.ColorConverter" />
<conversionRule conversionWord="wex" converterClass="org.springframework.boot.logging.logback.WhitespaceThrowableProxyConverter" />
<conversionRule conversionWord="wEx" converterClass="org.springframework.boot.logging.logback.ExtendedWhitespaceThrowableProxyConverter" />
<appender name="Loki" class="pl.tkowalcz.tjahzi.logback.LokiAppender">
<filter class="ch.qos.logback.classic.filter.ThresholdFilter">
<level>WARN</level>
</filter>
<url>http://localhost/loki/api/v1/push</url>
<encoder>
<pattern>${FILE_LOG_PATTERN:-%d{${LOG_DATEFORMAT_PATTERN:-yyyy-MM-dd HH:mm:ss.SSS}} [${HOSTNAME}] ${LOG_LEVEL_PATTERN:-%5p} ${PID:- } --- [%t] %-40.40logger{39} : %m%n${LOG_EXCEPTION_CONVERSION_WORD:-%wEx}}</pattern>
</encoder>
<label>
<name>app</name>
<value>test</value>
</label>
<label>
<name>host</name>
<value>${HOSTNAME}</value>
</label>
<logLevelLabel>level</logLevelLabel>
</appender>
<appender name="Console" class="ch.qos.logback.core.ConsoleAppender">
<encoder>
<pattern>${CONSOLE_LOG_PATTERN:-%clr(%d{${LOG_DATEFORMAT_PATTERN:-yyyy-MM-dd HH:mm:ss.SSS}}){faint} %clr(${LOG_LEVEL_PATTERN:-%5p}) %clr(${PID:- }){magenta} %clr(---){faint} %clr([%15.15t]){faint} %clr(%-40.40logger{39}){cyan} %clr(:){faint} %m%n${LOG_EXCEPTION_CONVERSION_WORD:-%wEx}}</pattern>
</encoder>
</appender>
<root level="INFO">
<appender-ref ref="Console"/>
</root>
</configuration> If i remove the LokiAppender from |
Thank you for providing reproducer. |
I have reproduced this issue. I am not very familiar with Spring app lifecycle but looks like logging system ( I have intentionally used non-daemon threads so that exiting application must stop the logging system so all buffers are flushed and all messages sent. Should I provide a configuration option to use no daemon threads? I don't see any other option currently and are open for ideas. |
Hi @lanyuanxiaoyao, @eugenwintersberger, @theaob! I have released a new version of Tjahzi for Logback and Log4j2 that has option to use daemon threads. This should fix your problem but may cause messages to be lost during shutdown. Alternatively you can manyally shutdown the Spring logging system. |
I am using the Loki log appender in an Apache Spark application deployed with spark-submit. The Spark application hangs indefinitely at shutdown. When running the application from the command line I have to explicitly kill the task using CTRL-C in order to terminate the program.
This is the Scala code of my application:
And here are the last lines of the command line output:
As you can see, the program stops after the last line in the Scala code and waits there indefinitely until I press CTRL-C.
Is this a known problem?
The text was updated successfully, but these errors were encountered: