Re: [h2] MVStore -- can I ignore it?

2016-12-20 Thread Noel Grandin
MV_STORE is a completely separate storage engine from the old PageStore.

The old PageStore engine generates files with a .h2.db extension, the new
MV_STORE engine generates files with a .mv.db extension.

So it's not possible to mix and match opening the same files with the
different engines.

I and some other people currently use MV_STORE in production, but there may
still be some issues. If you have .h2.db database files from the 1.3 series
that you want to carry on using, then you will need to use the old
PageStore engine.
​

-- 
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+unsubscr...@googlegroups.com.
To post to this group, send email to h2-database@googlegroups.com.
Visit this group at https://groups.google.com/group/h2-database.
For more options, visit https://groups.google.com/d/optout.


Re: [h2] Re: The last stable release Version 1.3.176 was published at 2014-04-05, when will 1.4.x stable version release?

2016-12-20 Thread Noel Grandin
We already require java7 for current 1.4​

-- 
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+unsubscr...@googlegroups.com.
To post to this group, send email to h2-database@googlegroups.com.
Visit this group at https://groups.google.com/group/h2-database.
For more options, visit https://groups.google.com/d/optout.


[h2] MVStore -- can I ignore it?

2016-12-20 Thread SkiAddict
So after managing to resolve my slow console launch problem 
, I'm back 
to actually working with h2.  First question: what version to use?  I was 
on 1.3.167 but would like to use something more up to date.  1.3.176 still 
gives me an error on opening the database (something about not being able 
to find the class -- in my Java frontend application -- which implements a 
database function) but 1.4.193 doesn't.  However, 1.4.193 has this MVStore 
thingie, which I'm not too sure about.

I've had a quick read of this , 
but it seems to be written for an audience who will use the MVStore 
features in their code directly.  I simply use h2 as a standard SQL 
database, from my Java frontend.

So: are there reasons I should avoid 1.4.193?  Is there anything special I 
need to do to use it? (e.g. file conversion, like we had to do when 
upgrading from 1.1)  Can I ignore MVStore altogether?  I see that I can now 
get the h2 console to open a database which is already opened by my Java 
frontend -- but only if I don't add MV_STORE=FALSE to my console's URL.  
What are the tradeoffs here?  What are the secondary effects of *not* 
adding that to the URL?  And finally: have I already harmed my database 
file by opening it both with and without MV_STORE=FALSE?

Many thanks :-)

-- 
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+unsubscr...@googlegroups.com.
To post to this group, send email to h2-database@googlegroups.com.
Visit this group at https://groups.google.com/group/h2-database.
For more options, visit https://groups.google.com/d/optout.


[h2] Re: Please help, h2 console in El Capitan very very slow!!!

2016-12-20 Thread SkiAddict
Update: with the help of someone over at stackexchange 

 
I managed to get rid of "Santa's MacBook Pro", and inetTester 
 now resolves in 77ms.  The key thing 
was setting HostName (*not* LocalHostName) to 'trial':

sudo scutil --set HostName trial

With this done, h2 console launches in seconds.  What a huge relief!

So, with everything working I did some investigation.  I really do think 
there was a gremlin in the original string "Santa's MacBook Pro", since by 
successive small changes I've managed to get back to it in HostName -- and 
h2 console still launches in seconds.  Space chars, apostrophe, no problems 
at all.  It also has nothing to do with the contents of etc/hosts -- I'm 
now using my original copy of that file.

Many, many thanks Noel and Tomas, I could not have resolved this without 
your help.  You've made "Santa" very happy -- and right before Christmas, 
too! :-)

-- 
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+unsubscr...@googlegroups.com.
To post to this group, send email to h2-database@googlegroups.com.
Visit this group at https://groups.google.com/group/h2-database.
For more options, visit https://groups.google.com/d/optout.


[h2] Re: The last stable release Version 1.3.176 was published at 2014-04-05, when will 1.4.x stable version release?

2016-12-20 Thread Consu Leon
I have this same question.

Is H2 still a product you can base any level of 'production' on, 
considering no stable release for years and still have to build with now 
completely obsolete java 1.6 (I removed some lines from the pom and was 
able to build with java7 but don't want to use such build till it's marked 
stable).

We run still somewhat happily with h2-1.3.176.jar, but after inserting a 
few 10 records a drop of all tables takes literally forever. Only 
stopping the server and removing the files then gives a quick solution. 
This is probably the main reason we advise our customers not to run 
production with H2.

Once I attempted to switched to h2-1.4.187.jar but even the first tests 
failed quickly: SQL's we execute on 1.3 version yield different query 
results - some bugs in the query engine I guess - and back to 1.3.

Then we decided to wait till a stable release of 1.4 -but it never came.

Currently testing with h2-1.4.193.jar, initial impression is good; but 
further testing is needed to confirm.

Main point here is that it's obvious that h2 database is used in many 
places and often in 'production' situations where installing one of the big 
database players would be overkill (probably slower) or too expensive.

Those users then have to consider that their only choice is to run a 
'stable' version with known problems or a beta version that's 'nearly 
stable' but still built with completely obsolete java6.

Looking at the great performance we achieve with H2 and the ease of use my 
wish for 2017 is deliver a stable 1.4 version built with java8!

Best season wishes,

Leon

On Wednesday, December 7, 2016 at 5:14:44 AM UTC+1, Felix Lee wrote:
>
> The last stable release Version 1.3.176 was published at 2014-04-05, when 
> will 1.4.x stable version release? My company's internal policy is 
> forbidden 'beta' version to be used in production...
>

-- 
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+unsubscr...@googlegroups.com.
To post to this group, send email to h2-database@googlegroups.com.
Visit this group at https://groups.google.com/group/h2-database.
For more options, visit https://groups.google.com/d/optout.


Re: [h2] Concurrency at org.h2.store.fs.FileBase.read()

2016-12-20 Thread Noel Grandin
Not without changing the structure considerably - FileBase inherits from java.nio.channels.FileChannel, which has a 
position field, and multiple things changing that at the same time would cause problems.


We'd probably need to switch to using Java's asynchronous IO API to avoid that, 
which is a fairly large change.

You're welcome to submit patches, of course :-)

--
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+unsubscr...@googlegroups.com.
To post to this group, send email to h2-database@googlegroups.com.
Visit this group at https://groups.google.com/group/h2-database.
For more options, visit https://groups.google.com/d/optout.


[h2] Concurrency at org.h2.store.fs.FileBase.read()

2016-12-20 Thread Anatolii K
Hi

I see a lot of thread blocked at 

java.lang.Thread.State: BLOCKED (on object monitor)
at org.h2.store.fs.FileBase.read(FileBase.java:39)
- waiting to lock <0x0006f1dfcdd0> (a org.h2.store.fs.FileSplit)
at org.h2.mvstore.DataUtils.readFully(DataUtils.java:421)
at org.h2.mvstore.FileStore.readFully(FileStore.java:98)
at org.h2.mvstore.Page.read(Page.java:190)
at org.h2.mvstore.MVStore.readPage(MVStore.java:1952)
at org.h2.mvstore.MVMap.readPage(MVMap.java:800)
at org.h2.mvstore.Page.getChildPage(Page.java:217)
at org.h2.mvstore.MVMap.binarySearch(MVMap.java:489)
at org.h2.mvstore.MVMap.binarySearch(MVMap.java:490)
at org.h2.mvstore.MVMap.binarySearch(MVMap.java:490)
at org.h2.mvstore.MVMap.get(MVMap.java:471)
at 
org.h2.mvstore.db.TransactionStore$TransactionMap.getValue(TransactionStore.java:1036)
- locked <0x0006f1dd0608> (a org.h2.mvstore.MVMap)
at 
org.h2.mvstore.db.TransactionStore$TransactionMap.get(TransactionStore.java:1013)
at 
org.h2.mvstore.db.TransactionStore$TransactionMap.get(TransactionStore.java:981)
at org.h2.mvstore.db.MVPrimaryIndex.getRow(MVPrimaryIndex.java:215)
at org.h2.mvstore.db.MVTable.getRow(MVTable.java:463)
at 
org.h2.mvstore.db.MVSecondaryIndex$MVStoreCursor.get(MVSecondaryIndex.java:489)
at org.h2.index.IndexCursor.get(IndexCursor.java:288)
at org.h2.table.TableFilter.get(TableFilter.java:594)
at org.h2.command.dml.Update.update(Update.java:109)

Why the read() method is synchronized?
May be it would be better to use java.util.concurrent.locks.ReadWriteLock? 


-- 
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+unsubscr...@googlegroups.com.
To post to this group, send email to h2-database@googlegroups.com.
Visit this group at https://groups.google.com/group/h2-database.
For more options, visit https://groups.google.com/d/optout.


Re: [h2] SELECT FOR UPDATE does not work with MERGE

2016-12-20 Thread Noel Grandin
we don't currently have an answer for that, other than "be careful what order you do your MERGE statements in" because 
MERGE will take a full-table lock even in MVCC mode, and, as you found out, if you do MERGE statements in different 
orders in different transactions, you will get a timeout.


We probably need a LOCK TABLE command to make this kind of thing work in MVCC mode for places where it is impossible to 
order the MERGE commands consistently.


--
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+unsubscr...@googlegroups.com.
To post to this group, send email to h2-database@googlegroups.com.
Visit this group at https://groups.google.com/group/h2-database.
For more options, visit https://groups.google.com/d/optout.


Re: [h2] SELECT FOR UPDATE does not work with MERGE

2016-12-20 Thread Anatolii K
Really? It seems to work with UPDATE. I tested it with H2 console and using 
attached test with UPDATE instead of MERGE

If SELECT FOR UPDATE doesn't work what 


On Tuesday, December 20, 2016 at 2:30:45 PM UTC+5, Noel Grandin wrote:
>
> SELECT FOR UPDATE doesn't actually do anything useful in MVCC mode, I'm 
> afraid. 
>

-- 
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+unsubscr...@googlegroups.com.
To post to this group, send email to h2-database@googlegroups.com.
Visit this group at https://groups.google.com/group/h2-database.
For more options, visit https://groups.google.com/d/optout.


Re: [h2] SELECT FOR UPDATE does not work with MERGE

2016-12-20 Thread Noel Grandin

SELECT FOR UPDATE doesn't actually do anything useful in MVCC mode, I'm afraid.

--
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+unsubscr...@googlegroups.com.
To post to this group, send email to h2-database@googlegroups.com.
Visit this group at https://groups.google.com/group/h2-database.
For more options, visit https://groups.google.com/d/optout.


[h2] SELECT FOR UPDATE does not work with MERGE

2016-12-20 Thread Anatolii K
Hi

Please see attached file: I added method testConcurrentMergeDeadlock() to 
existing test.
This test failed with error
...
Caused by: java.lang.IllegalStateException: Entry is locked [1.4.193/101]
at org.h2.mvstore.DataUtils.newIllegalStateException(DataUtils.java:766)


The same test with UPDATE instead of MERGE works fine.
 
Looks like MERGE removes lock previously acquired by SELECT FOR UPDATE


-- 
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+unsubscr...@googlegroups.com.
To post to this group, send email to h2-database@googlegroups.com.
Visit this group at https://groups.google.com/group/h2-database.
For more options, visit https://groups.google.com/d/optout.
/*
 * Copyright 2004-2014 H2 Group. Multiple-Licensed under the MPL 2.0,
 * and the EPL 1.0 (http://h2database.com/html/license.html).
 * Initial Developer: H2 Group
 */
package org.h2.test.mvcc;

import java.sql.Connection;
import java.sql.ResultSet;
import java.sql.Statement;
import java.util.concurrent.CountDownLatch;

import org.h2.api.ErrorCode;
import org.h2.test.TestBase;
import org.h2.util.Task;

/**
 * Multi-threaded MVCC (multi version concurrency) test cases.
 */
public class TestMvccMultiThreaded extends TestBase {

/**
 * Run just this test.
 *
 * @param a ignored
 */
public static void main(String... a) throws Exception {
TestBase.createCaller().init().test();
}

@Override
public void test() throws Exception {
testMergeWithUniqueKeyViolation();
// not supported currently
if (!config.multiThreaded) {
testConcurrentMerge();
testConcurrentUpdate();
testConcurrentMergeDeadlock();
}
}

private void testMergeWithUniqueKeyViolation() throws Exception {
deleteDb(getTestName());
Connection conn = getConnection(getTestName());
Statement stat = conn.createStatement();
stat.execute("create table test(x int primary key, y int unique)");
stat.execute("insert into test values(1, 1)");
assertThrows(ErrorCode.DUPLICATE_KEY_1, stat).
execute("merge into test values(2, 1)");
stat.execute("merge into test values(1, 2)");
conn.close();

}

private void testConcurrentMerge() throws Exception {
deleteDb(getTestName());
int len = 3;
final Connection[] connList = new Connection[len];
for (int i = 0; i < len; i++) {
Connection conn = getConnection(
getTestName() + ";MVCC=TRUE;LOCK_TIMEOUT=500");
connList[i] = conn;
}
Connection conn = connList[0];
conn.createStatement().execute(
"create table test(id int primary key, name varchar)");
Task[] tasks = new Task[len];
final boolean[] stop = { false };
for (int i = 0; i < len; i++) {
final Connection c = connList[i];
c.setAutoCommit(false);
tasks[i] = new Task() {
@Override
public void call() throws Exception {
while (!stop) {
c.createStatement().execute(
"merge into test values(1, 'x')");
c.commit();
Thread.sleep(1);
}
}
};
tasks[i].execute();
}
Thread.sleep(1000);
stop[0] = true;
for (int i = 0; i < len; i++) {
tasks[i].get();
}
for (int i = 0; i < len; i++) {
connList[i].close();
}
deleteDb(getTestName());
}

private void testConcurrentUpdate() throws Exception {
deleteDb(getTestName());
int len = 2;
final Connection[] connList = new Connection[len];
for (int i = 0; i < len; i++) {
connList[i] = getConnection(
getTestName() + ";MVCC=TRUE");
}
Connection conn = connList[0];
conn.createStatement().execute(
"create table test(id int primary key, value int)");
conn.createStatement().execute(
"insert into test values(0, 0)");
final int count = 1000;
Task[] tasks = new Task[len];

final CountDownLatch latch = new CountDownLatch(len);

for (int i = 0; i < len; i++) {
final int x = i;
tasks[i] = new Task() {
@Override
public void call() throws Exception {
for (int a = 0; a < count; a++) {
connList[x].createStatement().execute(
"update test set value=value+1");
latch.countDown();
latch.await();
}
}
};