[MCOL-4397] calgetshowpartitions fails if MDB started before MCS Created: 2020-11-18  Updated: 2021-02-01  Resolved: 2020-11-30

Status: Closed
Project: MariaDB ColumnStore
Component/s: MDB Plugin
Affects Version/s: 5.4.3
Fix Version/s: 6.1.1

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


 Description   

See working_tpch1_comparelogonly/misc/calshowpartitions.sql

If Server is running and columnstore is started, the calgetshowpartitions uses an out of date shared memory segment for extent map. It may get the wrong answer or will throw a generic error if the requested shm segment doesn't exist.
The fix is to refresh the shm pointers before running the function.



 Comments   
Comment by David Hall (Inactive) [ 2020-11-19 ]

QA: Start columnstore and do some stuff.
Run:

select calshowpartitionsbyvalue(schema(), 'dtypes', 'id', '-200', '101');
+--------------------------------------------------------------------------------------------------------------------------------------------------------------+
| calshowpartitionsbyvalue(schema(), 'dtypes', 'id', '-200', '101')                                                                                            |
+--------------------------------------------------------------------------------------------------------------------------------------------------------------+
| Part#     Min                           Max                           Status
  0.0.1                                  1                           100Enabled |
+--------------------------------------------------------------------------------------------------------------------------------------------------------------+

Restart columnstore while leaving MDB running:
systemctl stop mariadb-columnstore
systemctl start mariadb-columnstore

Now try
select calshowpartitionsbyvalue(schema(), 'dtypes', 'id', '-200', '101');

It may work. Probably not.
You will get either

ERROR 1815 (HY000): Internal error: IDB-2040: No partition found for the given value range.

OR

ERROR 1815 (HY000): Internal error: Error occured when calling CALSHOWPARTITIONS

Depending on how shared memory got mapped by the system that run.

Comment by Daniel Lee (Inactive) [ 2020-11-23 ]

Build tested: 5.4.3-1

Could not reproduce this issue using the scenario in the ticket, but reproduced as the following:

After truncating a table, select count is correctly return 0 rows, but calshowpartitionsbyvalue() returned stats before the truncate statement.
After restarting the engine, calshowpartitionsbyvalue() still returned the old stats.

MariaDB [mytest]> select calshowpartitionsbyvalue(schema(), 'lineitem', 'l_orderkey', '0', '60000000');
--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------

calshowpartitionsbyvalue(schema(), 'lineitem', 'l_orderkey', '0', '60000000')

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

Part# Min Max Status
0.0.1 1 35930438 Enabled
0.1.1 2376100 44325542 Enabled
0.2.1 10765025 52720294 Enabled
0.3.1 19156964 60000000 Enabled

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

MariaDB [mytest]> select count from lineitem;
----------

count

----------

59986052

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

MariaDB [mytest]> truncate lineitem;
Query OK, 0 rows affected (0.395 sec)

MariaDB [mytest]> select calshowpartitionsbyvalue(schema(), 'lineitem', 'l_orderkey', '0', '60000000');
--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------

calshowpartitionsbyvalue(schema(), 'lineitem', 'l_orderkey', '0', '60000000')

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

Part# Min Max Status
0.0.1 1 35930438 Enabled
0.1.1 2376100 44325542 Enabled
0.2.1 10765025 52720294 Enabled
0.3.1 19156964 60000000 Enabled

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

MariaDB [mytest]> select count from lineitem;
----------

count

----------

0

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

MariaDB [mytest]> select calshowpartitionsbyvalue(schema(), 'lineitem', 'l_orderkey', '0', '60000000');
--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------

calshowpartitionsbyvalue(schema(), 'lineitem', 'l_orderkey', '0', '60000000')

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

Part# Min Max Status
0.0.1 1 35930438 Enabled
0.1.1 2376100 44325542 Enabled
0.2.1 10765025 52720294 Enabled
0.3.1 19156964 60000000 Enabled

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

Comment by Daniel Lee (Inactive) [ 2020-11-23 ]

Builds tested: 5.5.1 (Drone 1151), 6.1.0 (Drone 1176)

The issue has been fixed.

MariaDB [mytest]> select calshowpartitionsbyvalue(schema(), 'lineitem', 'l_orderkey', '0', '60000000');
--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------

calshowpartitionsbyvalue(schema(), 'lineitem', 'l_orderkey', '0', '60000000')

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

Part# Min Max Status
0.0.1 1 41939616 Enabled
0.1.1 8380738 50335043 Enabled
0.2.1 16772356 58728385 Enabled
0.3.1 25159234 60000000 Enabled

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

MariaDB [mytest]> select count from lineitem;
----------

count

----------

59986052

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

MariaDB [mytest]> truncate lieneitem;
ERROR 1146 (42S02): Table 'mytest.lieneitem' doesn't exist
MariaDB [mytest]> truncate lineitem;
Query OK, 0 rows affected (0.399 sec)

MariaDB [mytest]> select calshowpartitionsbyvalue(schema(), 'lineitem', 'l_orderkey', '0', '60000000');
ERROR 1815 (HY000): Internal error: IDB-2040: No partition found for the given value range.
MariaDB [mytest]> select count from lineitem;
----------

count

----------

0

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

Comment by Daniel Lee (Inactive) [ 2020-11-30 ]

Closed per test result in my last comment.

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