玩!不能正确关闭H2 [英] Play! not shutting down H2 correctly

查看:178
本文介绍了玩!不能正确关闭H2的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我使用Play编写一个部署在Tomcat中的webapp。因为应用程序不会处理非常多的数据,所以我在Hibernate中使用默认的H2数据库。当我想部署应用程序的新版本时,我关闭了tomcat,清除旧的webapp和WAR,添加我的新WAR,并开始备份。



直到几天前,当我添加数据库组件。现在,我经常无法重新部署应用程序。当我删除旧目录时,它会自动重新生成这个结构:

  $ ls -laR myapp / 
myapp /:
total 24
drwxr-xr-x 3 root root 4096 Aug 24 17:20。
drwxr-xr-x 13 root root 4096 Aug 24 17:20 ..
drwxr-xr-x 3 root root 4096 Aug 24 17:20 WEB-INF

myapp / WEB-INF:
总计24
drwxr-xr-x 3根root 4096 Aug 24 17:20。
drwxr-xr-x 3 root root 4096 Aug 24 17:20 ..
drwxr-xr-x 3 root root 4096 Aug 24 17:20 application

myapp / WEB -INF / application:
total 24
drwxr-xr-x 3 root root 4096 Aug 24 17:20。
drwxr-xr-x 3 root root 4096 Aug 24 17:20 ..
drwxr-xr-x 3 root root 4096 Aug 24 17:20 db

myapp / WEB -INF / application / db:
total 24
drwxr-xr-x 3 root root 4096 Aug 24 17:20。
drwxr-xr-x 3 root root 4096 Aug 24 17:20 ..
drwxr-xr-x 2 root root 4096 Aug 24 17:20 h2

myapp / WEB -INF / application / db / h2:
total 24
drwxr-xr-x 2 root root 4096 Aug 24 17:20。
drwxr-xr-x 3 root root 4096 Aug 24 17:20 ..
-rw -r - r-- 1 root root 100 Aug 24 17:20 play.lock.db

WAR解压缩时也会出现这种情况。



I最近在catalina.out日志中发现了一条消息,他抱怨我的应用程序没有关闭名为H2 File Lock Watchdog的进程。基于对H2文档的简短搜索,我认为这个过程是干扰我的应用的。



编辑



以下是日志文件中的抱怨行:



SEVERE:Web应用程序[/ myapp]似乎启动了一个名为[H2 File Lock Watchdog /var/lib/apache-tomcat-6.0的线程。 32 / webapps / myapp / WEB-INF / application / db / h2 / play.lock.db]但无法停止它。这很可能导致内存泄漏。



那么,我该如何杀死这个进程呢?我无法重新启动机器,因为它不是我的,我无法找到 top ps 。我更喜欢Play的方式来自动关闭它,但我并没有将它构建到我的部署脚本中。



非常感谢,如果您已阅读至此!!

解决方案


我关闭了tomcat




你确定你完全关闭了tomcat吗?因为H2数据库正在运行。如果关闭tomcat进程,数据库也会停止(因为H2在tomcat进程中运行)。除非在不同的进程中运行数据库。



或者您是否关闭了 tomcat中的web应用程序?如果是这样,那么至少有一个数据库连接没有关闭,这样数据库就会继续运行(并创建这个.lock.db文件)。



现在,我不知道播放框架,也不能说如何确保所有数据库连接都关闭。

强制数据库关闭的一种方法是运行SQL语句 SHUTDOWN


我无法用top或ps找到看门狗

top ps 仅显示过程。 H2看门狗是一个java进程中的线程。要查看该线程,请使用:

$ $ p $ jps -l(获取Java进程列表)
jstack -l < PID> (以获得完整的线程转储)


I'm using Play to write a webapp which is deployed in Tomcat. Because the app won't be processing very much data I'm using the default H2 database with Hibernate. When I want to deploy a new version of the app, I shut down tomcat, wipe the old webapp and WAR, add my new WAR, and start back up.

This worked until a few days ago, when I added the database component. Now, I am often unable to redeploy the app. When I delete the old directory, it is automatically regenerated with this structure:

$ ls -laR myapp/
myapp/:
total 24
drwxr-xr-x  3 root root 4096 Aug 24 17:20 .
drwxr-xr-x 13 root root 4096 Aug 24 17:20 ..
drwxr-xr-x  3 root root 4096 Aug 24 17:20 WEB-INF

myapp/WEB-INF:
total 24
drwxr-xr-x 3 root root 4096 Aug 24 17:20 .
drwxr-xr-x 3 root root 4096 Aug 24 17:20 ..
drwxr-xr-x 3 root root 4096 Aug 24 17:20 application

myapp/WEB-INF/application:
total 24
drwxr-xr-x 3 root root 4096 Aug 24 17:20 .
drwxr-xr-x 3 root root 4096 Aug 24 17:20 ..
drwxr-xr-x 3 root root 4096 Aug 24 17:20 db

myapp/WEB-INF/application/db:
total 24
drwxr-xr-x 3 root root 4096 Aug 24 17:20 .
drwxr-xr-x 3 root root 4096 Aug 24 17:20 ..
drwxr-xr-x 2 root root 4096 Aug 24 17:20 h2

myapp/WEB-INF/application/db/h2:
total 24
drwxr-xr-x 2 root root 4096 Aug 24 17:20 .
drwxr-xr-x 3 root root 4096 Aug 24 17:20 ..
-rw-r--r-- 1 root root  100 Aug 24 17:20 play.lock.db

The same happens when the WAR unzips.

I recently noticed a message whiz by in the catalina.out log complaining about my app not shutting down a process called something like "H2 File Lock Watchdog". Based on a brief search of the H2 docs, I think that process is what's interfering with my app.

EDIT

Here's the complaining line in the log file:

SEVERE: The web application [/myapp] appears to have started a thread named [H2 File Lock Watchdog /var/lib/apache-tomcat-6.0.32/webapps/myapp/WEB-INF/application/db/h2/play.lock.db] but has failed to stop it. This is very likely to create a memory leak.

So, how do I kill this process? I can't restart the machine because it's not mine, and I can't find the watchdog with top or ps. I'd prefer a way for Play to shut it down automagically, but I'm not above building it into my deployment script.

Thanks a million if you've read this far!

解决方案

I shut down tomcat

Are you sure you have shut down tomcat completely? Because the H2 database is sill running. If you shut down the tomcat process, the database is also stopped (because H2 is running within the tomcat process). Except if you run the database in a different process.

Or did you just shut down the web application within tomcat? If that is the case, then at least one database connection was not closed, so that the database keeps running (and creates this .lock.db file).

Now, I don't know the play framework, and can't say how to ensure all database connections are closed.

One way to force the database to close is to run the SQL statement SHUTDOWN.

I can't find the watchdog with top or ps

top and ps only display processes. The H2 watchdog is a thread within a java process. To see the thread, use:

jps -l (to get the list of Java processes)
jstack -l <pid> (to get a full thread dump)

这篇关于玩!不能正确关闭H2的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆