Skip to content

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

Closed as not planned

Description

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.

Activity

  1. ghost added
    bug
    on Jun 13, 2022
  2. kaidaguerre commented on Jun 14, 2022

    @kaidaguerre
    Contributor

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

  3. github-actions commented on May 1, 2025

    @github-actions

    This issue is stale because it has been open 60 days with no activity. Remove stale label or comment or this will be closed in 30 days.

  4. added
    ext:needs-triage
    on Jun 10, 2025
  5. Priyanka-Chatterjee-2000 commented on Aug 14, 2025

    @Priyanka-Chatterjee-2000

    The connection does not crash now, it throws an error unexpected EOF:

    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;
    
    Error: unexpected EOF
    

    The steampipe logs:

    2025-08-14 07:02:10.793 UTC [WARN]  steampipe [1efe]: Error waiting for notification: unexpected EOF
    

    The database logs:

    2025/08/14 12:32:10 [INFO] Log level WARN
    2025-08-14 07:02:10.793 UTC [9500] LOG:  server process (PID 9536) was terminated by signal 11: Segmentation fault: 11
    2025-08-14 07:02:10.793 UTC [9500] DETAIL:  Failed process was running: 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;
    2025-08-14 07:02:10.793 UTC [9500] LOG:  terminating any other active server processes
    2025-08-14 07:02:10.794 UTC [9547] LOG:  connection received: host=127.0.0.1 port=63557
    2025-08-14 07:02:10.794 UTC [9547] LOG:  PID 9536 in cancel request did not match any process
    2025-08-14 07:02:10.794 UTC [9548] LOG:  connection received: host=127.0.0.1 port=63558
    2025-08-14 07:02:10.794 UTC [9548] LOG:  PID 9537 in cancel request did not match any process
    2025-08-14 07:02:10.795 UTC [9500] LOG:  all server processes terminated; reinitializing
    

    This issue is similar to #346

  6. removed
    ext:needs-triage
    on Aug 14, 2025
  7. github-actions commented on Oct 13, 2025

    @github-actions

    This issue is stale because it has been open 60 days with no activity. Remove stale label or comment or this will be closed in 30 days.

  8. github-actions commented on Nov 13, 2025

    @github-actions

    This issue was closed because it has been stalled for 90 days with no activity.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Labels

bugstale

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions