← Back to team overview

maria-developers team mailing list archive

Re: 503e494ec6e: MDEV-16241 Assertion `inited==RND' failed in handler::ha_rnd_end()

 

Hi, Aleksey!

On Nov 06, Aleksey Midenkov wrote:
> revision-id: 503e494ec6e103b23dc55f8fc8ae68ecec8b8316 (versioning-1.0.6-1-g503e494ec6e)
> parent(s): 6120ae4acafb23badecc623e33797949e3f6fbbb
> author: Aleksey Midenkov <midenok@xxxxxxxxx>
> committer: Aleksey Midenkov <midenok@xxxxxxxxx>
> timestamp: 2018-10-22 11:50:10 +0300
> message:
> 
> MDEV-16241 Assertion `inited==RND' failed in handler::ha_rnd_end()
> 
> Discrepancy in open indexes due to overwritten `read_partitions` upon
> `ha_open()` in `ha_partition::clone()`.
> 
> [Fixes tempesta-tech/mariadb#551]
> 
> diff --git a/mysql-test/main/partition_innodb.result b/mysql-test/main/partition_innodb.result
> index d27abc07984..c63cbc4601d 100644
> --- a/mysql-test/main/partition_innodb.result
> +++ b/mysql-test/main/partition_innodb.result
> @@ -925,3 +925,14 @@ test_jfg	test_jfg11
>  test_jfg	test_jfg12#P#p1000
>  test_jfg	test_jfg12#P#pmax
>  DROP DATABASE test_jfg;
> +#
> +# MDEV-16241 Assertion `inited==RND' failed in handler::ha_rnd_end()
> +#
> +CREATE TABLE t1 (pk INT PRIMARY KEY, x INT, y INT, z INT, KEY (x), KEY (y, z))
> +WITH SYSTEM VERSIONING
> +PARTITION BY SYSTEM_TIME (PARTITION p1 HISTORY, PARTITION pn CURRENT);
> +INSERT INTO t1 VALUES (1, 7, 8, 9), (2, NULL, NULL, NULL), (3, NULL, NULL, NULL);
> +SELECT COUNT(*) FROM t1 WHERE x IS NULL AND y IS NULL AND z IS NULL;
> +COUNT(*)
> +2
> +DROP TABLE t1;

please, add a non-system-versioning test too. It's in one of the
comments in the bug report.

> diff --git a/sql/ha_partition.cc b/sql/ha_partition.cc
> index 40380ffeec5..901f812a0e6 100644
> --- a/sql/ha_partition.cc
> +++ b/sql/ha_partition.cc
> @@ -3725,6 +3725,9 @@ void ha_partition::rebind_psi()
>  handler *ha_partition::clone(const char *name, MEM_ROOT *mem_root)
>  {
>    ha_partition *new_handler;
> +  MY_BITMAP read_partitions;
> +  MY_BITMAP lock_partitions;
> +  int error;
>  
>    DBUG_ENTER("ha_partition::clone");
>    new_handler= new (mem_root) ha_partition(ht, table_share, m_part_info,
> @@ -3748,9 +3751,21 @@ handler *ha_partition::clone(const char *name, MEM_ROOT *mem_root)
>                                                ALIGN_SIZE(m_ref_length)*2)))
>      goto err;
>  
> -  if (new_handler->ha_open(table, name,
> +  DBUG_ASSERT(m_tot_parts == m_part_info->read_partitions.n_bits);
> +  DBUG_ASSERT(m_tot_parts == m_part_info->lock_partitions.n_bits);
> +  my_bitmap_init(&read_partitions, NULL, m_tot_parts, FALSE);
> +  my_bitmap_init(&lock_partitions, NULL, m_tot_parts, FALSE);
> +  bitmap_copy(&read_partitions, &m_part_info->read_partitions);
> +  bitmap_copy(&lock_partitions, &m_part_info->lock_partitions);
> +  error= new_handler->ha_open(table, name,
>                             table->db_stat,
> -                           HA_OPEN_IGNORE_IF_LOCKED | HA_OPEN_NO_PSI_CALL))
> +                           HA_OPEN_IGNORE_IF_LOCKED | HA_OPEN_NO_PSI_CALL);
> +  bitmap_copy(&m_part_info->read_partitions, &read_partitions);
> +  bitmap_copy(&m_part_info->lock_partitions, &lock_partitions);
> +  my_bitmap_free(&read_partitions);
> +  my_bitmap_free(&lock_partitions);
> +
> +  if (error)

I don't think this is needed. ha_partition::open() is aware of clones,
it has `if (m_is_clone_of)` to do some stuff only for clones and some
only for fresh opens. Perhaps you just need to move the bitmap-resetting
code to be done only for fresh opens?

Regards,
Sergei
Chief Architect MariaDB
and security@xxxxxxxxxxx