Uploaded image for project: 'Ignite'
  1. Ignite
  2. IGNITE-13192

Thin client with compactFooter: exception on get value after INSERT and put

    XMLWordPrintableJSON

    Details

    • 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

      Description

      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;
               }

        Attachments

          Issue Links

            Activity

              People

              • Assignee:
                alex_pl Aleksey Plekhanov
                Reporter:
                surkov Surkov Aleksandr
              • Votes:
                0 Vote for this issue
                Watchers:
                4 Start watching this issue

                Dates

                • Created:
                  Updated:
                  Resolved:

                  Time Tracking

                  Estimated:
                  Original Estimate - Not Specified
                  Not Specified
                  Remaining:
                  Remaining Estimate - 0h
                  0h
                  Logged:
                  Time Spent - 1h
                  1h