[MCOL-1347] ALTER TABLE ADD COLUMN creates a column with incorrect width for a varchar columns. Created: 2018-04-18  Updated: 2019-03-06  Resolved: 2018-12-19

Status: Closed
Project: MariaDB ColumnStore
Component/s: PrimProc
Affects Version/s: 1.1.6, 1.2.2
Fix Version/s: 1.1.7

Type: Bug Priority: Minor
Reporter: Roman Assignee: Daniel Lee (Inactive)
Resolution: Fixed Votes: 0
Labels: None

Issue Links:
Relates
relates to MCOL-1675 Incorrect HWM calculation if the tabl... Closed
Sprint: 2018-21

 Description   

There is a table used for ETL purposes, that is recreated on regular basis.
Whilst processing select * from table limit 0,100, there was a failure:

Apr 12 10:12:12 dbusa ExeMgr[74153]: 12.510096 |1855|0|0| D 16 CAL0041: Start SQL statement: select * from dbusa.table limit 0, 1000; |dbusa|
Apr 12 10:12:16 dbusa PrimProc[74097]: 16.789519 |0|0|0| I 28 CAL0061: PrimProc error reading file for OID 8242; retry updateptrs for /usr/local/mariadb/columnstore/data1/000.dir/000.dir/032.dir/050.dir/000.dir/FILE000.cdf. rc=0, idx=4, ptr.size=4
Apr 12 10:12:16 dbusa PrimProc[74097]: 16.793821 |0|0|0| C 28 CAL0000: Invalid Range from HWM for lbid 13379328, range size should be <= blocksReadAhead: HWM 2047, dbroot 1, highfbo 3071, lowfbo 2560, blocksReadAhead 512, range size -512
Apr 12 10:12:16 dbusa ExeMgr[74153]: 16.802872 |1855|0|0| D 16 CAL0042: End SQL statement

The problem presumably caused by a block saved by versioning but is absent in dbroot involved.



 Comments   
Comment by Roman [ 2018-12-06 ]

To reproduce it first run the DDL statements:

create table cs1(i bigint) engine=columnstore;
alter table cs1 add column v1 varchar(1);

After that one must insert > 8kk rows into the table. I have simple generator for the purpose so feel free to ask for it.
After the preparations call
SELECT * FROM cs1 LIMIT 0, 1000;
and check logs.

There is a shortcut. Instead of populating the table with values just run:
select c.object_id,c.column_name,e.width from information_schema.columnstore_extents e, information_schema.columnstore_columns c where e.object_id = c.object_id and c.column_name = 'v1';

The width returned for the column must be 4 instead of 2 that is the correct value.

Comment by Roman [ 2018-12-06 ]

Please review.

Comment by Andrew Hutchings (Inactive) [ 2018-12-10 ]

The fix doesn't appear to work in all cases, more information in the PR

Comment by Andrew Hutchings (Inactive) [ 2018-12-10 ]

Also can you please provide a test case in the regression suite?

Comment by Roman [ 2018-12-10 ]

Please review the change.

Comment by Daniel Lee (Inactive) [ 2018-12-19 ]

Build verified: 1.1.7-1 nightly

MariaDB [mytest]> alter table cs1 add column v1 varchar(1);
Query OK, 0 rows affected (0.12 sec)
Records: 0 Duplicates: 0 Warnings: 0

MariaDB [mytest]> select c.object_id,c.column_name,e.width from information_schema.columnstore_extents e, information_schema.columnstore_columns c where e.object_id = c.object_id and c.column_name = 'v1';
---------------------------

object_id column_name width

---------------------------

3060 v1 2

---------------------------
1 row in set (0.37 sec)

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