Thomas, i was looking at the H2 sources and i believe that you monitor the
file LOCK with a daemon Thread. My question is: HOW do you create the File
Lock? Using the java native TEMP file creator?
*TEST CASE*:
File lock=new File(DATABASE_NAME+".lock.db");
Class.forName("org.h2.Driver");
Connection conn = DriverManager.
getConnection("jdbc:h2:~/"+DATABASE_NAME, "sa", "");
System.out.println("LOCKED!");
System.out.println("CONN CLOSED? "+conn.isClosed()); // false
conn.close();
System.out.println("CONN CLOSED? "+conn.isClosed()); // TRUE
while(lock.exists()){
System.out.println("WAITING FOR UNLOCK...");
Thread.sleep(1000);
}
System.out.println("UNLOCKED!"); // *NEVER REACHED*!!!
On Saturday, November 2, 2013 3:50:26 PM UTC, Thomas Mueller wrote:
>
> Hi,
>
> H2 doesn't "miss the unlock". I'm sure this is not a problem in the
> database. It is clearly a problem on your side.
>
> Regards,
> Thomas
>
>
> On Sat, Nov 2, 2013 at 4:27 PM, marcolopes <[email protected] <javascript:>
> > wrote:
>
>> Thomas, this only happens if the user misses the "login"...
>>
>> 1) Backup the **closed** database
>> 2) Login is attempted and fails
>> 3) Database is closed (well, i issue the datanucleus PFM.close that shoud
>> close ALL connections / poolmanager)
>> 4) Back to step 1 - and that is where it might be problematic, as i don't
>> really know if the database is closed or H2 just misses the unlock...
>>
>>
>> On Saturday, November 2, 2013 2:54:53 PM UTC, Thomas Mueller wrote:
>>
>>> Hi,
>>>
>>> Copying the database file while the database is open is not a good idea.
>>> It will work in most cases, but not in all cases (for example if the
>>> transaction log is rolled over while the backup is in progress). When it
>>> doesn't work, the database will be corrupt. Don't blame us for that.
>>>
>>> If you want to backup the database while it is open, use the "backup"
>>> SQL statement. Otherwise you need to close the database.
>>>
>>> Regards,
>>> Thomas
>>>
>>>
>>> On Sat, Nov 2, 2013 at 3:51 PM, Noel Grandin <[email protected]> wrote:
>>>
>>>> Then it sounds like the problem is with datanucleus not closing it's
>>>> connection to the db. Perhaps it needs some special call or parameter to
>>>> tell it that?
>>>> Or are you using db_close_delay in your db URL? Which would also cause
>>>> the db to not close when the last connection is closed.
>>>> Or maybe you are using a connection pool which may also need to be shut
>>>> down.
>>>>
>>>>
>>>> On Saturday, 2 November 2013, marcolopes wrote:
>>>>
>>>>> Thomas, i know what's going on...
>>>>>
>>>>> 1) The first backup is made
>>>>> 2) The database is opened (i'm using Datanucleus persistence, so, no
>>>>> control from my code)
>>>>> 3) A database LOCK file is created
>>>>> 4) I close the "Persistence Manager Factory" but the LOCK file is not
>>>>> released... (it is released only when i terminate the java app)
>>>>> 5) Subsequent backups attempts cause org.h2.jdbc.JdbcSQLException:
>>>>> Cannot change the setting "backup" when the database is already open
>>>>> [90133-169]
>>>>>
>>>>> On Saturday, November 2, 2013 9:14:22 AM UTC, Thomas Mueller wrote:
>>>>>>
>>>>>> Hi,
>>>>>>
>>>>>> I don't know what you do exactly, but I can not reproduce it. Could
>>>>>> you provide a simple, reproducible test case? My test case is: I create
>>>>>> a
>>>>>> database "test". After that there is a file called "test.h2.db". Then I
>>>>>> backup this file 4 times, and that works, and no .lock.db files are
>>>>>> created.
>>>>>>
>>>>>> *public* *class* Test {
>>>>>>
>>>>>> *public* *static* *void* main(String... args) *throws* Exception
>>>>>> {
>>>>>>
>>>>>> Backup.execute("~/temp/**backup1**.zip", "~/temp", "test", *
>>>>>> true*);
>>>>>>
>>>>>> Backup.execute("~/temp/**backup2**.zip", "~/temp", "test", *
>>>>>> false*);
>>>>>>
>>>>>> Backup.execute("~/temp/**backup3**.zip", "~/temp", "test", *
>>>>>> true*);
>>>>>>
>>>>>> Backup.execute("~/temp/**backup4**.zip", "~/temp", "test", *
>>>>>> false*);
>>>>>>
>>>>>> }
>>>>>>
>>>>>> }
>>>>>>
>>>>>> I would expect from you a similar test case then the one above.
>>>>>>
>>>>>> Regards,
>>>>>> Thomas
>>>>>>
>>>>>>
>>>>>> On Fri, Nov 1, 2013 at 7:14 PM, marcolopes <[email protected]> wrote:
>>>>>>
>>>>>>> The database is **closed**!
>>>>>>>
>>>>>>> The problem is that, on the first backup execution a LOCK is
>>>>>>> created... and all subsequent backup attempts fail.
>>>>>>>
>>>>>>>
>>>>>>> On Friday, November 1, 2013 5:52:55 PM UTC, Thomas Mueller wrote:
>>>>>>>
>>>>>>>> Hi,
>>>>>>>>
>>>>>>>> What do you try to do? If the database is open, you should probably
>>>>>>>> use the BACKUP SQL statement, not the Backup standalone tool.
>>>>>>>>
>>>>>>>> Regards,
>>>>>>>> Thomas
>>>>>>>>
>>>>>>>>
>>>>>>>>
>>>>>>>> On Fri, Nov 1, 2013 at 6:39 PM, marcolopes <[email protected]>wrote:
>>>>>>>>
>>>>>>>>> I don't really understand the behavior of this parameter on the *
>>>>>>>>> Backup.execute* method.
>>>>>>>>>
>>>>>>>>> I thought it would disable the possible "log info", but,
>>>>>>>>> inspecting the code, it goes beyond that.
>>>>>>>>>
>>>>>>>>> The problem with the current approach is: if quiet=false, there is
>>>>>>>>> an attempt to LOCK the database... and the LOCK file remains until
>>>>>>>>> the JAVA
>>>>>>>>> session is terminated... so, another subsequent attempt to BACKUP a
>>>>>>>>> **yet
>>>>>>>>> closed** but now locked database, fails!
>>>>>>>>>
>>>>>>>>> --
>>>>>>>>> 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.**co**m.
>>>>>>>>> To post to this group, send email to [email protected].
>>>>>>>>>
>>>>>>>>> Visit this group at http://groups.google.com/**group****
>>>>>>>>> /h2-database <http://groups.google.com/group/h2-database>.
>>>>>>>>> For more options, visit https://groups.google.com/**grou****
>>>>>>>>> ps/opt_out <https://groups.google.com/groups/opt_out>.
>>>>>>>>>
>>>>>>>>
>>>>>>>> --
>>>>>>> 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 [email protected].
>>>>>>> Visit this group at
>>>>>>> http://groups.google.com/**group**/h2-database<http://groups.google.com/group/h2-database>
>>>>>>> .
>>>>>>> For more options, visit
>>>>>>> https://groups.google.com/**grou**ps/opt_out<https://groups.google.com/groups/opt_out>
>>>>>>> .
>>>>>>>
>>>>>>
>>>>>> --
>>>>> 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+unsubscribe@**googlegroups.com.
>>>>> To post to this group, send email to [email protected].
>>>>> Visit this group at
>>>>> http://groups.google.com/**group/h2-database<http://groups.google.com/group/h2-database>
>>>>> .
>>>>> For more options, visit
>>>>> https://groups.google.com/**groups/opt_out<https://groups.google.com/groups/opt_out>
>>>>> .
>>>>>
>>>> --
>>>> 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 [email protected].
>>>> Visit this group at
>>>> http://groups.google.com/**group/h2-database<http://groups.google.com/group/h2-database>
>>>> .
>>>> For more options, visit
>>>> https://groups.google.com/**groups/opt_out<https://groups.google.com/groups/opt_out>
>>>> .
>>>>
>>>
>>> --
>> 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 [email protected] <javascript:>.
>> To post to this group, send email to [email protected]<javascript:>
>> .
>> Visit this group at http://groups.google.com/group/h2-database.
>> For more options, visit https://groups.google.com/groups/opt_out.
>>
>
>
--
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 [email protected].
To post to this group, send email to [email protected].
Visit this group at http://groups.google.com/group/h2-database.
For more options, visit https://groups.google.com/groups/opt_out.