Skip to content

Postgres crash when using uuid and explain #3

@ludobrands

Description

@ludobrands

Hi,

encountering multiple connection crashes when working with uuid. Reduced it to it's simplest case:

cassandra@cqlsh> create table stats.messages (message_guid uuid PRIMARY KEY, from_domain text);

postgres=# \d+ message
                         Table "public.message"
    Column    | Type | Modifiers | Storage  | Stats target | Description 
--------------+------+-----------+----------+--------------+-------------
 message_guid | uuid | not null  | plain    |              | 
 domain       | text |           | extended |              | 
Indexes:
    "message_pkey" PRIMARY KEY, btree (message_guid)

select * from fdw_stats.messages where message_guid in ('5f6ff794-bff6-4404-96ea-ed4faefb812a','45fd83f9-6fc8-4dc2-9b4a-bdfef6bb6cf2');
works fine. But
explain select * from fdw_stats.messages where message_guid in ('5f6ff794-bff6-4404-96ea-ed4faefb812a','45fd83f9-6fc8-4dc2-9b4a-bdfef6bb6cf2');
crashes the server process. The only log I found is in /var/log/syslog:
kernel: [5994562.576860] postgres[14200]: segfault at 0 ip 0000558b194c77ba sp 00007fffcbaacfd0 error 4 in postgres[558b190c1000+64c000]

Enabled ISDEBUG but that doesn't seem to help a lot:

postgres=# explain select * from fdw_stats.messages c join message p on (p.message_guid = c.message_guid);
NOTICE:  begin: 0
NOTICE:  rowid requested
NOTICE:  path keys: [((u'message_guid',), 1), (u'message_guid', 10000), (u'from_domain', 10000), (u'__rowid__', 1)]
server closed the connection unexpectedly
        This probably means the server terminated abnormally
        before or while processing the request.
The connection to the server was lost. Attempting reset: Failed.
!>

It is linked to the uuid since
explain select * from message m join fdw_stats.messages c on (m.domain=c.from_domain);
works just fine

Strangely enough, explain analyze of the same failing query does work:

postgres=# explain analyze select * from fdw_stats.messages c join message p on (p.message_guid = c.message_guid);
NOTICE:  begin: 0
NOTICE:  rowid requested
NOTICE:  path keys: [((u'message_guid',), 1), (u'message_guid', 10000), (u'from_domain', 10000), (u'__rowid__', 1)]
NOTICE:  building select statement... Quals: [message_guid = 1cc882db-f453-4af5-8289-205a2d5c4182], columns: set(['from_domain', 'message_guid', '__rowid__']), sortkeys: None, allow filtering: False
NOTICE:  qual field message_guid; qual index 1; qual type <type 'unicode'>; qual operator: =; qual value 1cc882db-f453-4af5-8289-205a2d5c4182
NOTICE:  CQL query: SELECT "from_domain","message_guid" FROM stats.messages WHERE  message_guid = %s 
NOTICE:  executing statement...
NOTICE:  cursor got in 6.60181045532 ms
NOTICE:  building select statement... Quals: [message_guid = 5f6ff794-bff6-4404-96ea-ed4faefb812a], columns: set(['from_domain', 'message_guid', '__rowid__']), sortkeys: None, allow filtering: False
NOTICE:  qual field message_guid; qual index 1; qual type <type 'unicode'>; qual operator: =; qual value 5f6ff794-bff6-4404-96ea-ed4faefb812a
NOTICE:  CQL query: SELECT "from_domain","message_guid" FROM stats.messages WHERE  message_guid = %s 
NOTICE:  executing statement...
NOTICE:  cursor got in 3.63993644714 ms
NOTICE:  qual field message_guid; qual index 1; qual type <type 'unicode'>; qual operator: =; qual value 5f6ff794-bff6-4404-96ea-ed4faefb812a
NOTICE:  CQL query: SELECT "from_domain","message_guid" FROM stats.messages WHERE  message_guid = %s 
NOTICE:  end_scan. Total time: 4.79602813721 ms
NOTICE:  pre commit
NOTICE:  commit
                                                    QUERY PLAN                                                     
-------------------------------------------------------------------------------------------------------------------
 Nested Loop  (cost=20.00..107031.40 rows=100000 width=128) (actual time=7.374..11.785 rows=2 loops=1)
   ->  Seq Scan on message p  (cost=0.00..20.70 rows=1070 width=48) (actual time=0.015..0.022 rows=2 loops=1)
   ->  Foreign Scan on messages c  (cost=20.00..100.00 rows=1 width=100) (actual time=5.846..5.873 rows=1 loops=2)
         Filter: (p.message_guid = message_guid)
         Multicorn: SELECT "from_domain","message_guid" FROM stats.messages WHERE  message_guid = %s 
         Multicorn: [UUID('5f6ff794-bff6-4404-96ea-ed4faefb812a')]
         Multicorn: ['from_domain', 'message_guid']
 Planning time: 1.027 ms
 Execution time: 12.074 ms
(9 rows)

This works also:

postgres=# explain select * from message m join fdw_stats.messages c on (m.message_guid=c.message_guid and c.message_guid='{5f6ff794-bff6-4404-96ea-ed4faefb812a}');
NOTICE:  begin: 0
NOTICE:  rowid requested
NOTICE:  path keys: [((u'message_guid',), 1), (u'message_guid', 10000), (u'from_domain', 10000), (u'__rowid__', 1)]
NOTICE:  qual field message_guid; qual index 1; qual type <type 'unicode'>; qual operator: =; qual value 5f6ff794-bff6-4404-96ea-ed4faefb812a
NOTICE:  CQL query: SELECT "from_domain","message_guid" FROM stats.messages WHERE  message_guid = %s
NOTICE:  end_scan. Total time: 0.861167907715 ms
NOTICE:  pre commit
NOTICE:  commit
                                              QUERY PLAN
------------------------------------------------------------------------------------------------------
 Nested Loop  (cost=20.15..108.18 rows=1 width=128)
   ->  Index Scan using message_pkey on message m  (cost=0.15..8.17 rows=1 width=48)
         Index Cond: (message_guid = '5f6ff794-bff6-4404-96ea-ed4faefb812a'::uuid)
   ->  Foreign Scan on messages c  (cost=20.00..100.00 rows=1 width=100)
         Filter: (message_guid = '5f6ff794-bff6-4404-96ea-ed4faefb812a'::uuid)
         Multicorn: SELECT "from_domain","message_guid" FROM stats.messages WHERE  message_guid = %s
         Multicorn: [UUID('5f6ff794-bff6-4404-96ea-ed4faefb812a')]
         Multicorn: ['from_domain', 'message_guid']
(8 rows)

Anything else I can do to pin point the cause of the problem?

Cheers,

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions