tembo-io / pg_timeseries

Simple and focused time-series tables for PostgreSQL, from Tembo
PostgreSQL License
324 stars 5 forks source link

Segmentation fault when running regression tests #31

Open esiaero opened 1 month ago

esiaero commented 1 month ago

Versions: PostgreSQL 16.4

Extensions are all the head of their respective repos except pg_partman which is missing a minor metadata file update. Exact commits: pg_partman - de93f4a pg_cron - f5d1111 columnar - 47354c2 timeseries - ba218b8

Manual installation of timeseries on Amazon Linux 2.0


The installation and extension creation goes fine. However, running make installcheck for the regression tests causes a segfault on extension creation.

Program terminated with signal SIGSEGV, Segmentation fault.
#0  0x000000000064c567 in LookupTypeNameExtended (pstate=0x0, typeName=0x0, typmod_p=0x0, temp_ok=true, missing_ok=false) at parse_type.c:81
81      if (typeName->names == NIL)
(gdb) bt
#0  0x000000000064c567 in LookupTypeNameExtended (pstate=0x0, typeName=0x0, typmod_p=0x0, temp_ok=true, missing_ok=false) at parse_type.c:81
#1  0x000000000064c52a in LookupTypeName (pstate=0x0, typeName=0x0, typmod_p=0x0, missing_ok=false) at parse_type.c:41
#2  0x00000000006a1547 in interpret_function_parameter_list (pstate=0x1e78118, parameters=0x21769d8, languageOid=13737, objtype=OBJECT_PROCEDURE, parameterTypes=0x7ffcc14408a8, 
    parameterTypes_list=0x7ffcc14408a0, allParameterTypes=0x7ffcc1440898, parameterModes=0x7ffcc1440890, parameterNames=0x7ffcc1440888, inParameterNames_list=0x7ffcc1440880, 
    parameterDefaults=0x7ffcc1440878, variadicArgType=0x7ffcc1440874, requiredResultType=0x7ffcc1440870) at functioncmds.c:241
#3  0x00000000006a3ada in CreateFunction (pstate=0x1e78118, stmt=0x2178180) at functioncmds.c:1163
#4  0x00000000009c7302 in ProcessUtilitySlow (pstate=0x1e78118, pstmt=0x1e77e58, 
    queryString=0x2066668 "CREATE TYPE public.check_default_table AS (default_table text, count bigint);\nCREATE TABLE public.part_config (\n    parent_table text NOT NULL\n    , control text NOT NULL\n    , partition_interval text"..., context=PROCESS_UTILITY_QUERY, params=0x0, queryEnv=0x0, dest=0xd66e00 <donothingDR>, qc=0x0) at utility.c:1659
#5  0x00000000009c6078 in standard_ProcessUtility (pstmt=0x1e77e58, 
    queryString=0x2066668 "CREATE TYPE public.check_default_table AS (default_table text, count bigint);\nCREATE TABLE public.part_config (\n    parent_table text NOT NULL\n    , control text NOT NULL\n    , partition_interval text"..., readOnlyTree=false, context=PROCESS_UTILITY_QUERY, params=0x0, queryEnv=0x0, dest=0xd66e00 <donothingDR>, qc=0x0)
    at utility.c:1078
#6  0x00007f0266335713 in ColumnarProcessUtility (pstmt=0x1e77e58, 
    queryString=0x2066668 "CREATE TYPE public.check_default_table AS (default_table text, count bigint);\nCREATE TABLE public.part_config (\n    parent_table text NOT NULL\n    , control text NOT NULL\n    , partition_interval text"..., readOnlyTree=false, context=PROCESS_UTILITY_QUERY, params=0x0, queryEnv=0x0, dest=0xd66e00 <donothingDR>, completionTag=0x0)
    at columnar_tableam.c:2916
#7  0x00000000009c51ec in ProcessUtility (pstmt=0x1e77e58, 
    queryString=0x2066668 "CREATE TYPE public.check_default_table AS (default_table text, count bigint);\nCREATE TABLE public.part_config (\n    parent_table text NOT NULL\n    , control text NOT NULL\n    , partition_interval text"..., readOnlyTree=false, context=PROCESS_UTILITY_QUERY, params=0x0, queryEnv=0x0, dest=0xd66e00 <donothingDR>, qc=0x0)
    at utility.c:526
#8  0x000000000069819f in execute_sql_string (
    sql=0x2066668 "CREATE TYPE public.check_default_table AS (default_table text, count bigint);\nCREATE TABLE public.part_config (\n    parent_table text NOT NULL\n    , control text NOT NULL\n    , partition_interval text"...) at extension.c:818
#9  0x0000000000698d76 in execute_extension_script (extensionOid=16629, control=0x1f979d0, from_version=0x0, version=0x1f97a60 "5.1.0", requiredSchemas=0x0, 
    schemaName=0x1f97968 "public", schemaOid=2200) at extension.c:1117
#10 0x0000000000699d2e in CreateExtensionInternal (extensionName=0x1e5f163 "pg_partman", schemaName=0x1f97968 "public", versionName=0x1f97a60 "5.1.0", cascade=true, 
    parents=0x20277e8, is_create=true) at extension.c:1681
#11 0x0000000000699f5b in get_required_extension (reqExtensionName=0x1e5f163 "pg_partman", extensionName=0x1d88760 "timeseries", origSchemaName=0x0, cascade=true, parents=0x0, 
    is_create=true) at extension.c:1746
#12 0x0000000000699ba6 in CreateExtensionInternal (extensionName=0x1d88760 "timeseries", schemaName=0x1db1b28 "public", versionName=0x1e5f108 "0.1.5", cascade=true, parents=0x0, 
    is_create=true) at extension.c:1650
#13 0x000000000069a320 in CreateExtension (pstate=0x1db2208, stmt=0x1d88718) at extension.c:1848
#14 0x00000000009c703a in ProcessUtilitySlow (pstate=0x1db2208, pstmt=0x1d88eb8, queryString=0x1d88308 "CREATE EXTENSION timeseries CASCADE;", context=PROCESS_UTILITY_TOPLEVEL, 
    params=0x0, queryEnv=0x0, dest=0x1d89178, qc=0x7ffcc1441db0) at utility.c:1578
#15 0x00000000009c6078 in standard_ProcessUtility (pstmt=0x1d88eb8, queryString=0x1d88308 "CREATE EXTENSION timeseries CASCADE;", readOnlyTree=false, 
    context=PROCESS_UTILITY_TOPLEVEL, params=0x0, queryEnv=0x0, dest=0x1d89178, qc=0x7ffcc1441db0) at utility.c:1078
#16 0x00000000009c521d in ProcessUtility (pstmt=0x1d88eb8, queryString=0x1d88308 "CREATE EXTENSION timeseries CASCADE;", readOnlyTree=false, context=PROCESS_UTILITY_TOPLEVEL, 
    params=0x0, queryEnv=0x0, dest=0x1d89178, qc=0x7ffcc1441db0) at utility.c:530
#17 0x00000000009c3e84 in PortalRunUtility (portal=0x1e01698, pstmt=0x1d88eb8, isTopLevel=true, setHoldSnapshot=false, dest=0x1d89178, qc=0x7ffcc1441db0) at pquery.c:1158
#18 0x00000000009c40de in PortalRunMulti (portal=0x1e01698, isTopLevel=true, setHoldSnapshot=false, dest=0x1d89178, altdest=0x1d89178, qc=0x7ffcc1441db0) at pquery.c:1315
#19 0x00000000009c3613 in PortalRun (portal=0x1e01698, count=9223372036854775807, isTopLevel=true, run_once=true, dest=0x1d89178, altdest=0x1d89178, qc=0x7ffcc1441db0)
    at pquery.c:791
#20 0x00000000009bcf0d in exec_simple_query (query_string=0x1d88308 "CREATE EXTENSION timeseries CASCADE;") at postgres.c:1278
#21 0x00000000009c1774 in PostgresMain (dbname=0x1d84b08 "contrib_regression", username=0x1d84b38 "evsi") at postgres.c:4701
#22 0x00000000008f7fe7 in BackendRun (port=0x1db08d0) at postmaster.c:4464
#23 0x00000000008f797d in BackendStartup (port=0x1db08d0) at postmaster.c:4192
#24 0x00000000008f4242 in ServerLoop () at postmaster.c:1782
#25 0x00000000008f3c12 in PostmasterMain (argc=8, argv=0x1d829b0) at postmaster.c:1466
#26 0x00000000007ba16e in main (argc=8, argv=0x1d829b0) at main.c:198

At a glance, I noticed pg_partman creation was going through columnar hooks. If I make it so cascade installs pg_partman before columnar

diff --git a/timeseries.control b/timeseries.control
index 1aa7027..627ad5e 100644
--- a/timeseries.control
+++ b/timeseries.control
@@ -2,4 +2,4 @@
 comment = 'Convenience API for Tembo time series stack'
 default_version = '0.1.5'
 module_pathname = '$libdir/timeseries'
-requires = 'columnar, pg_cron, pg_partman'
+requires = 'pg_partman, columnar, pg_cron'

The regression tests run fine (only difference being the order of cascaded dependent extension creation).

Curious if this kind of behavior has been encountered before?

jasonmp85 commented 1 month ago

Curious if this kind of behavior has been encountered before?

I haven't come across this behavior myself, but if that swap causes things to work better, it might be worth changing in our codebase.

I'll look into this a little bit today and update here.