ignite-issues mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Pavel Konstantinov (JIRA)" <j...@apache.org>
Subject [jira] [Comment Edited] (IGNITE-6671) [Web Console] Wrong java type used in generated config from DB schema
Date Tue, 24 Oct 2017 03:14:00 GMT

    [ https://issues.apache.org/jira/browse/IGNITE-6671?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=16216230#comment-16216230
] 

Pavel Konstantinov edited comment on IGNITE-6671 at 10/24/17 3:13 AM:
----------------------------------------------------------------------

Failed tested in branch:
# created a table with types described above
# imported into project via web console
{code}
                            <property name="types">
                                <list>
                                    <bean class="org.apache.ignite.cache.store.jdbc.JdbcType">
                                        <property name="cacheName" value="Ignite6671Cache"/>
                                        <property name="keyType" value="model.Ignite6671Key"/>
                                        <property name="valueType" value="model.Ignite6671"/>
                                        <property name="databaseSchema" value="GRIDGAIN"/>
                                        <property name="databaseTable" value="IGNITE6671"/>

                                        <property name="keyFields">
                                            <list>
                                                <bean class="org.apache.ignite.cache.store.jdbc.JdbcTypeField">
                                                    <constructor-arg>
                                                        <util:constant static-field="java.sql.Types.NUMERIC"/>
                                                    </constructor-arg>
                                                    <constructor-arg value="F0"/>
                                                    <constructor-arg value="java.math.BigDecimal"/>
                                                    <constructor-arg value="f0"/>
                                                </bean>
                                            </list>
                                        </property>

                                        <property name="valueFields">
                                            <list>
                                                <bean class="org.apache.ignite.cache.store.jdbc.JdbcTypeField">
                                                    <constructor-arg>
                                                        <util:constant static-field="java.sql.Types.NUMERIC"/>
                                                    </constructor-arg>
                                                    <constructor-arg value="F0"/>
                                                    <constructor-arg value="java.math.BigDecimal"/>
                                                    <constructor-arg value="f0"/>
                                                </bean>

                                                <bean class="org.apache.ignite.cache.store.jdbc.JdbcTypeField">
                                                    <constructor-arg>
                                                        <util:constant static-field="java.sql.Types.TINYINT"/>
                                                    </constructor-arg>
                                                    <constructor-arg value="F1"/>
                                                    <constructor-arg value="java.lang.Byte"/>
                                                    <constructor-arg value="f1"/>
                                                </bean>

                                                <bean class="org.apache.ignite.cache.store.jdbc.JdbcTypeField">
                                                    <constructor-arg>
                                                        <util:constant static-field="java.sql.Types.SMALLINT"/>
                                                    </constructor-arg>
                                                    <constructor-arg value="F3"/>
                                                    <constructor-arg value="java.lang.Short"/>
                                                    <constructor-arg value="f3"/>
                                                </bean>

                                                <bean class="org.apache.ignite.cache.store.jdbc.JdbcTypeField">
                                                    <constructor-arg>
                                                        <util:constant static-field="java.sql.Types.INTEGER"/>
                                                    </constructor-arg>
                                                    <constructor-arg value="F5"/>
                                                    <constructor-arg value="java.lang.Integer"/>
                                                    <constructor-arg value="f5"/>
                                                </bean>

                                                <bean class="org.apache.ignite.cache.store.jdbc.JdbcTypeField">
                                                    <constructor-arg>
                                                        <util:constant static-field="java.sql.Types.BIGINT"/>
                                                    </constructor-arg>
                                                    <constructor-arg value="F10"/>
                                                    <constructor-arg value="java.lang.Long"/>
                                                    <constructor-arg value="f10"/>
                                                </bean>

                                                <bean class="org.apache.ignite.cache.store.jdbc.JdbcTypeField">
                                                    <constructor-arg>
                                                        <util:constant static-field="java.sql.Types.NUMERIC"/>
                                                    </constructor-arg>
                                                    <constructor-arg value="F19"/>
                                                    <constructor-arg value="java.math.BigDecimal"/>
                                                    <constructor-arg value="f19"/>
                                                </bean>

                                                <bean class="org.apache.ignite.cache.store.jdbc.JdbcTypeField">
                                                    <constructor-arg>
                                                        <util:constant static-field="java.sql.Types.NUMERIC"/>
                                                    </constructor-arg>
                                                    <constructor-arg value="F20"/>
                                                    <constructor-arg value="java.math.BigDecimal"/>
                                                    <constructor-arg value="f20"/>
                                                </bean>
                                            </list>
                                        </property>
                                    </bean>
                                </list>
                            </property>
                        </bean>
                    </property>

                    <property name="readThrough" value="true"/>
                    <property name="writeThrough" value="true"/>

                    <property name="queryEntities">
                        <list>
                            <bean class="org.apache.ignite.cache.QueryEntity">
                                <property name="keyType" value="model.Ignite6671Key"/>
                                <property name="valueType" value="model.Ignite6671"/>

                                <property name="keyFields">
                                    <list>
                                        <value>f0</value>
                                    </list>
                                </property>

                                <property name="fields">
                                    <map>
                                        <entry key="f0" value="java.math.BigDecimal"/>
                                        <entry key="f1" value="java.lang.Byte"/>
                                        <entry key="f3" value="java.lang.Short"/>
                                        <entry key="f5" value="java.lang.Integer"/>
                                        <entry key="f10" value="java.lang.Long"/>
                                        <entry key="f19" value="java.math.BigDecimal"/>
                                        <entry key="f20" value="java.math.BigDecimal"/>
                                    </map>
                                </property>
                            </bean>
                        </list>
                    </property>
{code}
# started two node using ServerNodeSpringStartup + ServerNodeCodeStartup
# started web agent and connected to cluster
# open SQL in web console and successfully inserted two rows
{code}
insert into "Ignite6671Cache".Ignite6671(f0,f1,f3,f5,f10,f19,f20)values(123456789,9,999,99999,9999999999,9999999999999999999,99999999999999999999)
insert into "Ignite6671Cache".Ignite6671(f0,f1,f3,f5,f10,f19,f20)values(12345689,9,999,99999,9999999999,9999999999999999999,99999999999999999999)
{code}
# then tried to 
{code}
select * from "Ignite6671Cache".Ignite6671
{code}
and got error
{code}
Error: Numeric value (9999999999999999999) out of range of long (-9223372036854775808 - 9223372036854775807)
at [Source: buffer(okhttp3.internal.http1.Http1Codec$FixedLengthSource@d13283f).inputStream();
line: 1, column: 212] (through reference chain: org.apache.ignite.console.agent.rest.RestResponseHolder["response"])
{code}


was (Author: pkonstantinov):
Failed tested in branch:
# created a table with types described above
# imported into project via web console
# started two node using ServerNodeSpringStartup + ServerNodeCodeStartup
# started web agent and connected to cluster
# open SQL in web console and successfully inserted two rows
{code}
insert into "Ignite6671Cache".Ignite6671(f0,f1,f3,f5,f10,f19,f20)values(123456789,9,999,99999,9999999999,9999999999999999999,99999999999999999999)
insert into "Ignite6671Cache".Ignite6671(f0,f1,f3,f5,f10,f19,f20)values(12345689,9,999,99999,9999999999,9999999999999999999,99999999999999999999)
{code}
# then tried to 
{code}
select * from "Ignite6671Cache".Ignite6671
{code}
and got error
{code}
Error: Numeric value (9999999999999999999) out of range of long (-9223372036854775808 - 9223372036854775807)
at [Source: buffer(okhttp3.internal.http1.Http1Codec$FixedLengthSource@d13283f).inputStream();
line: 1, column: 212] (through reference chain: org.apache.ignite.console.agent.rest.RestResponseHolder["response"])
{code}

> [Web Console] Wrong java type used in generated config from DB schema
> ---------------------------------------------------------------------
>
>                 Key: IGNITE-6671
>                 URL: https://issues.apache.org/jira/browse/IGNITE-6671
>             Project: Ignite
>          Issue Type: Bug
>      Security Level: Public(Viewable by anyone) 
>    Affects Versions: 2.2
>            Reporter: Dmitry Karachentsev
>            Assignee: Pavel Konstantinov
>             Fix For: 2.4
>
>
> We should be confident that java types in generated config are able to fit in values
from DB. For example, WC generates short for Oracle's NUMBER(5), when short could be max 32767,
but NUMBER(5) - 99999.
> That may produce errors like below during DB import:
> {noformat}
>  Exception in thread "main" javax.cache.integration.CacheLoaderException: Failed to load
cache: test
>        at org.apache.ignite.cache.store.jdbc.CacheAbstractJdbcStore.loadCache(CacheAbstractJdbcStore.java:798)
>        at org.apache.ignite.internal.processors.cache.store.GridCacheStoreManagerAdapter.loadCache(GridCacheStoreManagerAdapter.java:502)
>        at org.apache.ignite.internal.processors.cache.distributed.dht.GridDhtCacheAdapter.localLoadCache(GridDhtCacheAdapter.java:486)
>        at org.apache.ignite.internal.processors.cache.GridCacheProxyImpl.localLoadCache(GridCacheProxyImpl.java:217)
>        at org.apache.ignite.internal.processors.cache.GridCacheAdapter$LoadCacheJob.localExecute(GridCacheAdapter.java:5439)
>        at org.apache.ignite.internal.processors.cache.GridCacheAdapter$LoadCacheJobV2.localExecute(GridCacheAdapter.java:5488)
>        at org.apache.ignite.internal.processors.cache.GridCacheAdapter$TopologyVersionAwareJob.execute(GridCacheAdapter.java:6103)
>        at org.apache.ignite.compute.ComputeJobAdapter.call(ComputeJobAdapter.java:132)
>        at org.apache.ignite.internal.processors.closure.GridClosureProcessor$C2.execute(GridClosureProcessor.java:1842)
>        at org.apache.ignite.internal.processors.job.GridJobWorker$2.call(GridJobWorker.java:566)
>        at org.apache.ignite.internal.util.IgniteUtils.wrapThreadLoader(IgniteUtils.java:6621)
>        at org.apache.ignite.internal.processors.job.GridJobWorker.execute0(GridJobWorker.java:560)
>        at org.apache.ignite.internal.processors.job.GridJobWorker.body(GridJobWorker.java:489)
>        at org.apache.ignite.internal.util.worker.GridWorker.run(GridWorker.java:110)
>        at org.apache.ignite.internal.processors.job.GridJobProcessor.processJobExecuteRequest(GridJobProcessor.java:1114)
>        at org.apache.ignite.internal.processors.job.GridJobProcessor$JobExecutionListener.onMessage(GridJobProcessor.java:1907)
>        at org.apache.ignite.internal.managers.communication.GridIoManager.invokeListener(GridIoManager.java:1257)
>        at org.apache.ignite.internal.managers.communication.GridIoManager.processRegularMessage0(GridIoManager.java:885)
>        at org.apache.ignite.internal.managers.communication.GridIoManager.access$2100(GridIoManager.java:114)
>        at org.apache.ignite.internal.managers.communication.GridIoManager$7.run(GridIoManager.java:802)
>        at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)
>        at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)
>        at java.lang.Thread.run(Thread.java:745)
> Caused by: javax.cache.CacheException: Failed to read binary object: org.apache.TestModel
>        at org.apache.ignite.cache.store.jdbc.CacheJdbcPojoStore.buildBinaryObject(CacheJdbcPojoStore.java:255)
>        at org.apache.ignite.cache.store.jdbc.CacheJdbcPojoStore.buildObject(CacheJdbcPojoStore.java:136)
>        at org.apache.ignite.cache.store.jdbc.CacheAbstractJdbcStore$1.call(CacheAbstractJdbcStore.java:463)
>        at org.apache.ignite.cache.store.jdbc.CacheAbstractJdbcStore$1.call(CacheAbstractJdbcStore.java:430)
>        at java.util.concurrent.FutureTask.run(FutureTask.java:266)
>        ... 3 more
> Caused by: java.sql.SQLException: Numeric Overflow
>        at oracle.jdbc.driver.NumberCommonAccessor.throwOverflow(NumberCommonAccessor.java:4170)
>        at oracle.jdbc.driver.NumberCommonAccessor.getShort(NumberCommonAccessor.java:311)
>        at oracle.jdbc.driver.GeneratedStatement.getShort(GeneratedStatement.java:305)
>        at oracle.jdbc.driver.GeneratedScrollableResultSet.getShort(GeneratedScrollableResultSet.java:879)
>        at org.apache.ignite.cache.store.jdbc.JdbcTypesDefaultTransformer.getColumnValue(JdbcTypesDefaultTransformer.java:84)
>        at org.apache.ignite.cache.store.jdbc.CacheJdbcPojoStore.buildBinaryObject(CacheJdbcPojoStore.java:247)
>        ... 7 more
> {noformat}
> *This should be checked for all supported databases.*



--
This message was sent by Atlassian JIRA
(v6.4.14#64029)

Mime
View raw message