Version 1.4.181 has changed the temp file location?

105 views
Skip to first unread message

Harshad RJ

unread,
Aug 25, 2014, 7:40:53 AM8/25/14
to h2-da...@googlegroups.com
After updating to version 1.4.181 I see this exception:

Caused by: java.security.AccessControlException: access denied ("java.io.FilePermission" "/path_to_db/dbname.h2.mv.db.tempFile" "read")
    at java.security.AccessControlContext.checkPermission(AccessControlContext.java:457)
    at java.security.AccessController.checkPermission(AccessController.java:884)
    at java.lang.SecurityManager.checkPermission(SecurityManager.java:549)
    at java.lang.SecurityManager.checkRead(SecurityManager.java:888)
    at java.io.File.exists(File.java:814)
    at org.h2.store.fs.FilePathDisk.exists(FilePathDisk.java:149)
    at org.h2.store.fs.FileUtils.exists(FileUtils.java:31)
    at org.h2.mvstore.MVStoreTool.compactCleanUp(MVStoreTool.java:348)
    at org.h2.mvstore.db.MVTableEngine.init(MVTableEngine.java:61)
    at org.h2.engine.Database.getPageStore(Database.java:2372)
    at org.h2.engine.Database.open(Database.java:666)
    at org.h2.engine.Database.openDatabase(Database.java:266)



This was not happening in version 1.4.180.

My code runs under a security manager, and I have already added the required file permissions for Constants.SUFFIX_TEMP_FILE

The Suffix for temp file is defined as ".temp.db" in Constants.java.

It looks like MVStoreTool is suddenly using different file names now.

Can you please tell me if this is a regression or the paths are changed now?

thanks,
Harshad

Thomas Mueller

unread,
Aug 25, 2014, 2:52:41 PM8/25/14
to H2 Google Group
Hi,

The newest version of H2 has a new mechanism to compact files (when using "shutdown defrag"), which is creating this type of temp file ("*.db.tempFile"). 

There is currently no documentation on the files that H2 creates. I guess you need that, right?

Regards,
Thomas



--
You received this message because you are subscribed to the Google Groups "H2 Database" group.
To unsubscribe from this group and stop receiving emails from it, send an email to h2-database...@googlegroups.com.
To post to this group, send email to h2-da...@googlegroups.com.
Visit this group at http://groups.google.com/group/h2-database.
For more options, visit https://groups.google.com/d/optout.

Harshad RJ

unread,
Aug 26, 2014, 3:44:21 AM8/26/14
to h2-da...@googlegroups.com
Indeed would be great if there is documentation on that.

Would be even more awesome if Constants.java added a constant for that suffix string.

thanks,
Harshad

Harshad RJ

unread,
Dec 31, 2014, 7:13:53 AM12/31/14
to h2-da...@googlegroups.com
Hi,

Is there any update to this thread?

For context:
We are using h2 in our application (gngr, a browser implemented in pure Java). The application uses Java's sand-boxing mechanism to restrict the access to file-system. The relevant code looks like this:

  final String[] h2Suffixes = new String[] {
    org
.h2.engine.Constants.SUFFIX_LOCK_FILE,
    org
.h2.engine.Constants.SUFFIX_PAGE_FILE,
    org
.h2.engine.Constants.SUFFIX_MV_FILE,
    org
.h2.engine.Constants.SUFFIX_TEMP_FILE,
    org
.h2.engine.Constants.SUFFIX_TRACE_FILE,
   
".data.db",
 
};
 
for (final String suffix : h2Suffixes) {
    permissions
.add(new FilePermission(userDBPath + suffix, "read, write, delete"));
 
}


In pseudo-code,
  • gather the list of suffixes used by h2 for the db file
  • grant read,write and delete permissions for all the possible file names used by h2

In this context, it would be great if h2 provided a list of suffixes in Constants.java. Upgrading to a newer version would then be easier and more reliable.

thanks!

Thomas Mueller

unread,
Jan 14, 2015, 1:47:59 AM1/14/15
to h2-da...@googlegroups.com
Hi,

The file name suffixes are now all in the Constants class (for example SUFFIX_MV_STORE_NEW_FILE = ".newFile").

Regards,
Thomas

--

Harshad RJ

unread,
Jan 14, 2015, 8:25:06 AM1/14/15
to h2-da...@googlegroups.com
Hi Thomas,

Thanks for your response. After some analysis, I realized that we have to do this:

Constants.SUFFIX_MV_FILE + Constants.SUFFIX_MV_STORE_NEW_FILE,
Constants.SUFFIX_MV_FILE + Constants.SUFFIX_MV_STORE_TEMP_FILE,

to get the final suffix. It now works fine.

It would be great if Constants.java provided an array of all final suffixes. Also, ".data.db" is not there in Constants.java.

Is this suffix being used by mistake? If I don't give that permission, I get an exception:

java.security.AccessControlException: access denied ("java.io.FilePermission" "/home/default/user.h2.data.db" "read")

    at java.security.AccessControlContext.checkPermission(AccessControlContext.java:457)
    at java.security.AccessController.checkPermission(AccessController.java:884)
    at java.lang.SecurityManager.checkPermission(SecurityManager.java:549)
    at java.lang.SecurityManager.checkRead(SecurityManager.java:888)
    at java.io.File.exists(File.java:814)
    at org.h2.store.fs.FilePathDisk.exists(FilePathDisk.java:149)
    at org.h2.store.fs.FileUtils.exists(FileUtils.java:31)
    at org.h2.engine.Database.open(Database.java:572)
    at org.h2.engine.Database.openDatabase(Database.java:266)


​best,​
--

Thomas Mueller

unread,
Jan 15, 2015, 1:46:10 AM1/15/15
to h2-da...@googlegroups.com
Hi,

There is a feature request to drop the file name suffix at all. That means, for the database URL "jdbc:h2:./data", the database file would then be called just "data".

I think it's better to give access rights based on path than access rights based on file name suffixes. That is, allow to read from a certain directory.

Regards,
Thomas

--

Harshad RJ

unread,
Jan 15, 2015, 2:40:21 AM1/15/15
to h2-database

On Thu, Jan 15, 2015 at 12:16 PM, Thomas Mueller <thomas.to...@gmail.com> wrote:

I think it's better to give access rights based on path than access rights based on file name suffixes. That is, allow to read from a certain directory.

​That makes sense, thanks for the suggestion. When I first coded the permissions, I didn't realize there would be so many files used by h2.​


--
Reply all
Reply to author
Forward
0 new messages