Watchdog thread race condition

65 views
Skip to first unread message

Patrik Dufresne

unread,
Feb 28, 2016, 2:28:05 PM2/28/16
to H2 Database
Hello

In a Windows VM, I'm experience a race condition in FileLock.run() using version 1.3.174. Basically, when I open a database with the windows computer, the database get properly open, but looking at the threads, I don't see a "H2 File Lock Watchdog" thread.

The problem is always reproducible. In debug mode, I see the thread being called, but it goes straight to "watchdog end". Most likely, called to "locked = true;" was run after the call to "while (locked && filename!=null)".

I don't see how I can fix it from application level. Help please

Patrik Dufresne

unread,
Feb 28, 2016, 3:58:23 PM2/28/16
to H2 Database
Looking t the code, this problem probably affect current version too.


I recommend to fix this issue by replacing this line:
while (locked && fileName != null) {

by:
while (fileName != null) {

When unlocking, the variable "fileName" get set to null in all cases.

Noel Grandin

unread,
Feb 29, 2016, 1:29:39 AM2/29/16
to h2-da...@googlegroups.com
Thanks for the analysis.

Are you perhaps using the FILE_LOCK=SOCKET option?

Because that is the only way I can see what you describe happening.
In the FILE_LOCK=FILE case, we set "locked = true" just before we start the watchdog, so I can't see what you describe
happening.

Patrik Dufresne

unread,
Feb 29, 2016, 7:30:40 AM2/29/16
to h2-da...@googlegroups.com
I'm using FILE_LOCK=FILE.

You are right. In Trunk, locked = true is set before creating the thread. But in version 1.3.174 it's not. Also the changed seams very recent (Oct 2015)

So unless I'm using a beta version 1.4.191, I cannot get this fixed. Any plan to backport this fix to 1.3 branch ?

--
Patrik Dufresne




--
You received this message because you are subscribed to a topic in the Google Groups "H2 Database" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/h2-database/HE_xk8mJnUc/unsubscribe.
To unsubscribe from this group and all its topics, send an email to h2-database...@googlegroups.com.
To post to this group, send email to h2-da...@googlegroups.com.
Visit this group at https://groups.google.com/group/h2-database.
For more options, visit https://groups.google.com/d/optout.

Noel Grandin

unread,
Feb 29, 2016, 7:32:37 AM2/29/16
to h2-da...@googlegroups.com


On 2016/02/29 2:30 PM, Patrik Dufresne wrote:
>
> So unless I'm using a beta version 1.4.191, I cannot get this fixed. Any plan to backport this fix to 1.3 branch ?
>

Unlikely. But you can run the 1.4 series with the old engine easily enough, just append MV_STORE=false to your URL.

Patrik Dufresne

unread,
Mar 2, 2016, 7:55:44 AM3/2/16
to h2-da...@googlegroups.com
I've upgrade to 1.4 series. My unit test doesn't show any regression. I've set MV_STORE=FALSE to use the old store.

Thanks for your help.

--
Patrik Dufresne


Reply all
Reply to author
Forward
0 new messages