[
https://issues.apache.org/jira/browse/IGNITE-23170?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel
]
Evgeny Stanilovsky updated IGNITE-23170:
----------------------------------------
Fix Version/s: 3.2
(was: 3.1)
> SQL returns huge decimal values with trailing zeros
> ---------------------------------------------------
>
> Key: IGNITE-23170
> URL: https://issues.apache.org/jira/browse/IGNITE-23170
> Project: Ignite
> Issue Type: Bug
> Components: sql
> Reporter: Pavel Tupitsyn
> Priority: Major
> Labels: ignite-3
> Fix For: 3.2
>
>
> Add the following code to *ItSqlApiBaseTest*
> {code:java}
> @Test
> public void testDecimalDivisionTimeout() {
> IgniteSql igniteSql = igniteSql();
> igniteSql.execute(null, "CREATE TABLE testDecimalDivisionTimeout (ID
> INT PRIMARY KEY, VAL0 INT)").close();
> for (int i = 0; i < 10; i++) {
> igniteSql.execute(null, "INSERT INTO testDecimalDivisionTimeout
> VALUES (?, ?)", i, i * 100).close();
> }
> ResultSet<SqlRow> cursor = igniteSql.execute(null,
> "SELECT cast(VAl0 as decimal(300)) / ? FROM
> testDecimalDivisionTimeout", new BigDecimal(200));
> while (cursor.hasNext()) {
> cursor.next();
> }
> }
> {code}
> Warnings in the log:
> {code}
> org.apache.ignite.lang.IgniteException: A critical thread is blocked for 1758
> ms that is more than the allowed 500 ms, it is "iscsat_n_0-client-12" prio=10
> Id=121 RUNNABLE
> at
> [email protected]/java.math.MutableBigInteger.divideOneWord(MutableBigInteger.java:1131)
> at
> [email protected]/java.math.MutableBigInteger.divideKnuth(MutableBigInteger.java:1203)
> at
> [email protected]/java.math.MutableBigInteger.divideKnuth(MutableBigInteger.java:1163)
> at
> [email protected]/java.math.BigInteger.divideAndRemainderKnuth(BigInteger.java:2328)
> at
> [email protected]/java.math.BigInteger.divideAndRemainder(BigInteger.java:2316)
> at
> [email protected]/java.math.BigDecimal.createAndStripZerosToMatchScale(BigDecimal.java:4878)
> at
> [email protected]/java.math.BigDecimal.stripTrailingZeros(BigDecimal.java:3053)
> at
> app//org.apache.ignite.internal.binarytuple.BinaryTupleCommon.shrinkDecimal(BinaryTupleCommon.java:118)
> at
> app//org.apache.ignite.internal.binarytuple.BinaryTupleBuilder.appendDecimalNotNull(BinaryTupleBuilder.java:292)
> at
> app//org.apache.ignite.internal.binarytuple.BinaryTupleBuilder.appendDecimal(BinaryTupleBuilder.java:317)
> at
> app//org.apache.ignite.client.handler.requests.sql.ClientSqlCommon.packValue(ClientSqlCommon.java:96)
> at
> app//org.apache.ignite.client.handler.requests.sql.ClientSqlCommon.packCurrentPage(ClientSqlCommon.java:48)
> at
> app//org.apache.ignite.client.handler.requests.sql.ClientSqlExecuteRequest.writeResultSetAsync(ClientSqlExecuteRequest.java:135)
> at
> app//org.apache.ignite.client.handler.requests.sql.ClientSqlExecuteRequest.lambda$process$0(ClientSqlExecuteRequest.java:93)
> {code}
> This is caused by the fact that SQL returns a *BigDecimal* with ~32000
> trailing zeros:
> * *SqlRowHandler.toBinaryTuple* returns "0.5" without trailing zeros - all
> good
> * *Commons.readValue* sets the scale to 32767, creating trailing zeros,
> resulting value takes ~3KB
> * *ClientSqlCommon.packValue* calls *BinaryTupleBuilder.appendDecimal* which
> takes quite some time to strip those trailing zeros
> While IGNITE-18922 will get rid of intermediate conversion in client handler,
> we still return huge values from embedded API, allocating extra memory and
> potentially causing issue for the users.
--
This message was sent by Atlassian Jira
(v8.20.10#820010)