-
Type:
Bug
-
Status: Resolved
-
Priority:
Major
-
Resolution: Fixed
-
Affects Version/s: None
-
Fix Version/s: 2.9
-
Component/s: thin client
-
Labels:None
-
Ignite Flags:Release Notes Required
Start use thin client with compact footer equals true(setCompactFooter(true) ). Create table through SQL. Then execut INSERT and put() with different id/key. And then call method get() with id from INSERT. A BinaryObjectException will occur. It is expected the value inserted through INSERT.
Reproducer:
@Test public void testSql() throws Exception { try (Ignite ignored = Ignition.start(Config.getServerConfiguration()); Ignite ignored2 = Ignition.start(Config.getServerConfiguration()); IgniteClient client = Ignition.startClient(new ClientConfiguration().setBinaryConfiguration(new BinaryConfiguration().setCompactFooter(true)).setAddresses(Config.SERVER)) ) { // 1. Create table client.query( new SqlFieldsQuery(String.format( "CREATE TABLE IF NOT EXISTS Person (id INT PRIMARY KEY, name VARCHAR) WITH \"VALUE_TYPE=%s,CACHE_NAME=%s\"", Person.class.getName(), "PersonCache" )).setSchema("PUBLIC") ).getAll(); int key = 1; Person val = new Person(key, "Person " + key); // 2. INSERT value to cache client.query(new SqlFieldsQuery("INSERT INTO Person(id, name) VALUES(?, ?)") .setArgs(val.getId(), val.getName()) .setSchema("PUBLIC") ) .getAll(); // 4. Execute put(). The key must be different from what was in INSERT // Without this line, there will be no exception client.getOrCreateCache("PersonCache").put(2, val); // 5. Execute get(). There will be an exception: org.apache.ignite.binary.BinaryObjectException: Cannot find metadata for object with compact footer assertNotNull(client.getOrCreateCache("PersonCache").get(1)); } }
Decision:
+++ modules/core/src/main/java/org/apache/ignite/internal/client/thin/TcpIgniteClient.java (date 1593418365270) @@ -365,6 +365,11 @@ @Override public BinaryType metadata(int typeId, int schemaId) throws BinaryObjectException { BinaryType meta = metadata(typeId); + if (meta != null && !((BinaryTypeImpl)meta).metadata().hasSchema(schemaId)) { + cache.metadata().removeIf(t -> t.typeId() == typeId); + meta = metadata(typeId); + } + return meta != null && ((BinaryTypeImpl)meta).metadata().hasSchema(schemaId) ? meta : null; }
- links to