You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
When executing a query with matrix items, if non key-column quals are used which filter the matrix item list, they must be included in the cache key
#402
Closed
kaidaguerre opened this issue
Sep 2, 2022
· 0 comments
· Fixed by #403
interesting edge case bug in the way matrix (multi-region) queries work.
When a query is executed with matrix is defined (e.g. a list of regions), there is optimisation code which removes items from the list if they are excluded by the quals (even if no key column is defined).
This is the reason select * from aws_ec2_transit_gateway
returns an error but select * from aws_ec2_transit_gateway where region = 'us-east-1'
does not. In this case only'us-east-1 is executed, even though the plugin itself does not do explicit filtering using region
When caching however, only key column quals are used when building the cache key. So when running select * from aws_ec2_transit_gateway where region = 'us-east-1'
the result gets cached without region being in the cache key. This means when we later run select * from aws_ec2_transit_gateway where region = 'me-central-1'
we get a cache hit.
A worse symptom of this bug is if we first query a region with no result, then a region with results. In this case, the second query would incorrectly return no results:
> select * from aws_ec2_transit_gateway where region = 'us-east-1'
+--------------------+---------------------+-------+----------+-------------+---------------+-----------------+------------------------------------+--------------------------------+---------------------------------+---------------------------------+-------------+-------------------+------------------------------------+------------------+-------------+----------+------+-------+------+-----------+--------+-----
| transit_gateway_id | transit_gateway_arn | state | owner_id | description | creation_time | amazon_side_asn | association_default_route_table_id | auto_accept_shared_attachments | default_route_table_association | default_route_table_propagation | dns_support | multicast_support | propagation_default_route_table_id | vpn_ecmp_support | cidr_blocks | tags_src | tags | title | akas | partition | region | acco
+--------------------+---------------------+-------+----------+-------------+---------------+-----------------+------------------------------------+--------------------------------+---------------------------------+---------------------------------+-------------+-------------------+------------------------------------+------------------+-------------+----------+------+-------+------+-----------+--------+-----
+--------------------+---------------------+-------+----------+-------------+---------------+-----------------+------------------------------------+--------------------------------+---------------------------------+---------------------------------+-------------+-------------------+------------------------------------+------------------+-------------+----------+------+-------+------+-----------+--------+-----
Time: 1.0s.
> select * from aws_ec2_transit_gateway where region = 'us-east-2'
+--------------------+---------------------+-------+----------+-------------+---------------+-----------------+------------------------------------+--------------------------------+---------------------------------+---------------------------------+-------------+-------------------+------------------------------------+------------------+-------------+----------+------+-------+------+-----------+--------+-----
| transit_gateway_id | transit_gateway_arn | state | owner_id | description | creation_time | amazon_side_asn | association_default_route_table_id | auto_accept_shared_attachments | default_route_table_association | default_route_table_propagation | dns_support | multicast_support | propagation_default_route_table_id | vpn_ecmp_support | cidr_blocks | tags_src | tags | title | akas | partition | region | acco
+--------------------+---------------------+-------+----------+-------------+---------------+-----------------+------------------------------------+--------------------------------+---------------------------------+---------------------------------+-------------+-------------------+------------------------------------+------------------+-------------+----------+------+-------+------+-----------+--------+-----
+--------------------+---------------------+-------+----------+-------------+---------------+-----------------+------------------------------------+--------------------------------+---------------------------------+---------------------------------+-------------+-------------------+------------------------------------+------------------+-------------+----------+------+-------+------+-----------+--------+-----
in this case - us-east-2 does have results, as seen by clearing the cache:
interesting edge case bug in the way matrix (multi-region) queries work.
When a query is executed with matrix is defined (e.g. a list of regions), there is optimisation code which removes items from the list if they are excluded by the quals (even if no key column is defined).
This is the reason
select * from aws_ec2_transit_gateway
returns an error but
select * from aws_ec2_transit_gateway where region = 'us-east-1'
does not. In this case only
'us-east-1
is executed, even though the plugin itself does not do explicit filtering usingregion
When caching however, only key column quals are used when building the cache key. So when running
select * from aws_ec2_transit_gateway where region = 'us-east-1'
the result gets cached without region being in the cache key. This means when we later run
select * from aws_ec2_transit_gateway where region = 'me-central-1'
we get a cache hit.
A worse symptom of this bug is if we first query a region with no result, then a region with results. In this case, the second query would incorrectly return no results:
in this case - us-east-2 does have results, as seen by clearing the cache:
fix for this is that if any non keycolumn qual is used to filter the matrix items, it will be included in the cache key.
The text was updated successfully, but these errors were encountered: