steampipe-postgres-fdw icon indicating copy to clipboard operation
steampipe-postgres-fdw copied to clipboard

Whe run a JOIN query the database sends Segment Violation and stops responding.

Open ghost opened this issue 3 years ago • 2 comments

Describe the bug I was listing the interfaces on my AWS instance, I compose a query that joins aws_ec2_network_interface, aws_ec2_instance,aws_vpc_subnet. when i run the following query in a simple manner the database returns the results OK:

SELECT inet.network_interface_id, subnet.cidr_block AS "subnet_cidr", inet.private_ip_address, inet.interface_type, inet.attached_instance_id, inet.description, inet.status, subnet.title AS "subnet", inst.title AS "instance" FROM aws_ec2_network_interface AS inet LEFT JOIN aws_ec2_instance AS inst ON inet.attached_instance_id = inst.instance_id JOIN aws_vpc_subnet AS subnet ON inet.private_ip_address <<= subnet.cidr_block

Then i add a ORDER BY clause for the second field:

SELECT inet.network_interface_id, subnet.cidr_block AS "subnet_cidr", inet.private_ip_address, inet.interface_type, inet.attached_instance_id, inet.description, inet.status, subnet.title AS "subnet", inst.title AS "instance" FROM aws_ec2_network_interface AS inet LEFT JOIN aws_ec2_instance AS inst ON inet.attached_instance_id = inst.instance_id JOIN aws_vpc_subnet AS subnet ON inet.private_ip_address <<= subnet.cidr_block ORDER BY 2;

The psql client sends a message:

the server has closed the connection unexpectedly It's probably because the server terminated abnormallybefore or during the processing of the request.

Tailing the log i found the following message:

2022/06/13 13:34:17 [INFO] Log level WARN 2022-06-13 18:34:48.157 UTC [8339] LOG: server process (PID 8994) was terminated by signal 11: Segment violation 2022-06-13 18:34:48.157 UTC [8339] LOG: terminating any other active server processes 2022-06-13 18:34:48.158 UTC [9020] LOG: connection received: host=::1 port=40364 2022-06-13 18:34:48.158 UTC [9020] FATAL: the database system is in recovery mode 2022-06-13 18:34:48.158 UTC [8339] LOG: all server processes terminated; reinitializing 2022-06-13 18:34:48.180 UTC [9021] LOG: database system was interrupted; last known up at 2022-06-13 18:33:56 UTC 2022-06-13 18:34:48.181 UTC [9021] LOG: database system was not properly shut down; automatic recovery in progress 2022-06-13 18:34:48.181 UTC [9021] LOG: redo starts at 0/157ABB8 2022-06-13 18:34:48.181 UTC [9021] LOG: invalid record length at 0/157ABF0: wanted 24, got 0 2022-06-13 18:34:48.181 UTC [9021] LOG: redo done at 0/157ABB8 system usage: CPU: user: 0.00 s, system: 0.00 s, elapsed: 0.00 s 2022-06-13 18:34:48.183 UTC [8339] LOG: database system is ready to accept connections

But only happens when i try to order by "cidr_block" field. With another one it doesn't happen.

Steampipe version (steampipe -v) 0.14.6

To reproduce Run the following query: SELECT inet.network_interface_id, subnet.cidr_block AS "subnet_cidr", inet.private_ip_address, inet.interface_type, inet.attached_instance_id, inet.description, inet.status, subnet.title AS "subnet", inst.title AS "instance" FROM aws_ec2_network_interface AS inet LEFT JOIN aws_ec2_instance AS inst ON inet.attached_instance_id = inst.instance_id JOIN aws_vpc_subnet AS subnet ON inet.private_ip_address <<= subnet.cidr_block ORDER BY 2;

Expected behavior Return the information expected by the query ordered by cidr block.

Additional context The environment are a Ubuntu 18.04 machine with kernel 4.15.0-184-generic. The test was running on psql client, VSCode PostgreSQL tools, and pgadmin4, with the same behavior.

ghost avatar Jun 13 '22 18:06 ghost

thanks for the report @luisortiz-grit, I'll dig into it

kaidaguerre avatar Jun 14 '22 10:06 kaidaguerre