dynamobi/dynamobi — Issue #448: [FNL-56] BTreeSearchExecStream assertion failure when applying index only scan
Author: dynamobi-build
Created: 2011-12-30 03:14:06+00:00
State: closed
Labels: FNL

[reporter="jpham", created="Tue, 24 Oct 2006 09:05:19 -0500 (GMT-05:00)"]
I may not have set up the streams for index only scan correctly. If not, then advice would be appreciated. I am hitting this assertion:

java: ../../fennel/exec/ExecStreamBufAccessor.h:671: void fennel::ExecStreamBufAccessor::consumeTuple(): Assertion `tupleConsumptionAccessor.getCurrentTupleBuf()' failed.

and the GDB backtrace is:

#0 0xffffe410 in __kernel_vsyscall ()

#1 0xb7e7d9a1 in raise () from /lib/tls/i686/cmov/libc.so.6

#2 0xb7e7f2b9 in abort () from /lib/tls/i686/cmov/libc.so.6

#3 0xb7e76f51 in __assert_fail () from /lib/tls/i686/cmov/libc.so.6

#4 0xb0c3a715 in fennel::ExecStreamBufAccessor::consumeTuple (this=0x8806548)

at ExecStreamBufAccessor.h:671

#5 0xb0c393f3 in fennel::BTreeSearchExecStream::execute (this=0x84d73c0,

quantum=@0xbfcad698) at BTreeSearchExecStream.cpp:173

The following SQL reproduces this (at least on my machine):

create schema s;

set schema 's';

create table SALES(

CUSTID integer

,EMPNO integer

,PRODID integer

,PRICE numeric(3,2)

);

create index SALES_PRICE on SALES(PRICE);

create index SALES_EMPNO on SALES(EMPNO);

create index SALES_PRODID on SALES(PRODID);

create index SALES_CUSTID on SALES(CUSTID);

create or replace server ff_server

foreign data wrapper sys_file_wrapper

options(

directory '/home/jpham/lcs/luciddb/test/data',

file_extension '.csv',

ctrl_file_extension '.bcp',

field_delimiter ',',

line_delimiter '\n',

quote_char '"',

escape_char '',

with_header 'yes',

num_rows_scan '9'

);

INSERT INTO SALES SELECT * FROM ff_server."BCP".SALES;

-- a few self-inserts

INSERT INTO SALES SELECT * FROM SALES;

INSERT INTO SALES SELECT * FROM SALES;

INSERT INTO SALES SELECT * FROM SALES;

INSERT INTO SALES SELECT * FROM SALES;

-- a deletion

delete from sales

where

mod(lcs_rid(custid), 2) = 0 or mod(lcs_rid(custid), 4) = 3

or (lcs_rid(custid) > 500 and lcs_rid(custid) < 5000);

select price, count(*) from s.sales group by price;

The last query generates the following plan (dotty file is attached):

FennelToIteratorConverter

FennelRenameRel(fieldNames=[[PRICE, EXPR$1]])

LcsIndexAggRel(groupCount=[1], agg#0=[COUNT()])

FennelRenameRel(fieldNames=[[$f0, SRID, SegmentDesc, Segment]])

LcsIndexOnlyScanRel(table=[[LOCALDB, S, SALES]], index=[SALES_PRICE]

I find that I can reach the error sequence as follows (+/- one iteration?):

(1) Setting a breakpoint in LbmMinusExecStream::execute, this breakpoint is hit 26 times

(2) Then setting a breakpoint in BTreeSearchExecStream::execute outer loop, this gets hit 5 times

On the last outer loop, BTreeSearchExecStream performs the inner search loop. The inner loop returns immediately, because pReader is positioned. However, at this point, pInAccessor's tuple buffer is null, so the following call to consumeTupleBuffer will fail.