[MDEV-24238] [ERROR] mysqld got exception 0xc0000005 Created: 2020-11-18  Updated: 2021-05-27  Resolved: 2021-02-15

Status: Closed
Project: MariaDB Server
Component/s: Optimizer, Storage Engine - InnoDB
Affects Version/s: 10.3.26
Fix Version/s: N/A

Type: Bug Priority: Critical
Reporter: Dedy Assignee: Unassigned
Resolution: Incomplete Votes: 0
Labels: need_feedback

Issue Links:
Duplicate
duplicates MDEV-25787 Bug report: crash on SELECT DISTINCT ... Closed

 Description   

2020-11-18  8:17:40 0 [Note] InnoDB: Mutexes and rw_locks use Windows interlocked functions
2020-11-18  8:17:40 0 [Note] InnoDB: Uses event mutexes
2020-11-18  8:17:40 0 [Note] InnoDB: Compressed tables use zlib 1.2.11
2020-11-18  8:17:40 0 [Note] InnoDB: Number of pools: 1
2020-11-18  8:17:40 0 [Note] InnoDB: Using SSE2 crc32 instructions
2020-11-18  8:17:40 0 [Note] InnoDB: Initializing buffer pool, total size = 2G, instances = 8, chunk size = 128M
2020-11-18  8:17:40 0 [Note] InnoDB: Completed initialization of buffer pool
2020-11-18  8:17:41 0 [Note] InnoDB: 128 out of 128 rollback segments are active.
2020-11-18  8:17:41 0 [Note] InnoDB: Creating shared tablespace for temporary tables
2020-11-18  8:17:41 0 [Note] InnoDB: Setting file '.\ibtmp1' size to 12 MB. Physically writing the file full; Please wait ...
2020-11-18  8:17:41 0 [Note] InnoDB: File '.\ibtmp1' size is now 12 MB.
2020-11-18  8:17:41 0 [Note] InnoDB: Waiting for purge to start
2020-11-18  8:17:41 0 [Note] InnoDB: 10.3.26 started; log sequence number 238147676; transaction id 240981
2020-11-18  8:17:41 0 [Note] InnoDB: Loading buffer pool(s) from D:\ProgramFiles\MariaDB\data\ib_buffer_pool
2020-11-18  8:17:41 0 [Note] Plugin 'FEEDBACK' is disabled.
2020-11-18  8:17:41 0 [Note] Server socket created on IP: '::'.
2020-11-18  8:17:41 0 [Note] Reading of all Master_info entries succeeded
2020-11-18  8:17:41 0 [Note] Added new Master_info '' to hash table
2020-11-18  8:17:41 0 [Note] D:\ProgramFiles\MariaDB\bin\mysqld.exe: ready for connections.
Version: '10.3.26-MariaDB'  socket: ''  port: 3308  mariadb.org binary distribution
2020-11-18  8:17:42 0 [Note] InnoDB: Buffer pool(s) load completed at 201118  8:17:42
201118  8:22:04 [ERROR] mysqld got exception 0xc0000005 ;
This could be because you hit a bug. It is also possible that this binary
or one of the libraries it was linked against is corrupt, improperly built,
or misconfigured. This error can also be caused by malfunctioning hardware.
 
To report this bug, see https://mariadb.com/kb/en/reporting-bugs
 
We will try our best to scrape up some info that will hopefully help
diagnose the problem, but since we have already crashed, 
something is definitely wrong and this may fail.
 
Server version: 10.3.26-MariaDB
key_buffer_size=134217728
read_buffer_size=131072
max_used_connections=1
max_threads=65537
thread_count=7
It is possible that mysqld could use up to 
key_buffer_size + (read_buffer_size + sort_buffer_size)*max_threads = 136212 K  bytes of memory
Hope that's ok; if not, decrease some variables in the equation.
 
Thread pointer: 0x703ff328
Attempting backtrace. You can use the following information to find out
where mysqld died. If you see no messages after this, something went
terribly wrong...
mysqld.exe!ha_maria::extra()[ha_maria.cc:2514]
mysqld.exe!end_read_record()[records.cc:326]
mysqld.exe!st_join_table::cleanup()[sql_select.cc:12739]
mysqld.exe!JOIN::cleanup()[sql_select.cc:13109]
mysqld.exe!JOIN::join_free()[sql_select.cc:13016]
mysqld.exe!do_select()[sql_select.cc:19297]
mysqld.exe!JOIN::exec_inner()[sql_select.cc:4120]
mysqld.exe!JOIN::exec()[sql_select.cc:3915]
mysqld.exe!mysql_select()[sql_select.cc:4321]
mysqld.exe!handle_select()[sql_select.cc:370]
mysqld.exe!execute_sqlcom_select()[sql_parse.cc:6318]
mysqld.exe!mysql_execute_command()[sql_parse.cc:3847]
mysqld.exe!mysql_parse()[sql_parse.cc:7843]
mysqld.exe!dispatch_command()[sql_parse.cc:1855]
mysqld.exe!do_command()[sql_parse.cc:1398]
mysqld.exe!threadpool_process_request()[threadpool_common.cc:367]
mysqld.exe!tp_callback()[threadpool_common.cc:185]
ntdll.dll!TpReleaseWork()
ntdll.dll!TpDisassociateCallback()
kernel32.dll!BaseThreadInitThunk()
ntdll.dll!RtlUserThreadStart()
 
Trying to get some variables.
Some pointers may be invalid and cause the dump to abort.
Query (0x70657010): select distinct d.tgl,d.ref,a.customer,b.nama,a.sales,a.lokasi,a.faktur2,a.refso,
date(date_add(d.tgl, interval d.tempo day)) as tgltempo,
a.jnstransaksi,d.tempo as term, d.nilaifaktur,
sum(if(a.jnstransaksi=3,ifnull(a.bayar,0)+ifnull(a.bayar2,0)+ifnull(a.bayar3,0),0)) as bayar,
sum(a.piutang) as Saldo,
datediff('2020-10-31 00:00:00',d.tgl) as umur,datediff('2020-10-31 00:00:00',d.tgl)-d.tempo as larut,
a.ket,e.bayargiro,e.nogiro,
if(datediff('2020-10-31 00:00:00',a.tgl)-a.tempo<=-1,sum(a.piutang),0) as tbtjm,
if(datediff('2020-10-31 00:00:00',a.tgl)-a.tempo=0,sum(a.piutang),0) as t0,
if(datediff('2020-10-31 00:00:00',a.tgl)-a.tempo between 1 and 30 ,sum(a.piutang),0) as t1s30,
if(datediff('2020-10-31 00:00:00',a.tgl)-a.tempo between 31 and 60 ,sum(a.piutang),0) as t31s60,
if(datediff('2020-10-31 00:00:00',a.tgl)-a.tempo between 61 and 90 ,sum(a.piutang),0) as t61s90,
if(datediff('2020-10-31 00:00:00',a.tgl)-a.tempo between 91 and 120 ,sum(a.piutang),0) as t91s120,
if(datediff('2020-10-31 00:00:00',a.tgl)-a.tempo>=121 and 120,sum(a.piutang),0) as tl120
from penjualan a left join customer b on a.customer=b.kode 
left join (select faktur2,if(jnstransaksi=1,tgl,tglref) as tgl,tempo,lokasi,netto as nilaifaktur,ref 
from penjualan where jnstransaksi in (1,4)) d on d.faktur2=a.faktur2
left join (select distinct faktur2, group_concat(nobukti) as nogiro, sum(bayar) as bayargiro from penjualan a 
left join customer b on a.customer=b.kode
where jnstransaksi=3 and cekgiro=-1 and kosong=0 and (date(a.tgl)>date('2020.10.31')) and lokasi in (60)  group by faktur2) e on e.faktur2=a.faktur2 
where (date(a.tgl)<=date('2020.10.31')) and a.lokasi in (60)   and a.customer='000383'
group by a.faktur2
having saldo<>0 
order by a.customer, d.tgl
Connection ID (thread ID): 27
Status: NOT_KILLED



 Comments   
Comment by Daniel Black [ 2020-11-18 ]

Can you include the output from show create table penjualan;, show create table customer;, and explain $the_query to see which index is used.

Does check table $tablename; show errors in these tables. Does this query always crash MariaDB?

Comment by Dedy [ 2020-11-18 ]

CREATE TABLE `penjualan` (
`FAKTUR` varchar(50) NOT NULL DEFAULT '',
`FAKTUR2` varchar(50) NOT NULL DEFAULT '',
`JNSTRANSAKSI` tinyint(1) NOT NULL DEFAULT 0,
`NOREK` varchar(25) DEFAULT NULL,
`JNSLAIN` tinyint(1) NOT NULL DEFAULT 0,
`TAX` tinyint(1) NOT NULL DEFAULT 0,
`RESERVED` tinyint(1) NOT NULL DEFAULT 0,
`CEK` tinyint(1) NOT NULL DEFAULT 0,
`LEVEL` tinyint(1) NOT NULL DEFAULT 0,
`KOSONG` tinyint(1) NOT NULL DEFAULT 0,
`CEKGIRO` tinyint(1) NOT NULL DEFAULT 0,
`GUNGGUNG` tinyint(1) NOT NULL DEFAULT 0,
`FAKTURPAJAK` varchar(25) DEFAULT '',
`REF` varchar(30) DEFAULT '',
`REFSO` varchar(50) DEFAULT '',
`TGL` datetime DEFAULT NULL,
`TEMPO` smallint(6) DEFAULT NULL,
`TGLTERIMA` date DEFAULT NULL,
`TGLREF` date DEFAULT NULL,
`CUSTOMER` varchar(50) NOT NULL DEFAULT '',
`PENJUALAN` double DEFAULT 0,
`JASA` double DEFAULT 0,
`DISCPR` double DEFAULT 0,
`DISCNI` double NOT NULL DEFAULT 0,
`DISCFAKTUR` double NOT NULL DEFAULT 0,
`DISCPERSENS` varchar(50) NOT NULL DEFAULT '',
`PAJAK` double DEFAULT 0,
`PEMBULATAN` double DEFAULT 0,
`NETTO` double DEFAULT 0,
`LAIN` double DEFAULT 0,
`JNSBAYAR` tinyint(4) unsigned DEFAULT 0,
`BAYAR` double DEFAULT 0,
`CHARGE` double NOT NULL DEFAULT 0,
`JNSBAYAR2` tinyint(4) unsigned DEFAULT 0,
`BAYAR2` double NOT NULL DEFAULT 0,
`JNSBAYAR3` tinyint(4) unsigned DEFAULT 0,
`BAYAR3` double NOT NULL DEFAULT 0,
`KEMBALI` double NOT NULL DEFAULT 0,
`NOBUKTI` varchar(50) DEFAULT '',
`RETUR` varchar(50) DEFAULT '',
`PIUTANG` double DEFAULT 0,
`KASIR` varchar(16) NOT NULL DEFAULT current_user(),
`USEREDIT` varchar(16) DEFAULT NULL,
`POSTING` tinyint(1) DEFAULT 0,
`PRINTF` tinyint(1) DEFAULT 0,
`PRINTSJ` tinyint(1) DEFAULT 0,
`NOPOST` smallint(6) DEFAULT NULL,
`KET` varchar(250) DEFAULT NULL,
`INKLUSIF` tinyint(1) NOT NULL DEFAULT 0,
`LOKASI` smallint(6) NOT NULL DEFAULT 0,
`LOKASI2` smallint(6) DEFAULT NULL,
`SALES` smallint(6) DEFAULT NULL,
`TGLFAKTUR` date DEFAULT NULL,
`MASAPAJAK` tinyint(4) DEFAULT NULL,
`TAHUNPAJAK` smallint(6) DEFAULT NULL,
`CREATETIME` datetime DEFAULT current_timestamp(),
`UPDTIME` datetime DEFAULT NULL ON UPDATE current_timestamp(),
PRIMARY KEY (`FAKTUR`,`FAKTUR2`,`CUSTOMER`,`JNSTRANSAKSI`) USING BTREE,
UNIQUE KEY `FAKTUR1` (`FAKTUR`,`FAKTUR2`) USING BTREE,
KEY `FK_penjualan_customer` (`CUSTOMER`),
KEY `FK_penjualan_gudang` (`LOKASI`),
KEY `FK_penjualan_sales` (`SALES`),
KEY `FK_penjualan_pengguna` (`KASIR`) USING BTREE,
KEY `FK_penjualan_pengguna_2` (`USEREDIT`) USING BTREE,
KEY `FK_penjualan_jnsbayarjual` (`JNSBAYAR`),
KEY `FK_penjualan_jnsbayarjual_2` (`JNSBAYAR2`),
KEY `FK_penjualan_jnsbayarjual_3` (`JNSBAYAR3`),
KEY `FK_penjualan_gudang_2` (`LOKASI2`),
KEY `FK_penjualan_account` (`NOREK`),
KEY `FK_penjualan_jnsjual` (`JNSBAYAR`,`LOKASI`),
KEY `FK_penjualan_jnsjual2` (`JNSBAYAR2`,`LOKASI`),
KEY `FK_penjualan_jnsjual3` (`JNSBAYAR3`,`LOKASI`),
CONSTRAINT `FK_penjualan_account` FOREIGN KEY (`NOREK`) REFERENCES `account` (`NOREK`) ON UPDATE CASCADE,
CONSTRAINT `FK_penjualan_customer` FOREIGN KEY (`CUSTOMER`) REFERENCES `customer` (`KODE`) ON UPDATE CASCADE,
CONSTRAINT `FK_penjualan_gudang` FOREIGN KEY (`LOKASI`) REFERENCES `gudang` (`KODE`) ON UPDATE CASCADE,
CONSTRAINT `FK_penjualan_gudang_2` FOREIGN KEY (`LOKASI2`) REFERENCES `gudang` (`KODE`) ON UPDATE CASCADE,
CONSTRAINT `FK_penjualan_jnsjual` FOREIGN KEY (`JNSBAYAR`, `LOKASI`) REFERENCES `jnsbayarjual` (`KODE`, `LOKASI`) ON UPDATE CASCADE,
CONSTRAINT `FK_penjualan_jnsjual2` FOREIGN KEY (`JNSBAYAR2`, `LOKASI`) REFERENCES `jnsbayarjual` (`KODE`, `LOKASI`) ON UPDATE CASCADE,
CONSTRAINT `FK_penjualan_jnsjual3` FOREIGN KEY (`JNSBAYAR3`, `LOKASI`) REFERENCES `jnsbayarjual` (`KODE`, `LOKASI`) ON UPDATE CASCADE,
CONSTRAINT `FK_penjualan_sales` FOREIGN KEY (`SALES`) REFERENCES `sales` (`KODE`) ON UPDATE CASCADE
) ENGINE=InnoDB DEFAULT CHARSET=utf8

CREATE TABLE `customer` (
`KODE` varchar(50) NOT NULL DEFAULT '',
`NIK` varchar(20) NOT NULL DEFAULT '',
`NAMANIK` varchar(50) NOT NULL DEFAULT '',
`AKTIF` tinyint(1) NOT NULL DEFAULT -1,
`BLOKPLAFON` tinyint(1) NOT NULL DEFAULT -1,
`LVL` smallint(5) unsigned DEFAULT NULL,
`AREA` varchar(20) DEFAULT NULL,
`NAMA` varchar(100) DEFAULT '',
`ALAMAT` varchar(200) DEFAULT '',
`TELP` varchar(50) DEFAULT '',
`MOBILE` varchar(100) DEFAULT NULL,
`MOBILE2` varchar(100) DEFAULT NULL,
`FAX` varchar(50) DEFAULT '',
`CONTACT` varchar(100) DEFAULT '',
`TEMPOBAYAR` smallint(6) DEFAULT NULL,
`TEMPOTELAT` smallint(6) DEFAULT NULL,
`HARITT` varchar(15) CHARACTER SET latin1 DEFAULT '',
`HARITAGIH` varchar(15) CHARACTER SET latin1 DEFAULT '',
`AGAMA` varchar(10) DEFAULT NULL,
`TGLLAHIR` datetime DEFAULT NULL,
`JENISKELAMIN` varchar(6) DEFAULT NULL,
`EMAIL` varchar(100) DEFAULT '',
`PLAFONKREDIT` double NOT NULL DEFAULT 0,
`SALES` smallint(6) DEFAULT NULL,
`TGLDAFTAR` datetime DEFAULT NULL,
`PICTURE` longblob DEFAULT NULL,
`GPSMAP` varchar(50) DEFAULT NULL,
`EXPIREDATE` datetime DEFAULT NULL,
`NPWP` varchar(50) DEFAULT '',
`NAMAPKP` varchar(100) DEFAULT '',
`ALAMATPKP` varchar(150) DEFAULT '',
`UMUR` double DEFAULT 0,
`CREATETIME` datetime DEFAULT current_timestamp(),
`UNIONCODE` varchar(50) DEFAULT '',
`UPDTIME` datetime DEFAULT NULL ON UPDATE current_timestamp(),
PRIMARY KEY (`KODE`) USING BTREE,
KEY `FK_customer_area` (`AREA`),
CONSTRAINT `FK_customer_area` FOREIGN KEY (`AREA`) REFERENCES `area` (`KODE`) ON UPDATE CASCADE
) ENGINE=InnoDB DEFAULT CHARSET=utf8

//explain select
"id" "select_type" "table" "type" "possible_keys" "key" "key_len" "ref" "rows" "Extra"
"1" "PRIMARY" "b" "eq_ref" "PRIMARY" "PRIMARY" "152" "data.a.CUSTOMER" "1" ""
"1" "PRIMARY" "<derived3>" "ref" "key0" "key0" "153" "data.a.FAKTUR2" "10" ""
"3" "DERIVED" "a" "ref" "FK_penjualan_gudang" "FK_penjualan_gudang" "2" "const" "2902" "Using index condition; Using where; Using filesort"
"1" "PRIMARY" "a" "ref" "FK_penjualan_customer,FK_penjualan_gudang" "FK_penjualan_customer" "152" "const" "8" "Using index condition; Using where; Using temporary; Using filesort"
"1" "PRIMARY" "penjualan" "ALL" "5804" "Using where; Using join buffer (flat, BNL join)"

Comment by Dedy [ 2020-11-18 ]

Does this query always crash MariaDB? yes

check table penjualan
"Table" "Op" "Msg_type" "Msg_text"
"data.penjualan" "check" "status" "OK"

check table customer
"Table" "Op" "Msg_type" "Msg_text"
"data.customer" "check" "status" "OK"

Comment by Elena Stepanova [ 2021-01-11 ]

Is the data confidential? If not, or if you can obfuscate it, would you be able to provide a data sample which allows to reproduce the issue? So far I couldn't reproduce it with artificially generated data, but it's not very surprising, since there are numerous conditions in the query and they are very specific.
Please also paste or attach your cnf file(s).
Thanks

Generated at Thu Feb 08 09:28:28 UTC 2024 using Jira 8.20.16#820016-sha1:9d11dbea5f4be3d4cc21f03a88dd11d8c8687422.