Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
ghost opened this issue Jun 13, 2022 · 1 comment
Assignees
Labels
bug Something isn't working

Comments

@ghost
Copy link

ghost commented Jun 13, 2022

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 ghost added the bug Something isn't working label Jun 13, 2022
@kaidaguerre
Copy link
Contributor

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

@kaidaguerre kaidaguerre transferred this issue from turbot/steampipe Jul 6, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

1 participant