You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@ignite.apache.org by max904 <ma...@yandex.ru> on 2020/04/09 17:18:39 UTC

Ignite crashes with CorruptedTreeException: "B+Tree is corrupted" on a composite BinaryObject scenario

Ignite crashes when I use composite BinaryObject as a key and also include it
into the value object.

Here is the BinaryObject scenario:

// create a new composite key
BinaryObjectBuilder key1Builder =
Ignition.ignite().binary().builder(EmployeeId.class.getName());
key1Builder.setField("employeeNumber", 65348765, Integer.class);
key1Builder.setField("departmentNumber", 123, Integer.class);
BinaryObject key1 = key1Builder.build();

// create a new value
BinaryObjectBuilder emp1Builder =
Ignition.ignite().binary().builder(Employee.class.getName());
emp1Builder.setField("firstName", "John", String.class);
emp1Builder.setField("lastName", "Smith", String.class);
emp1Builder.setField("id", key1); // The composite key is also a part of the
value!
BinaryObject emp1 = emp1Builder.build();

// put the record to the DB - OK
employeeCache.put(key1, emp1);
// read it back - OK
BinaryObject emp2 = employeeCache.get(key1);
assertThat(emp2).isNotNull();
assertThat(emp2).isEqualTo(emp1);

// put the same key and value back to the DB - OK
employeeCache.put(key1, emp1); // OK!

// extract a key from the value
BinaryObject key2 = emp1.field("id");

// try to put a record with the extracted key - CRASH
employeeCache.put(key2, emp1); // CRASH!!! CorruptedTreeException: B+Tree is
corrupted ...

// try to put a record with the extracted key clone - CRASH
employeeCache.put(key2.clone(), emp1); // CRASH!!! CorruptedTreeException:
B+Tree is corrupted ...

// try to put a record with the extracted key rebuilt - OK
employeeCache.put(key2.toBuilder().build(), emp1); // OK!

This is clearly a bug as Ignite node crashes on a such basic use case!
I expect the scenario should work in all three cases, not only when I
explicitly rebuild the extracted key.
I verified it fails in both Ignite 2.8.0 and 2.7.6 (with a different error
though).
I can provide all the stack traces upon request.



--
Sent from: http://apache-ignite-users.70518.x6.nabble.com/

Re: Ignite crashes with CorruptedTreeException: "B+Tree is corrupted" on a composite BinaryObject scenario

Posted by max904 <ma...@yandex.ru>.
Thank you, Alex!
Yes, I figured that this line indeed causes this crash. And yes, I'm using
queries and I need this line.
For now, I'm using the workaround I've described (of rebuilding the key
BinaryObject). But it's quite expensive operation and I would like to avoid
it.
This looks like a bug to me, as in any case, Ignite should not crash so
miserably, especially on such common condition.
If you file a ticket, could you please post a reference number for it to
track?

Best regards,
Maxim



--
Sent from: http://apache-ignite-users.70518.x6.nabble.com/

Re: Ignite crashes with CorruptedTreeException: "B+Tree is corrupted" on a composite BinaryObject scenario

Posted by Ilya Kasnacheev <il...@gmail.com>.
Hello!

I have added comment to this ticket describing why does it happen and how
to fix it.

In Ignite, when you get key from your value binary object, it's actually a
wrapper pointing at some position in its parent (value) binary object. When
you try to put it to cache, indexing cannot process it correctly.

We should add code which tries to detach such objects, and throws some
exception when it cannot be detached (such as, if it references another
object inside parent)

Regards,
-- 
Ilya Kasnacheev


пт, 17 апр. 2020 г. в 20:52, akorensh <al...@gmail.com>:

> Maxim,
>   I've an appropriate ticket:
> https://issues.apache.org/jira/browse/IGNITE-12911
> Thanks, Alex
>
>
>
> --
> Sent from: http://apache-ignite-users.70518.x6.nabble.com/
>

Re: Ignite crashes with CorruptedTreeException: "B+Tree is corrupted" on a composite BinaryObject scenario

Posted by akorensh <al...@gmail.com>.
Maxim,
  I've an appropriate ticket:
https://issues.apache.org/jira/browse/IGNITE-12911
Thanks, Alex



--
Sent from: http://apache-ignite-users.70518.x6.nabble.com/

Re: Ignite crashes with CorruptedTreeException: "B+Tree is corrupted" on a composite BinaryObject scenario

Posted by max904 <ma...@yandex.ru>.
Thank you, Alex!
Yes, I figured that this line indeed causes this crash. And yes, I'm using
queries and I need this line.
For now, I'm using the workaround I've described (of rebuilding the key
BinaryObject). But it's quite expensive operation and I would like to avoid
it.
This looks like a bug to me, as in any case, Ignite should not crash so
miserably, especially on such common condition.
If you file a ticket, could you please post a reference number for it to
track?

Best regards,
Maxim




--
Sent from: http://apache-ignite-users.70518.x6.nabble.com/

Re: Ignite crashes with CorruptedTreeException: "B+Tree is corrupted" on a composite BinaryObject scenario

Posted by akorensh <al...@gmail.com>.
Hi,
  I was able to reproduce your use-case.
  This line causes the issues you describe:
cacheConfig.setIndexedTypes(EmployeeId.class, Employee.class);
  Comment it out, and everything works.

   If you need Indexes, define them as need be, but  remove these lines:
         employeeCache.put(key2, emp1); // CRASH!!! CorruptedTreeException:
B+Tree is corrupted

         employeeCache.put(key2.clone(), emp1); // CRASH!!!

   Use other means to compose key2.
   

   I will look into why this failure occurs, and raise appropriate tickets
if necessary.
Thanks, Alex




--
Sent from: http://apache-ignite-users.70518.x6.nabble.com/

Re: Ignite crashes with CorruptedTreeException: "B+Tree is corrupted" on a composite BinaryObject scenario

Posted by max904 <ma...@yandex.ru>.
Yes, of course I'm using "cache.withKeepBinary()". Below is my exact
reproducer:

final URL configUrl =
getClass().getClassLoader().getResource("example-ignite.xml");
final Ignite ignite = Ignition.start(configUrl);

final CacheConfiguration<EmployeeId, Employee> cacheConfig = new
CacheConfiguration<>("Employee");
cacheConfig.setIndexedTypes(EmployeeId.class, Employee.class);

IgniteCache<EmployeeId, Employee> cache =
ignite.getOrCreateCache(cacheConfig);
IgniteCache<BinaryObject, BinaryObject> employeeCache =
cache.withKeepBinary();

try {
  BinaryObjectBuilder key1Builder =
ignite.binary().builder(EmployeeId.class.getName());
  key1Builder.setField("employeeNumber", 65348765, Integer.class);
  key1Builder.setField("departmentNumber", 123, Integer.class);
  BinaryObject key1 = key1Builder.build();
  BinaryObjectBuilder emp1Builder =
ignite.binary().builder(Employee.class.getName());
  emp1Builder.setField("firstName", "John", String.class);
  emp1Builder.setField("lastName", "Smith", String.class);
  emp1Builder.setField("id", key1);
  BinaryObject emp1 = emp1Builder.build();

  employeeCache.put(key1, emp1);
  BinaryObject emp2 = employeeCache.get(key1);
  assertThat(emp2).isNotNull();
  assertThat(emp2).isEqualTo(emp1);

  employeeCache.put(key1, emp1);

  BinaryObject key2 = emp1.field("id");
  employeeCache.put(key2, emp1); // CRASH!!! CorruptedTreeException: B+Tree
is corrupted

  //employeeCache.put(key2.clone(), emp1); // CRASH!!!
CorruptedTreeException: B+Tree is corrupted

  employeeCache.put(key2.toBuilder().build(), emp1); // OK!
} finally {
  Ignition.stop(true);
}

------------

Where the data types are the following:

public interface EmployeeId {
  int getEmployeeNumber();
  void setEmployeeNumber(int employeeNumber);

  int getDepartmentNumber();
  void setDepartmentNumber(int departmentNumber);
}

public interface Employee {

  EmployeeId getId();
  void setId(EmployeeId id);

  String getFirstName();
  void setFirstName(String firstName);

  String getLastName();
  void setLastName(String lastName);

  Date getBirthDate();
  void setBirthDate(Date birthDate);

  ...
}





--
Sent from: http://apache-ignite-users.70518.x6.nabble.com/

Re: Ignite crashes with CorruptedTreeException: "B+Tree is corrupted" on a composite BinaryObject scenario

Posted by akorensh <al...@gmail.com>.
Hi,
   When running your code I created the cache as follows:
          IgniteCache<BinaryObject, BinaryObject> employeeCache =
ignite.getOrCreateCache("employeeCache").withKeepBinary();

  With the ".WithKeepBinary()" flag set code works, otherwise there are
serialization errors.

  If you still get errors w/this flag set, send a reproducer, and I'll take
a look.

   more info:
https://www.gridgain.com/docs/latest/developers-guide/key-value-api/binary-objects
   Binary Objects Example:
https://github.com/apache/ignite/blob/master/examples/src/main/java/org/apache/ignite/examples/binary/datagrid/CacheClientBinaryPutGetExample.java

Thanks, Alex



--
Sent from: http://apache-ignite-users.70518.x6.nabble.com/