Re: [h2] Re: Timeout trying to lock table

2016-04-08 Thread Stuart Goldberg
Steve:

I'm going to answer my own question. I looked at your code change and 
indeed the current version of H2 (1.4.191) has your changes, yet this is 
the version that I am using!

What's gripping about your posting is that the exception I am getting 
involves an index based on time stamps!

Could there be some other place in the H2 code that exhibits this bug that 
might explain what I am seeing?

- Stuart

On Friday, April 8, 2016 at 9:08:32 AM UTC-4, Stuart Goldberg wrote:
>
> What release number is that? Because I think I'm using the latest release.
>
> Please clarify
> On Apr 8, 2016 8:09 AM, "Steve McLeod"  wrote:
>
>> This reminds me somewhat a bug I encountered in January. It affected what 
>> was then the latest update, and the problem affected the old PageStore. I 
>> fixed it, and the fix is in the current release of H2:
>> https://github.com/h2database/h2database/pull/224
>>
>> The appearance of the bug was the same: searching in an index for the row 
>> to delete sometimes failed.
>>
>>
>>
>>
>> On Thursday, 7 April 2016 09:19:20 UTC+2, Noel Grandin wrote:
>>>
>>> Hmmm, It's vaguely possible that you're hitting a bug in H2, but you're 
>>> using the old PageStore, which is pretty robust. 
>>>
>>> At a guess, I would say most likely you have dodgy hardware, and that 
>>> index shows up as the corruption just because that 
>>> index gets hit the most. 
>>>
>> -- 
>> 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/wEdRn9bbwMM/unsubscribe.
>> To unsubscribe from this group and all its topics, 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.
>>
>

-- 
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] MVStore serialization

2016-04-08 Thread Noel Grandin

Your test code isn't actually testing serialisation: you need to test passing 
an instance of your class into

ObjectOutputStream

and then reading it back via

ObjectInputStream

--
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] MVStore serialization

2016-04-08 Thread dmitry . meshkov
Outside of MVStore it works fine, I wrote special test for this

val row = Row(AccState(balance), txs, lastRowHeight)

val b = ByteBuffer.allocate(row.bytes.length)
b.put(row.bytes)
b.flip()

val des = row.read(b)
des shouldBe row


On Friday, April 8, 2016 at 4:24:39 PM UTC+3, Noel Grandin wrote:
>
> Your class does not obey the serialisation rules: 
>
> Caused by: java.io.InvalidClassException: 
> scorex.transaction.PaymentTransaction; no valid constructor 
>
>

-- 
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] MVStore serialization

2016-04-08 Thread Noel Grandin

Your class does not obey the serialisation rules:

Caused by: java.io.InvalidClassException: 
scorex.transaction.PaymentTransaction; no valid constructor

--
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: Timeout trying to lock table

2016-04-08 Thread Stuart Goldberg
What release number is that? Because I think I'm using the latest release.

Please clarify
On Apr 8, 2016 8:09 AM, "Steve McLeod"  wrote:

> This reminds me somewhat a bug I encountered in January. It affected what
> was then the latest update, and the problem affected the old PageStore. I
> fixed it, and the fix is in the current release of H2:
> https://github.com/h2database/h2database/pull/224
>
> The appearance of the bug was the same: searching in an index for the row
> to delete sometimes failed.
>
>
>
>
> On Thursday, 7 April 2016 09:19:20 UTC+2, Noel Grandin wrote:
>>
>> Hmmm, It's vaguely possible that you're hitting a bug in H2, but you're
>> using the old PageStore, which is pretty robust.
>>
>> At a guess, I would say most likely you have dodgy hardware, and that
>> index shows up as the corruption just because that
>> index gets hit the most.
>>
> --
> 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/wEdRn9bbwMM/unsubscribe.
> To unsubscribe from this group and all its topics, 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.
>

-- 
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] MVStore serialization

2016-04-08 Thread dmitry . meshkov
Next line is map.put() call

Caused by: java.lang.IllegalArgumentException: Could not deserialize [-84, 
-19, 0, 5, 115, 114, 0, 43, 115, 99, 111, 114, 101, 120, 46, 116, 114, 97, 
110, 115, 97, 99, 116, 105, 111, 110, 46, 115, 116, 97, 116, 101, 46, 100, 
97, 116, 97, 98, 97, 115, 101, 46, 115, 116, 97, 116, 101, 46, 82, 111, 
119, -82, -90, -108, -50, 87, 81, 2, -88, 2, 0, 5, 90, 0, 8, 98, 105, 116, 
109, 97, 112, 36, 48, 73, 0, 13, 108, 97, 115, 116, 82, 111, 119, 72, 101, 
105, 103, 104, 116, 91, 0, 5, 98, 121, 116, 101, 115, 116, 0, 2, 91, 66, 
76, 0, 6, 114, 101, 97, 115, 111, 110, 116, 0, 22, 76, 115, 99, 97, 108, 
97, 47, 99, 111, 108, 108, 101, 99, 116, 105, 111, 110, 47, 83, 101, 113, 
59, 76, 0, 5, 115, 116, 97, 116, 101, 116, 0, 50, 76, 115, 99, 111, 114, 
101, 120, 47, 116, 114, 97, 110, 115, 97, 99, 116, 105, 111, 110, 47, 115, 
116, 97, 116, 101, 47, 100, 97, 116, 97, 98, 97, 115, 101, 47, 115, 116, 
97, 116, 101, 47, 65, 99, 99, 83, 116, 97, 116, 101, 59, 120, 112, 0, 0, 0, 
0, 1, 112, 115, 114, 0, 50, 115, 99, 97, 108, 97, 46, 99, 111, 108, 108, 
101, 99, 116, 105, 111, 110, 46,... [1.4.191/0]
at org.h2.mvstore.DataUtils.newIllegalArgumentException(DataUtils.java:736)
at org.h2.mvstore.type.ObjectDataType.deserialize(ObjectDataType.java:372)
at 
org.h2.mvstore.type.ObjectDataType$SerializedObjectType.read(ObjectDataType.java:1547)
at org.h2.mvstore.type.ObjectDataType.read(ObjectDataType.java:232)
at org.h2.mvstore.type.ObjectDataType.read(ObjectDataType.java:115)
at org.h2.mvstore.Page.read(Page.java:711)
at org.h2.mvstore.Page.read(Page.java:195)
at org.h2.mvstore.MVStore.readPage(MVStore.java:1939)
at org.h2.mvstore.MVMap.readPage(MVMap.java:736)
at org.h2.mvstore.Page.getChildPage(Page.java:217)
at org.h2.mvstore.MVMap.put(MVMap.java:195)
at org.h2.mvstore.MVMap.put(MVMap.java:121)
at 
scorex.lagonaki.integration.StoredStateUnitTests$$anonfun$2$$anonfun$apply$mcV$sp$2.apply(StoredStateUnitTests.scala:40)
at 
scorex.lagonaki.integration.StoredStateUnitTests$$anonfun$2$$anonfun$apply$mcV$sp$2.apply(StoredStateUnitTests.scala:36)
at 
org.scalatest.prop.GeneratorDrivenPropertyChecks$$anonfun$56.liftedTree17$1(GeneratorDrivenPropertyChecks.scala:1267)
at 
org.scalatest.prop.GeneratorDrivenPropertyChecks$$anonfun$56.apply(GeneratorDrivenPropertyChecks.scala:1266)
at 
org.scalatest.prop.GeneratorDrivenPropertyChecks$$anonfun$56.apply(GeneratorDrivenPropertyChecks.scala:1264)
at 
org.scalacheck.Prop$$anonfun$forAll$3$$anonfun$apply$20.apply(Prop.scala:787)
at 
org.scalacheck.Prop$$anonfun$forAll$2$$anonfun$apply$19.apply(Prop.scala:776)
at 
org.scalacheck.Prop$$anonfun$forAllShrink$1$$anonfun$3.apply(Prop.scala:714)
at 
org.scalacheck.Prop$$anonfun$forAllShrink$1$$anonfun$3.apply(Prop.scala:714)
at org.scalacheck.Prop$.secure(Prop.scala:458)
at 
org.scalacheck.Prop$$anonfun$forAllShrink$1.org$scalacheck$Prop$$anonfun$$result$1(Prop.scala:714)
at org.scalacheck.Prop$$anonfun$forAllShrink$1.apply(Prop.scala:751)
at org.scalacheck.Prop$$anonfun$forAllShrink$1.apply(Prop.scala:708)
at org.scalacheck.Prop$$anonfun$apply$5.apply(Prop.scala:293)
at org.scalacheck.Prop$$anonfun$apply$5.apply(Prop.scala:292)
at org.scalacheck.PropFromFun.apply(Prop.scala:21)
at 
org.scalacheck.Prop$$anonfun$forAllShrink$1.org$scalacheck$Prop$$anonfun$$result$1(Prop.scala:715)
at org.scalacheck.Prop$$anonfun$forAllShrink$1.apply(Prop.scala:751)
at org.scalacheck.Prop$$anonfun$forAllShrink$1.apply(Prop.scala:708)
at org.scalacheck.Prop$$anonfun$apply$5.apply(Prop.scala:293)
at org.scalacheck.Prop$$anonfun$apply$5.apply(Prop.scala:292)
at org.scalacheck.PropFromFun.apply(Prop.scala:21)
at 
org.scalacheck.Prop$$anonfun$forAllShrink$1.org$scalacheck$Prop$$anonfun$$result$1(Prop.scala:715)
at org.scalacheck.Prop$$anonfun$forAllShrink$1.apply(Prop.scala:751)
at org.scalacheck.Prop$$anonfun$forAllShrink$1.apply(Prop.scala:708)
at org.scalacheck.Prop$$anonfun$apply$5.apply(Prop.scala:293)
at org.scalacheck.Prop$$anonfun$apply$5.apply(Prop.scala:292)
at org.scalacheck.PropFromFun.apply(Prop.scala:21)
at org.scalacheck.Test$.org$scalacheck$Test$$workerFun$1(Test.scala:323)
at org.scalacheck.Test$$anonfun$2.apply(Test.scala:352)
at org.scalacheck.Test$$anonfun$2.apply(Test.scala:352)
at org.scalacheck.Platform$.runWorkers(Platform.scala:40)
at org.scalacheck.Test$.check(Test.scala:352)
at org.scalatest.prop.Checkers$.doCheck(Checkers.scala:370)
... 54 more
Caused by: java.io.InvalidClassException: 
scorex.transaction.PaymentTransaction; no valid constructor
at 
java.io.ObjectStreamClass$ExceptionInfo.newInvalidClassException(ObjectStreamClass.java:150)
at java.io.ObjectStreamClass.checkDeserialize(ObjectStreamClass.java:790)
at java.io.ObjectInputStream.readOrdinaryObject(ObjectInputStream.java:1775)
at java.io.ObjectInputStream.readObject0(ObjectInputStream.java:1351)
at java.io.ObjectInputStream.readObject(ObjectInputStream.java:371)
at 
scala.collection.immutable.List$SerializationProxy.readObject(List.scala:479)
at sun.reflect

Re: [h2] MVStore serialization

2016-04-08 Thread Noel Grandin

you left out part of the exception.

--
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: Timeout trying to lock table

2016-04-08 Thread Steve McLeod
This reminds me somewhat a bug I encountered in January. It affected what 
was then the latest update, and the problem affected the old PageStore. I 
fixed it, and the fix is in the current release of H2:
https://github.com/h2database/h2database/pull/224

The appearance of the bug was the same: searching in an index for the row 
to delete sometimes failed.




On Thursday, 7 April 2016 09:19:20 UTC+2, Noel Grandin wrote:
>
> Hmmm, It's vaguely possible that you're hitting a bug in H2, but you're 
> using the old PageStore, which is pretty robust. 
>
> At a guess, I would say most likely you have dodgy hardware, and that 
> index shows up as the corruption just because that 
> index gets hit the most. 
>

-- 
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 serialization

2016-04-08 Thread dmitry . meshkov
Hi!

I'm trying to use MVStore to keep my custom object. It works fine for the 
first time, but when I try to reopen my database, I get error like:

Caused by: java.lang.IllegalArgumentException: Could not deserialize [-84, -
19, .. [1.4.191/0]
 at org.h2.mvstore.DataUtils.newIllegalArgumentException(DataUtils.java:736)
 at org.h2.mvstore.type.ObjectDataType.deserialize(ObjectDataType.java:372)
 at org.h2.mvstore.type.ObjectDataType$SerializedObjectType.read(
ObjectDataType.java:1547)
 at org.h2.mvstore.type.ObjectDataType.read(ObjectDataType.java:232)
 at org.h2.mvstore.type.ObjectDataType.read(ObjectDataType.java:115)
 at org.h2.mvstore.Page.read(Page.java:711)
 at org.h2.mvstore.Page.read(Page.java:195)
 at org.h2.mvstore.MVStore.readPage(MVStore.java:1939)
 at org.h2.mvstore.MVMap.readPage(MVMap.java:736)
 at org.h2.mvstore.Page.getChildPage(Page.java:217)
 at org.h2.mvstore.MVMap.put(MVMap.java:195)
 at org.h2.mvstore.MVMap.put(MVMap.java:121)


The simple test case, which works for the first time, but failes on the 
second one,  looks like:

val db = new MVStore.Builder().fileName("/tmp/mvstoretest.dat").open()

forAll(paymentGenerator, Gen.posNum[Long], Gen.posNum[Int]) { (tx: 
PaymentTransaction,
   balance: Long,
   lastRowHeight: 
Int) =>

  val map: MVMap[Int, Row] = db.openMap("map", new MVMap.Builder[Int, Row])
  val row = Row(AccState(balance), Seq(tx), lastRowHeight)
  map.put(lastRowHeight, row)
  map.get(lastRowHeight) shouldBe row
}
db.commit()



Object class is: 

case class Row(state: AccState, reason: Reason, lastRowHeight: Int) extends 
DataType {

 lazy val bytes: Array[Byte] = Ints.toByteArray(lastRowHeight) ++
 Longs.toByteArray(state.balance) ++
 Ints.toByteArray(reason.length) ++
 reason.foldLeft(Array.empty: Array[Byte]) { (b, scr) =>
 b ++ Ints.toByteArray(scr.bytes.length) ++ scr.bytes
 }

 override def compare(a: scala.Any, b: scala.Any): Int = (a, b) match {
 case (o1: Row, o2: Row) => BigInt(o1.bytes).compare(BigInt(o2.bytes))
 case _ => 1
 }

 override def write(buff: WriteBuffer, obj: scala.Any): Unit = {
 buff.put(obj.asInstanceOf[Row].bytes)
 }

 override def write(buff: WriteBuffer, obj: Array[AnyRef], len: Int, key: 
Boolean): Unit =
 obj.foreach(o => write(buff, o))

 override def read(buff: ByteBuffer): AnyRef = Row.deserialize(buff)

 override def read(buff: ByteBuffer, obj: Array[AnyRef], len: Int, key: 
Boolean): Unit = {
 (0 until len) foreach { i =>
 obj(i) = read(buff);
 }
 }

 override def getMemory(obj: scala.Any): Int = bytes.length
}

object Row {
 def deserialize(bytes: Array[Byte]): Row = {
 val b = ByteBuffer.allocate(bytes.length)
 b.put(bytes)
 b.flip()
 deserialize(b)
 }


 def deserialize(b: ByteBuffer): Row = {
 val lrh = b.getInt
 val accBalance = b.getLong
 val reasonLength = b.getInt()
 val reason: Seq[StateChangeReason] = (0 until reasonLength) map { i =>
 val txSize = b.getInt
 val tx = new Array[Byte](txSize)
 b.get(tx)
 if (txSize == 8) FeesStateChange(Longs.fromByteArray(tx))
 else LagonakiTransaction.parse(tx).get //todo: .get w/out catching
 }
 Row(AccState(accBalance), reason, lrh)
 }
}

-- 
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.