You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@ignite.apache.org by "Maxim Pudov (JIRA)" <ji...@apache.org> on 2019/02/06 14:00:00 UTC
[jira] [Assigned] (IGNITE-11219) CREATE TABLE with template doesn't
work properly with data inserted from KV API
[ https://issues.apache.org/jira/browse/IGNITE-11219?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]
Maxim Pudov reassigned IGNITE-11219:
------------------------------------
Assignee: Maxim Pudov
> CREATE TABLE with template doesn't work properly with data inserted from KV API
> -------------------------------------------------------------------------------
>
> Key: IGNITE-11219
> URL: https://issues.apache.org/jira/browse/IGNITE-11219
> Project: Ignite
> Issue Type: Bug
> Affects Versions: 2.7
> Reporter: Evgenii Zhuravlev
> Assignee: Maxim Pudov
> Priority: Critical
>
> When you use a template for your table, it takes the affinityMapper field from this template, which was set at the moment of creating a context for a different type without any keyConfigurations. This leads to the problem with accessing data from SQL if it was inserted using Key-value API
> Here is a code to reproduce the issue:
> {code:java}
> Ignition.setClientMode(true);
> Ignite ignite = Ignition.start("examples/config/example-ignite.xml");
> ignite.cluster().active(true);
> IgniteCache cache = ignite.getOrCreateCache("test");
> cache.query(new SqlFieldsQuery("CREATE TABLE IF NOT EXISTS TEST\n" +
> "(\n" +
> " TEST_ID NUMBER(15) NOT NULL,\n" +
> " TEST_FIELD VARCHAR2(100),\n" +
> " PRIMARY KEY (TEST_ID)\n" +
> ") with \"TEMPLATE=TEST_TEMPLATE,KEY_TYPE=TEST_KEY ,CACHE_NAME=TEST_CACHE , VALUE_TYPE=TEST_VALUE,ATOMICITY=TRANSACTIONAL\";").setSchema("PUBLIC"));
> for (int i = 0; i < 100; i++) {
> BinaryObjectBuilder keyBuilder = ignite.binary().builder("TEST_KEY");
> keyBuilder.setField("TEST_ID", new BigDecimal(111111111111111l + i));
> BinaryObjectBuilder valueBuilder = ignite.binary().builder("TEST_VALUE");
> valueBuilder.setField("TEST_FIELD", "123123" + i);
> ignite.cache("TEST_CACHE").withKeepBinary().put(keyBuilder.build(), valueBuilder.build());
> }
> //returns 100 rows as we expect
> System.out.println("FOUND:" + ignite.cache("TEST_CACHE").query(new SqlFieldsQuery("Select * from TEST")).getAll().size());
> //returns 0 rows - should return 1
> System.out.println("FOUND:" + ignite.cache("TEST_CACHE").query(new SqlFieldsQuery("Select TEST_FIELD from TEST where TEST_ID = 111111111111111")).getAll());
> for (int i = 0; i < 100; i++)
> //returns 0 rows - should return 1
> System.out.println("FOUND:" + ignite.cache("TEST_CACHE").query(new SqlFieldsQuery("Select TEST_FIELD from TEST where TEST_ID = " + (111111111111111l + i))).getAll());
> {code}
> Here is a test template:
> {code:java}
> <bean class="org.apache.ignite.configuration.CacheConfiguration">
> <property name="name" value="TEST_TEMPLATE*"/>
> </bean>
> {code}
> Steps to reproduce:
> 1. Start a server node, for example, using ExampleNodeStartup.
> 2. Start a client node using the code provided above with the template in configuration.
> It will show that it can't find these rows in the cache.
> Possible quickfix:
> set affinityMapper to cfgTemplate in GridCacheProcessor.getConfigFromTemplate:
> cfgTemplate.setAffinityMapper(null)
> Also, interesting thing - if you replace = with IS, then everything works.
--
This message was sent by Atlassian JIRA
(v7.6.3#76005)