[MCOL-1070] tupleconstantstep assert when query executed as view Created: 2017-12-04  Updated: 2018-02-14  Resolved: 2018-02-02

Status: Closed
Project: MariaDB ColumnStore
Component/s: ExeMgr
Affects Version/s: 1.1.2
Fix Version/s: 1.1.3

Type: Bug Priority: Major
Reporter: Nicola Assignee: Daniel Lee (Inactive)
Resolution: Fixed Votes: 0
Labels: None
Environment:

Vmware


Sprint: 2018-01, 2018-02, 2018-03

 Description   

Hi all,
i've create a view, but when try to execute the view returns this error:

Dec 4 07:59:36 dwh-cstore01 ExeMgr[46371]: 36.123128 |216|0|0| D 16 CAL0041: Start SQL statement: select * from get_lista_anomalie_msg; |c6msg|
Dec 4 07:59:36 dwh-cstore01 Calpont[46371]: 36.177395 |0|0|0| E 00 CAL0000: /home/builder/mariadb-columnstore-server/mariadb-columnstore-engine/dbcon/joblist/tupleconstantstep.cpp@156: assertion 'j < oidsIn.size()' failed
Dec 4 08:01:51 dwh-cstore01 joblist[46371]: 51.932073 |216|0|0| D 05 CAL0059: JobListFactory makeJoblist error: IDB-2035: An internal error occurred. Check the error log file & contact support.
Dec 4 08:01:51 dwh-cstore01 ExeMgr[46371]: 51.932485 |216|0|0| D 16 CAL0042: End SQL statement



 Comments   
Comment by Andrew Hutchings (Inactive) [ 2017-12-04 ]

Hi,

Can you please provide us with the the view and the tables behind it so we can attempt to reproduce this?

Comment by Nicola [ 2017-12-04 ]

Hi,
sure.
This is the query:
select case when `p`.`prog_sistema_gioco_id` is null then 9 else `p`.`codice_conc` end AS `destinatario`,`p`.`numero_msg` AS `numero_msg`,`p`.`descrizione` AS `stato`,`p`.`codice` AS `stato_num`,case when `p`.`codice` = 8 then 0 else 1 end AS `view_dett` from (select count(distinct `mo`.`ID_MSG_APP`) AS `numero_msg`,`sg`.`PROG_SISTEMA_GIOCO_ID` AS `prog_sistema_gioco_id`,`sout`.`DESCRIZIONE` AS `descrizione`,`sout`.`CODICE` AS `codice`,`sg`.`CODICE_CONC` AS `codice_conc` from (`c6msg`.`vl_sistema_gioco` `sg` left join ((((`c6msg`.`vl_messaggio_in` `mi` join `c6msg`.`vl_stato_elaborazione` `se` on(`mi`.`PROG_STATO_ELABORAZIONE_ID` = `se`.`PROG_STATO_ELABORAZIONE_ID`)) join `c6msg`.`vl_tipo_msg` `tm` on(`mi`.`PROG_TIPO_MSG_ID` = `tm`.`PROG_TIPO_MSG_ID`)) join `c6msg`.`vl_messaggio_out` `mo` on(`mi`.`ID_MSG_APP` = `mo`.`ID_MSG_APP` and `mi`.`PROG_TIPO_MSG_ID` = `mo`.`PROG_TIPO_MSG_ID`)) join `c6msg`.`vl_stato_elaborazione` `sout` on(`mo`.`PROG_STATO_ELABORAZIONE_ID` = `sout`.`PROG_STATO_ELABORAZIONE_ID`)) on(`mi`.`PROG_SIST_GIOCO_DEST_ID` = `sg`.`PROG_SISTEMA_GIOCO_ID`)) where `mi`.`DATA_RICEZIONE` >= date_format(sysdate(),'%Y-%m-%d') and `mo`.`DATA_TRASMISSIONE` >= date_format(sysdate(),'%Y-%m-%d') and `mo`.`DATA_TRASMISSIONE` >= `mi`.`DATA_RICEZIONE` and `se`.`CODICE` = 6 and `sout`.`CODICE` in (8,11,15) and `tm`.`CODICE` not in ('500','501') and `tm`.`CODICE` not like '000%' and !exists(select 1 from `c6msg`.`vl_messaggio_out` `mo2` where `mo2`.`ID_MSG_APP` = `mo`.`ID_MSG_APP` and `mo2`.`PROG_TIPO_MSG_ID` = `mo`.`PROG_TIPO_MSG_ID` and `mo2`.`DATA_TRASMISSIONE` > `mo`.`DATA_TRASMISSIONE` and `mo2`.`PROG_STATO_ELABORAZIONE_ID` in (10,12,13)) group by `sg`.`PROG_SISTEMA_GIOCO_ID`,`sout`.`DESCRIZIONE`,`sout`.`CODICE`,`sg`.`CODICE_CONC` union all select count(distinct `mo`.`ID_MSG_APP`) AS `numero_msg`,`sg`.`PROG_SISTEMA_GIOCO_ID` AS `prog_sistema_gioco_id`,'SLA_INVIATO_SENZA_RISPOSTA' AS `descrizione`,`sout`.`CODICE` AS `codice`,`sg`.`CODICE_CONC` AS `codice_conc` from (((((`c6msg`.`vl_messaggio_in` `mi` join `c6msg`.`vl_tipo_msg` `tm` on(`mi`.`PROG_TIPO_MSG_ID` = `tm`.`PROG_TIPO_MSG_ID`)) join `c6msg`.`vl_stato_elaborazione` `se` on(`mi`.`PROG_STATO_ELABORAZIONE_ID` = `se`.`PROG_STATO_ELABORAZIONE_ID`)) join `c6msg`.`vl_messaggio_out` `mo` on(`mi`.`ID_MSG_APP` = `mo`.`ID_MSG_APP` and `mi`.`PROG_TIPO_MSG_ID` = `mo`.`PROG_TIPO_MSG_ID`)) join `c6msg`.`vl_stato_elaborazione` `sout` on(`mo`.`PROG_STATO_ELABORAZIONE_ID` = `sout`.`PROG_STATO_ELABORAZIONE_ID`)) join `c6msg`.`vl_sistema_gioco` `sg` on(`mi`.`PROG_SIST_GIOCO_DEST_ID` = `sg`.`PROG_SISTEMA_GIOCO_ID`)) where `mi`.`DATA_RICEZIONE` >= date_format(sysdate(),'%Y-%m-%d') and `mo`.`DATA_TRASMISSIONE` >= date_format(sysdate(),'%Y-%m-%d') and `mo`.`DATA_TRASMISSIONE` >= `mi`.`DATA_RICEZIONE` and `se`.`CODICE` = 6 and round(24 * (sysdate() - `mi`.`DATA_RICEZIONE`),0) >= 6 and `sout`.`CODICE` = 10 and `tm`.`CODICE` in ('210','101') and `mi`.`COD_MITT` = '0' and `mo`.`COD_MITT` = '0' and !exists(select 1 from `c6msg`.`vl_messaggio_in` `mi2` where `mi2`.`ID_MSG_APP` = `mo`.`ID_MSG_APP` and (`mi2`.`PROG_TIPO_MSG_ID` = `mo`.`PROG_TIPO_MSG_ID` or `mi2`.`PROG_TIPO_MSG_ID` = 40) and `mi2`.`DATA_RICEZIONE` >= `mo`.`DATA_TRASMISSIONE` and `mi2`.`PROG_STATO_ELABORAZIONE_ID` = 6 and `mi2`.`COD_MITT` = 'H') group by `sg`.`PROG_SISTEMA_GIOCO_ID`,`sg`.`CODICE_CONC`,`sout`.`CODICE`) `p` order by `p`.`codice`

The execution query has 0,6 second.
Thanks.
Regards.

Comment by Andrew Hutchings (Inactive) [ 2017-12-04 ]

Can you also please attach the underlying table schemas used in this query?

Comment by Nicola [ 2017-12-04 ]

– --------------------------------------------------------
– Host: dwh-cstore01.gamenet.psm
– Server version: 10.2.10-MariaDB-log - Columnstore 1.1.2-1
– Server OS: Linux
– HeidiSQL Version: 9.4.0.5188
– --------------------------------------------------------

/*!40101 SET @OLD_CHARACTER_SET_CLIENT=@@CHARACTER_SET_CLIENT */;
/*!40101 SET NAMES utf8 */;
/*!50503 SET NAMES utf8mb4 */;
/*!40014 SET @OLD_FOREIGN_KEY_CHECKS=@@FOREIGN_KEY_CHECKS, FOREIGN_KEY_CHECKS=0 */;
/*!40101 SET @OLD_SQL_MODE=@@SQL_MODE, SQL_MODE='NO_AUTO_VALUE_ON_ZERO' */;

– Dumping structure for table c6msg.vl_messaggio_in
CREATE TABLE IF NOT EXISTS `vl_messaggio_in` (
`PROG_MESSAGGIO_IN_ID` bigint(20) unsigned NOT NULL,
`PROG_TIPO_MSG_ID` int(10) unsigned DEFAULT NULL,
`PROG_STATO_ELABORAZIONE_ID` int(10) unsigned DEFAULT NULL,
`MESSAGGIO` text DEFAULT NULL,
`DATA_RICEZIONE` date DEFAULT NULL,
`IP_ADDRESS` varchar(15) DEFAULT NULL,
`ID_MSG_APP` varchar(15) DEFAULT NULL,
`MSG_OPER` text DEFAULT NULL,
`COD_MITT` varchar(1) DEFAULT NULL,
`PROG_SIST_GIOCO_DEST_ID` int(10) unsigned DEFAULT NULL,
`PROG_SIST_GIOCO_MITT_ID` int(10) unsigned DEFAULT NULL
) ENGINE=Columnstore DEFAULT CHARSET=utf8;

– Data exporting was unselected.
– Dumping structure for table c6msg.vl_messaggio_out
CREATE TABLE IF NOT EXISTS `vl_messaggio_out` (
`PROG_MESSAGGIO_OUT_ID` bigint(20) unsigned NOT NULL,
`PROG_TIPO_MSG_ID` int(10) unsigned DEFAULT NULL,
`PROG_STATO_ELABORAZIONE_ID` int(10) unsigned DEFAULT NULL,
`MESSAGGIO` text DEFAULT NULL,
`DATA_TRASMISSIONE` date DEFAULT NULL,
`ID_MSG_APP` varchar(15) DEFAULT NULL,
`MSG_OPER` text DEFAULT NULL,
`COD_MITT` varchar(1) DEFAULT NULL,
`CODEID` varchar(16) DEFAULT NULL,
`PROG_SISTEMA_GIOCO_ID` int(10) unsigned DEFAULT NULL
) ENGINE=Columnstore DEFAULT CHARSET=utf8;

– Data exporting was unselected.
– Dumping structure for table c6msg.vl_sistema_gioco
CREATE TABLE IF NOT EXISTS `vl_sistema_gioco` (
`PROG_SISTEMA_GIOCO_ID` tinyint(1) unsigned NOT NULL,
`CODICE_CONC` tinyint(1) unsigned NOT NULL,
`COD_SISTEMA_GIOCO_AAMS` bigint(20) NOT NULL,
`PROG_COMPONENTE_ID` int(10) NOT NULL,
`DESCRIZIONE` varchar(50) NOT NULL,
`INDIRIZZO_IP` varchar(50) NOT NULL,
`URL_HTTP` varchar(300) NOT NULL,
`CHIAVE_PUBBLICA` text DEFAULT NULL,
`INVIO_CONTESTUALE` tinyint(4) DEFAULT NULL,
`MANUTENZIONE` tinyint(4) NOT NULL
) ENGINE=Columnstore DEFAULT CHARSET=utf8;

– Data exporting was unselected.
– Dumping structure for table c6msg.vl_stato_elaborazione
CREATE TABLE IF NOT EXISTS `vl_stato_elaborazione` (
`PROG_STATO_ELABORAZIONE_ID` int(10) unsigned DEFAULT NULL,
`CODICE` tinyint(4) DEFAULT NULL,
`DESCRIZIONE` varchar(50) DEFAULT NULL
) ENGINE=Columnstore DEFAULT CHARSET=latin1;

– Data exporting was unselected.
– Dumping structure for table c6msg.vl_tipo_msg
CREATE TABLE IF NOT EXISTS `vl_tipo_msg` (
`PROG_TIPO_MSG_ID` smallint(5) unsigned NOT NULL,
`CODICE` varchar(3) DEFAULT NULL,
`DESCRIZIONE` varchar(300) DEFAULT NULL,
`PROG_TIPO_MSG_AAMS_ID` int(11) DEFAULT NULL,
`SG_BORN` varchar(1) DEFAULT NULL,
`SLA_RX` varchar(1) DEFAULT NULL,
`SLA_TX` varchar(1) DEFAULT NULL
) ENGINE=Columnstore DEFAULT CHARSET=utf8;

– Data exporting was unselected.
/*!40101 SET SQL_MODE=IFNULL(@OLD_SQL_MODE, '') */;
/*!40014 SET FOREIGN_KEY_CHECKS=IF(@OLD_FOREIGN_KEY_CHECKS IS NULL, 1, @OLD_FOREIGN_KEY_CHECKS) */;
/*!40101 SET CHARACTER_SET_CLIENT=@OLD_CHARACTER_SET_CLIENT */;

Comment by Andrew Hutchings (Inactive) [ 2017-12-04 ]

Confirmed when creating those tables and making that query a view the error occurs when executing the view. Executing the query without the view works fine.

Comment by Nicola [ 2017-12-05 ]

How long will it take to solve the problem? because I have this problem in the production environment.

Thanks.
Regards.
Nicola Battista

Comment by Andrew Hutchings (Inactive) [ 2017-12-07 ]

Hi Nicola,

I have added it to our next 1.1 release cycle (1.1.3) which we are expecting to release in January. I'm not sure of a workaround yet apart from not using views. But I do know that it is the very outer part of the query which is triggering it.

Comment by Andrew Hutchings (Inactive) [ 2018-02-02 ]

Bug was due to ExeMgr not passing the view name properly during correlated exists filter on subquery processing causing a duplicate subquery which was later caught causing a failure. Fix was to make sure the view name from the exists filter is used every time.

For QA: Use the table schemas in the comments, create a view as the select query in the comments and then select * from the view. It will error before the patch, return no results after.

Comment by Daniel Lee (Inactive) [ 2018-02-02 ]

Build verified: Github source
root@stretch:~# cat mariadb-columnstore-1.1.3-1-stretch.x86_64.bin.tar.txt
/root/columnstore/mariadb-columnstore-server
commit e5499e513d88a3dfefbe9a356e20a1bceb1bde38
Merge: 99cdb0a4b5 4840a435aa
Author: david hill <david.hill@mariadb.com>
Date: Wed Jan 31 16:53:52 2018 -0600
Merge pull request #92 from mariadb-corporation/MCOL-1152
MCOL-1152: Change the debian package names.
/root/columnstore/mariadb-columnstore-server/mariadb-columnstore-engine
commit 446cf74a68eaaa8697a448d8de0327e0459d4341
Merge: c792188a 6f4cfcdc
Author: David.Hall <david.hall@mariadb.com>
Date: Fri Feb 2 13:09:51 2018 -0600
Merge pull request #392 from mariadb-corporation/MCOL-1070
MCOL-1070 Fix exists in view subquery

Verified original test case

Generated at Thu Feb 08 02:25:57 UTC 2024 using Jira 8.20.16#820016-sha1:9d11dbea5f4be3d4cc21f03a88dd11d8c8687422.