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

[Bug]: Segfault in SELECT query after upgrade to 2.5.2 #4191

Closed
mkindahl opened this issue Mar 24, 2022 · 1 comment · Fixed by #4192
Closed

[Bug]: Segfault in SELECT query after upgrade to 2.5.2 #4191

mkindahl opened this issue Mar 24, 2022 · 1 comment · Fixed by #4192
Assignees
Labels

Comments

@mkindahl
Copy link
Contributor

What type of bug is this?

Crash

What subsystems and features are affected?

Continuous aggregate

What happened?

Running queries on a continuous aggregate in one session will trigger a segfault with an odd error message if the extension is updated in another session.

TimescaleDB version affected

2.5.2

PostgreSQL version used

13.5

What operating system did you use?

Ubuntu 20.04.3 LTS

What installation method did you use?

Source

What platform did you run on?

On prem/Self-hosted

Relevant log output and stack trace

No response

How can we reproduce the bug?

mats@fury:~/issues/s311$ psql s311
Expanded display is used automatically.
Null display is "[NULL]".
psql (13.5)
Type "help" for help.

s311=# CREATE EXTENSION timescaledb VERSION "2.5.1";
WARNING:  
WELCOME TO
 _____ _                               _     ____________  
|_   _(_)                             | |    |  _  \ ___ \ 
  | |  _ _ __ ___   ___  ___  ___ __ _| | ___| | | | |_/ / 
  | | | |  _ ` _ \ / _ \/ __|/ __/ _` | |/ _ \ | | | ___ \ 
  | | | | | | | | |  __/\__ \ (_| (_| | |  __/ |/ /| |_/ /
  |_| |_|_| |_| |_|\___||___/\___\__,_|_|\___|___/ \____/
               Running version 2.5.1
For more information on TimescaleDB, please visit the following links:

 1. Getting started: https://docs.timescale.com/timescaledb/latest/getting-started
 2. API reference documentation: https://docs.timescale.com/api/latest
 3. How TimescaleDB is designed: https://docs.timescale.com/timescaledb/latest/overview/core-concepts

Note: TimescaleDB collects anonymous reports to better understand and assist our users.
For more information and how to disable, please see our docs https://docs.timescale.com/timescaledb/latest/how-to-guides/configuration/telemetry.

CREATE EXTENSION
s311=# 
s311=# 
s311=# CREATE TABLE conditions(
s311(#     time TIMESTAMPTZ NOT NULL,
s311(#     device_id INTEGER,
s311(#     humidity FLOAT
s311(# );
NOTICE:  switching extension state from EXTENSION_STATE_TRANSITIONING to EXTENSION_STATE_UNKNOWN
NOTICE:  switching extension state from EXTENSION_STATE_UNKNOWN to EXTENSION_STATE_CREATED
CREATE TABLE
s311=# 
s311=# SELECT * FROM create_hypertable('conditions', 'time');
 hypertable_id | schema_name | table_name | created 
---------------+-------------+------------+---------
             1 | public      | conditions | t
(1 row)

s311=# 
s311=# INSERT INTO conditions
s311-# SELECT time, (random()*3 + 1)::int, random()*100
s311-# FROM generate_series(now() - INTERVAL '7 days', now(), '1 hour') AS time;
INSERT 0 169
s311=# 
s311=# CREATE MATERIALIZED VIEW conditions_summary_daily
s311-# WITH (timescaledb.continuous) AS
s311-# SELECT device_id,
s311-#        time_bucket(INTERVAL '1 day', "time") AS bucket,
s311-#        AVG(humidity)
s311-# FROM conditions
s311-# GROUP BY device_id, bucket;
NOTICE:  refreshing continuous aggregate "conditions_summary_daily"
HINT:  Use WITH NO DATA if you do not want to refresh the continuous aggregate on creation.
CREATE MATERIALIZED VIEW
s311=# SELECT count(*) FROM conditions_summary_daily;
 count 
-------
    31
(1 row)

s311=# SELECT count(*) FROM conditions_summary_daily;
ERROR:  attempt to redefine parameter "timescaledb.enable_optimizations"
s311=# SELECT count(*) FROM conditions_summary_daily;
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.
!?>
@mkindahl mkindahl added the bug label Mar 24, 2022
@mkindahl mkindahl self-assigned this Mar 24, 2022
@mkindahl mkindahl added the segfault Segmentation fault label Mar 24, 2022
@mkindahl
Copy link
Contributor Author

First SELECT call

First select calls do_load as part of the pg_analyze_and_rewrite
inside exec_simple_query, which then calls
ts_extension_check_version.

(gdb) bt
#0  ts_extension_check_version (so_version=so_version@entry=0x7f80ddb9baf6 "2.5.1") at /home/mats/work/timescale/timescaledb+support/src/extension.c:70
#1  0x00007f80ddb5e604 in _PG_init () at /home/mats/work/timescale/timescaledb+support/src/init.c:99
#2  0x00005617c04ca964 in internal_load_library (libname=libname@entry=0x5617c25a0c20 "/usr/local/pg/13.5/lib/postgresql/timescaledb-2.5.1.so") at dfmgr.c:289
#3  0x00005617c04cb2e6 in load_external_function (filename=filename@entry=0x7ffc26800370 "$libdir/timescaledb-2.5.1", funcname=funcname@entry=0x7f80e7c5f073 "ts_post_load_init", signalNotFound=signalNotFound@entry=false, filehandle=filehandle@entry=0x0) at dfmgr.c:118
#4  0x00007f80e7c5b5ab in do_load () at /home/mats/work/timescale/timescaledb+support/src/loader/loader.c:718
#5  0x00007f80e7c5ba2c in extension_check () at /home/mats/work/timescale/timescaledb+support/src/loader/loader.c:753
#6  extension_check () at /home/mats/work/timescale/timescaledb+support/src/loader/loader.c:736
#7  post_analyze_hook (pstate=0x5617c24d09c0, query=0x5617c24d0ad8) at /home/mats/work/timescale/timescaledb+support/src/loader/loader.c:447
#8  0x00005617c010dd67 in parse_analyze (parseTree=0x5617c24d0930, sourceText=<optimized out>, paramTypes=0x0, numParams=0, queryEnv=0x0) at analyze.c:119
#9  0x00005617c0391337 in pg_analyze_and_rewrite (parsetree=parsetree@entry=0x5617c24d0930, query_string=query_string@entry=0x5617c24cfb70 "SELECT count(*) FROM conditions_summary_daily;", paramTypes=paramTypes@entry=0x0, numParams=numParams@entry=0, 
    queryEnv=queryEnv@entry=0x0) at postgres.c:691
#10 0x00005617c0391907 in exec_simple_query (query_string=0x5617c24cfb70 "SELECT count(*) FROM conditions_summary_daily;") at postgres.c:1155
#11 0x00005617c03932ba in PostgresMain (argc=<optimized out>, argv=argv@entry=0x5617c24ffc90, dbname=<optimized out>, username=<optimized out>) at postgres.c:4338
#12 0x00005617c02fde2f in BackendRun (port=0x5617c24fd910, port=0x5617c24fd910) at postmaster.c:4550
#13 BackendStartup (port=0x5617c24fd910) at postmaster.c:4234
#14 ServerLoop () at postmaster.c:1739
#15 0x00005617c02fedf4 in PostmasterMain (argc=1, argv=<optimized out>) at postmaster.c:1412
#16 0x00005617bfff7ea0 in main (argc=1, argv=0x5617c24c9700) at main.c:210

Second call to ts_extension_check_version is from pg_plan_queries
inside exec_simple_query.

(gdb) bt
#0  ts_extension_check_version (so_version=0x7f80ddb9baf6 "2.5.1") at /home/mats/work/timescale/timescaledb+support/src/extension.c:77
#1  ts_extension_check_version (so_version=0x7f80ddb9baf6 "2.5.1") at /home/mats/work/timescale/timescaledb+support/src/extension.c:69
#2  0x00007f80ddb53ff0 in extension_set_state (newstate=EXTENSION_STATE_CREATED) at /home/mats/work/timescale/timescaledb+support/src/extension.c:134
#3  extension_update_state () at /home/mats/work/timescale/timescaledb+support/src/extension.c:165
#4  0x00007f80ddb54618 in extension_update_state () at /home/mats/work/timescale/timescaledb+support/src/extension.c:285
#5  ts_extension_is_loaded () at /home/mats/work/timescale/timescaledb+support/src/extension.c:285
#6  0x00007f80ddb60a5d in timescaledb_planner (parse=0x5617c24d0ad8, query_string=0x5617c24cfb70 "SELECT count(*) FROM conditions_summary_daily;", cursor_opts=256, bound_params=0x0) at /home/mats/work/timescale/timescaledb+support/src/planner.c:315
#7  0x00005617c03914dc in pg_plan_query (querytree=0x5617c24d0ad8, query_string=0x5617c24cfb70 "SELECT count(*) FROM conditions_summary_daily;", cursorOptions=256, boundParams=0x0) at postgres.c:875
#8  0x00005617c03915d1 in pg_plan_queries (querytrees=0x5617c25a16a8, query_string=query_string@entry=0x5617c24cfb70 "SELECT count(*) FROM conditions_summary_daily;", cursorOptions=cursorOptions@entry=256, boundParams=boundParams@entry=0x0) at postgres.c:966
#9  0x00005617c039191b in exec_simple_query (query_string=0x5617c24cfb70 "SELECT count(*) FROM conditions_summary_daily;") at postgres.c:1158
#10 0x00005617c03932ba in PostgresMain (argc=<optimized out>, argv=argv@entry=0x5617c24ffc90, dbname=<optimized out>, username=<optimized out>) at postgres.c:4338
#11 0x00005617c02fde2f in BackendRun (port=0x5617c24fd910, port=0x5617c24fd910) at postmaster.c:4550
#12 BackendStartup (port=0x5617c24fd910) at postmaster.c:4234
#13 ServerLoop () at postmaster.c:1739
#14 0x00005617c02fedf4 in PostmasterMain (argc=1, argv=<optimized out>) at postmaster.c:1412
#15 0x00005617bfff7ea0 in main (argc=1, argv=0x5617c24c9700) at main.c:210

Second SELECT call

Now we run ALTER EXTENSION in a separate session to update the
extension, but keep the first one open.

When we run select in the first session again, it will hit
post_analyze_hook, but since loaded was set in the previous call,
no extension checking will be done as part of
pg_analyze_and_rewrite.

Breakpoint 12, post_analyze_hook (pstate=0x5617c24d09c0, query=0x5617c24d0ad8) at /home/mats/work/timescale/timescaledb+support/src/loader/loader.c:345
345     {
(gdb) bt
#0  extension_check () at /home/mats/work/timescale/timescaledb+support/src/loader/loader.c:738
#1  post_analyze_hook (pstate=0x5617c24d09c0, query=0x5617c24d0ad8) at /home/mats/work/timescale/timescaledb+support/src/loader/loader.c:447
#2  0x00005617c010dd67 in parse_analyze (parseTree=0x5617c24d0930, sourceText=<optimized out>, paramTypes=0x0, numParams=0, queryEnv=0x0) at analyze.c:119
#3  0x00005617c0391337 in pg_analyze_and_rewrite (parsetree=parsetree@entry=0x5617c24d0930, query_string=query_string@entry=0x5617c24cfb70 "SELECT count(*) FROM conditions_summary_daily;", paramTypes=paramTypes@entry=0x0, numParams=numParams@entry=0, 
    queryEnv=queryEnv@entry=0x0) at postgres.c:691
#4  0x00005617c0391907 in exec_simple_query (query_string=0x5617c24cfb70 "SELECT count(*) FROM conditions_summary_daily;") at postgres.c:1155
#5  0x00005617c03932ba in PostgresMain (argc=<optimized out>, argv=argv@entry=0x5617c24ffc90, dbname=<optimized out>, username=<optimized out>) at postgres.c:4338
#6  0x00005617c02fde2f in BackendRun (port=0x5617c24fd910, port=0x5617c24fd910) at postmaster.c:4550
#7  BackendStartup (port=0x5617c24fd910) at postmaster.c:4234
#8  ServerLoop () at postmaster.c:1739
#9  0x00005617c02fedf4 in PostmasterMain (argc=1, argv=<optimized out>) at postmaster.c:1412
#10 0x00005617bfff7ea0 in main (argc=1, argv=0x5617c24c9700) at main.c:210
(gdb) p loaded
$80 = true

It then hits ts_extension_check_version, as part of the
pg_plan_queries (not the pg_analyze_and_rewrite) but with the new
version.

Note that the so_version and sql_version are identical since the
so_version is from the newly loaded library.

Breakpoint 11, ts_extension_check_version (so_version=0x7f80dd965b16 "2.5.2") at /home/mats/work/timescale/timescaledb+support/src/extension.c:77
77              if (strcmp(sql_version, so_version) != 0)
$72 = 0x5617c26082c8 "2.5.2"
$73 = 0x7f80dd965b16 "2.5.2"
(gdb) bt
#0  ts_extension_check_version (so_version=0x7f80dd965b16 "2.5.2") at /home/mats/work/timescale/timescaledb+support/src/extension.c:77
#1  ts_extension_check_version (so_version=so_version@entry=0x7f80dd965b16 "2.5.2") at /home/mats/work/timescale/timescaledb+support/src/extension.c:69
#2  0x00007f80dd928584 in _PG_init () at /home/mats/work/timescale/timescaledb+support/src/init.c:101
#3  0x00005617c04ca964 in internal_load_library (libname=libname@entry=0x5617c2607ec8 "/usr/local/pg/13.5/lib/postgresql/timescaledb-2.5.2.so") at dfmgr.c:289
#4  0x00005617c04cb2e6 in load_external_function (filename=filename@entry=0x5617c2607df8 "$libdir/timescaledb-2.5.2", funcname=funcname@entry=0x5617c2607dc0 "ts_continuous_agg_watermark", signalNotFound=signalNotFound@entry=true, 
    filehandle=filehandle@entry=0x7ffc267fee48) at dfmgr.c:118
#5  0x00005617c04cbd46 in fmgr_info_C_lang (finfo=0x5617c2607d10, procedureTuple=0x7f80dd98f5f8, functionId=272860) at fmgr.c:403
#6  fmgr_info_cxt_security (functionId=functionId@entry=272860, finfo=finfo@entry=0x5617c2607d10, mcxt=<optimized out>, ignore_security=ignore_security@entry=false) at fmgr.c:248
#7  0x00005617c04cc0c2 in fmgr_info (functionId=functionId@entry=272860, finfo=finfo@entry=0x5617c2607d10) at fmgr.c:128
#8  0x00005617c01e8338 in ExecInitFunc (scratch=scratch@entry=0x7ffc267fefb0, node=node@entry=0x5617c25f6b00, args=0x5617c25f6aa8, funcid=272860, inputcollid=0, state=state@entry=0x5617c2607c78) at execExpr.c:2226
#9  0x00005617c01e6c36 in ExecInitExprRec (node=node@entry=0x5617c25f6b00, state=state@entry=0x5617c2607c78, resv=resv@entry=0x5617c2607c80, resnull=resnull@entry=0x5617c2607c7d) at execExpr.c:916
#10 0x00005617c01e55bc in ExecInitExpr (node=node@entry=0x5617c25f6b00, parent=parent@entry=0x0) at execExpr.c:142
#11 0x00005617c02c6bad in evaluate_expr (expr=0x5617c25f6b00, result_type=result_type@entry=20, result_typmod=result_typmod@entry=-1, result_collation=result_collation@entry=0) at clauses.c:4808
#12 0x00005617c02c8492 in evaluate_function (context=0x7ffc267ff570, func_tuple=0x7f80dd98f5f8, funcvariadic=false, args=0x5617c25f6aa8, input_collid=0, result_collid=0, result_typmod=-1, result_type=20, funcid=272860) at clauses.c:4348
#13 simplify_function (funcid=272860, result_type=20, result_typmod=-1, result_collid=0, input_collid=0, args_p=0x7ffc267ff2a0, funcvariadic=false, process_args=true, allow_non_const=true, context=0x7ffc267ff570) at clauses.c:3978
#14 0x00005617c02c6dea in eval_const_expressions_mutator (node=0x5617c2634a70, context=0x7ffc267ff570) at clauses.c:2532
#15 0x00005617c0265a86 in expression_tree_mutator (node=0x5617c2634b78, mutator=mutator@entry=0x5617c02c6cb0 <eval_const_expressions_mutator>, context=context@entry=0x7ffc267ff570) at nodeFuncs.c:3059
#16 0x00005617c02c8b2e in simplify_function (funcid=272853, result_type=1184, result_typmod=-1, result_collid=0, input_collid=0, args_p=0x7ffc267ff480, funcvariadic=false, process_args=true, allow_non_const=true, context=0x7ffc267ff570) at clauses.c:3969
#17 0x00005617c02c6dea in eval_const_expressions_mutator (node=0x5617c2634a18, context=0x7ffc267ff570) at clauses.c:2532
#18 0x00005617c02c7651 in eval_const_expressions_mutator (node=0x5617c26349e0, context=0x7ffc267ff570) at clauses.c:3183
#19 0x00005617c02c8d52 in estimate_expression_value (root=root@entry=0x5617c2633798, node=<optimized out>) at clauses.c:2355
#20 0x00005617c04706c6 in get_restriction_variable (root=root@entry=0x5617c2633798, args=<optimized out>, varRelid=<optimized out>, vardata=vardata@entry=0x7ffc267ff650, other=other@entry=0x7ffc267ff648, varonleft=varonleft@entry=0x7ffc267ff647) at selfuncs.c:4637
#21 0x00005617c0472e20 in get_restriction_variable (varonleft=0x7ffc267ff647, other=0x7ffc267ff648, vardata=0x7ffc267ff650, varRelid=<optimized out>, args=<optimized out>, root=<optimized out>) at ../../../../src/include/nodes/pg_list.h:171
#22 scalarineqsel_wrapper (fcinfo=<optimized out>, isgt=false, iseq=<optimized out>) at selfuncs.c:1419
#23 0x00005617c04ccfa2 in FunctionCall4Coll (flinfo=0x7ffc267ff750, collation=<optimized out>, arg1=<optimized out>, arg2=<optimized out>, arg3=<optimized out>, arg4=<optimized out>) at fmgr.c:1216
#24 0x00005617c04cd7da in OidFunctionCall4Coll (functionId=<optimized out>, collation=collation@entry=0, arg1=arg1@entry=94660045518744, arg2=arg2@entry=1322, arg3=arg3@entry=94660045523336, arg4=arg4@entry=0) at fmgr.c:1452
#25 0x00005617c02d4165 in restriction_selectivity (root=root@entry=0x5617c2633798, operatorid=operatorid@entry=1322, args=0x5617c2634988, inputcollid=0, varRelid=0) at plancat.c:1785
#26 0x00005617c02864c9 in clause_selectivity (root=0x5617c2633798, clause=0x5617c26348d8, varRelid=<optimized out>, jointype=JOIN_INNER, sjinfo=<optimized out>) at clausesel.c:777
#27 0x00005617c028691c in clauselist_selectivity_simple (root=0x5617c2633798, clauses=0x5617c25f6388, varRelid=0, jointype=JOIN_INNER, sjinfo=0x0, estimatedclauses=0x0) at ../../../../src/include/nodes/pg_list.h:127
#28 0x00005617c0286be9 in clauselist_selectivity (root=root@entry=0x5617c2633798, clauses=0x5617c25f6388, varRelid=varRelid@entry=0, jointype=jointype@entry=JOIN_INNER, sjinfo=sjinfo@entry=0x0) at clausesel.c:105
#29 0x00005617c028dd6d in set_baserel_size_estimates (root=root@entry=0x5617c2633798, rel=rel@entry=0x5617c2634188) at costsize.c:4650
#30 0x00005617c0283a20 in set_plain_rel_size (rte=0x5617c2632530, rel=0x5617c2634188, root=0x5617c2633798) at allpaths.c:583
#31 set_rel_size (root=root@entry=0x5617c2633798, rel=rel@entry=0x5617c2634188, rti=rti@entry=1, rte=rte@entry=0x5617c2632530) at allpaths.c:412
#32 0x00005617c0285cf0 in set_base_rel_sizes (root=<optimized out>) at allpaths.c:323
#33 make_one_rel (root=root@entry=0x5617c2633798, joinlist=joinlist@entry=0x5617c25f61a0) at allpaths.c:185
#34 0x00005617c02ab7ed in query_planner (root=root@entry=0x5617c2633798, qp_callback=qp_callback@entry=0x5617c02abf50 <standard_qp_callback>, qp_extra=qp_extra@entry=0x7ffc267ffbe0) at planmain.c:269
#35 0x00005617c02b0bfe in grouping_planner (root=<optimized out>, inheritance_update=false, tuple_fraction=<optimized out>) at planner.c:2059
#36 0x00005617c02b379c in subquery_planner (glob=<optimized out>, parse=parse@entry=0x5617c26323c0, parent_root=parent_root@entry=0x5617c24d1558, hasRecursion=hasRecursion@entry=false, tuple_fraction=0) at planner.c:1015
#37 0x00005617c02835bf in set_subquery_pathlist (rte=0x0, rti=<optimized out>, rel=0x5617c2632c88, root=0x5617c24d1558) at allpaths.c:2306
#38 set_rel_size (root=root@entry=0x5617c24d1558, rel=rel@entry=0x5617c263c608, rti=rti@entry=4, rte=rte@entry=0x5617c263c028) at allpaths.c:422
#39 0x00005617c0282d94 in set_append_rel_size (rte=0x5617c263c028, rti=1, rel=0x4, root=0x0) at allpaths.c:1111
#40 set_rel_size (root=root@entry=0x5617c24d1558, rel=rel@entry=0x5617c24d0d60, rti=rti@entry=1, rte=rte@entry=0x5617c24d0bf0) at allpaths.c:383
#41 0x00005617c0285cf0 in set_base_rel_sizes (root=<optimized out>) at allpaths.c:323
#42 make_one_rel (root=root@entry=0x5617c24d1558, joinlist=joinlist@entry=0x5617c2631f50) at allpaths.c:185
#43 0x00005617c02ab7ed in query_planner (root=root@entry=0x5617c24d1558, qp_callback=qp_callback@entry=0x5617c02abf50 <standard_qp_callback>, qp_extra=qp_extra@entry=0x7ffc26800120) at planmain.c:269
#44 0x00005617c02b0bfe in grouping_planner (root=<optimized out>, inheritance_update=false, tuple_fraction=<optimized out>) at planner.c:2059
#45 0x00005617c02b379c in subquery_planner (glob=glob@entry=0x5617c263c2c0, parse=parse@entry=0x5617c24d0ad8, parent_root=parent_root@entry=0x0, hasRecursion=hasRecursion@entry=false, tuple_fraction=tuple_fraction@entry=0) at planner.c:1015
#46 0x00005617c02b4bd3 in standard_planner (parse=parse@entry=0x5617c24d0ad8, query_string=query_string@entry=0x5617c24cfb70 "SELECT count(*) FROM conditions_summary_daily;", cursorOptions=cursorOptions@entry=256, boundParams=boundParams@entry=0x0) at planner.c:405
#47 0x00007f80ddb60b37 in timescaledb_planner (parse=0x5617c24d0ad8, query_string=0x5617c24cfb70 "SELECT count(*) FROM conditions_summary_daily;", cursor_opts=256, bound_params=0x0) at /home/mats/work/timescale/timescaledb+support/src/planner.c:328
#48 0x00005617c03914dc in pg_plan_query (querytree=0x5617c24d0ad8, query_string=0x5617c24cfb70 "SELECT count(*) FROM conditions_summary_daily;", cursorOptions=256, boundParams=0x0) at postgres.c:875
#49 0x00005617c03915d1 in pg_plan_queries (querytrees=0x5617c25a8a00, query_string=query_string@entry=0x5617c24cfb70 "SELECT count(*) FROM conditions_summary_daily;", cursorOptions=cursorOptions@entry=256, boundParams=boundParams@entry=0x0) at postgres.c:966
#50 0x00005617c039191b in exec_simple_query (query_string=0x5617c24cfb70 "SELECT count(*) FROM conditions_summary_daily;") at postgres.c:1158
#51 0x00005617c03932ba in PostgresMain (argc=<optimized out>, argv=argv@entry=0x5617c24ffc90, dbname=<optimized out>, username=<optimized out>) at postgres.c:4338
#52 0x00005617c02fde2f in BackendRun (port=0x5617c24fd910, port=0x5617c24fd910) at postmaster.c:4550
#53 BackendStartup (port=0x5617c24fd910) at postmaster.c:4234
#54 ServerLoop () at postmaster.c:1739
#55 0x00005617c02fedf4 in PostmasterMain (argc=1, argv=<optimized out>) at postmaster.c:1412
#56 0x00005617bfff7ea0 in main (argc=1, argv=0x5617c24c9700) at main.c:210

mkindahl added a commit to mkindahl/timescaledb that referenced this issue Mar 24, 2022
If a session is started and loads (and caches, by OID) functions in the
extension to use them in, for example, a `SELECT` query on a continuous
aggregate, the extension will be marked as loaded internally.

If an `ALTER EXTENSION` is then executed in a separate session, it will
update `pg_extension` to hold the new version, and any other sessions
will see this as the new version, including the session that already
loaded the previous version of the shared library.

Since the pre-update session has loaded some functions from the old
version already, running the same queries with the old named functions
will trigger a reload of the new version of the shared library to get
the new functions (same name, but different OID), but since this has
already been loaded in a different version, it will trigger an error
that GUC variables are re-defined.

Further queries after that will then corrupt the database causing a
crash.

This commit fixes this by recording the version loaded rather than if
it has been loaded and check that the version did not change after a
query has been analyzed (in the `post_analyze_hook`). If the version
changed, it will generate a fatal error to force an abort of the
session.

Fixes timescale#4191
mkindahl added a commit to mkindahl/timescaledb that referenced this issue Mar 28, 2022
If a session is started and loads (and caches, by OID) functions in the
extension to use them in, for example, a `SELECT` query on a continuous
aggregate, the extension will be marked as loaded internally.

If an `ALTER EXTENSION` is then executed in a separate session, it will
update `pg_extension` to hold the new version, and any other sessions
will see this as the new version, including the session that already
loaded the previous version of the shared library.

Since the pre-update session has loaded some functions from the old
version already, running the same queries with the old named functions
will trigger a reload of the new version of the shared library to get
the new functions (same name, but different OID), but since this has
already been loaded in a different version, it will trigger an error
that GUC variables are re-defined.

Further queries after that will then corrupt the database causing a
crash.

This commit fixes this by recording the version loaded rather than if
it has been loaded and check that the version did not change after a
query has been analyzed (in the `post_analyze_hook`). If the version
changed, it will generate a fatal error to force an abort of the
session.

Fixes timescale#4191
mkindahl added a commit to mkindahl/timescaledb that referenced this issue Mar 28, 2022
If a session is started and loads (and caches, by OID) functions in the
extension to use them in, for example, a `SELECT` query on a continuous
aggregate, the extension will be marked as loaded internally.

If an `ALTER EXTENSION` is then executed in a separate session, it will
update `pg_extension` to hold the new version, and any other sessions
will see this as the new version, including the session that already
loaded the previous version of the shared library.

Since the pre-update session has loaded some functions from the old
version already, running the same queries with the old named functions
will trigger a reload of the new version of the shared library to get
the new functions (same name, but different OID), but since this has
already been loaded in a different version, it will trigger an error
that GUC variables are re-defined.

Further queries after that will then corrupt the database causing a
crash.

This commit fixes this by recording the version loaded rather than if
it has been loaded and check that the version did not change after a
query has been analyzed (in the `post_analyze_hook`). If the version
changed, it will generate a fatal error to force an abort of the
session.

Fixes timescale#4191
@jfjoly jfjoly added this to the TimescaleDB 2.6.1 milestone Mar 28, 2022
mkindahl added a commit to mkindahl/timescaledb that referenced this issue Mar 29, 2022
If a session is started and loads (and caches, by OID) functions in the
extension to use them in, for example, a `SELECT` query on a continuous
aggregate, the extension will be marked as loaded internally.

If an `ALTER EXTENSION` is then executed in a separate session, it will
update `pg_extension` to hold the new version, and any other sessions
will see this as the new version, including the session that already
loaded the previous version of the shared library.

Since the pre-update session has loaded some functions from the old
version already, running the same queries with the old named functions
will trigger a reload of the new version of the shared library to get
the new functions (same name, but different OID), but since this has
already been loaded in a different version, it will trigger an error
that GUC variables are re-defined.

Further queries after that will then corrupt the database causing a
crash.

This commit fixes this by recording the version loaded rather than if
it has been loaded and check that the version did not change after a
query has been analyzed (in the `post_analyze_hook`). If the version
changed, it will generate a fatal error to force an abort of the
session.

Fixes timescale#4191
mkindahl added a commit to mkindahl/timescaledb that referenced this issue Mar 30, 2022
If a session is started and loads (and caches, by OID) functions in the
extension to use them in, for example, a `SELECT` query on a continuous
aggregate, the extension will be marked as loaded internally.

If an `ALTER EXTENSION` is then executed in a separate session, it will
update `pg_extension` to hold the new version, and any other sessions
will see this as the new version, including the session that already
loaded the previous version of the shared library.

Since the pre-update session has loaded some functions from the old
version already, running the same queries with the old named functions
will trigger a reload of the new version of the shared library to get
the new functions (same name, but different OID), but since this has
already been loaded in a different version, it will trigger an error
that GUC variables are re-defined.

Further queries after that will then corrupt the database causing a
crash.

This commit fixes this by recording the version loaded rather than if
it has been loaded and check that the version did not change after a
query has been analyzed (in the `post_analyze_hook`). If the version
changed, it will generate a fatal error to force an abort of the
session.

Fixes timescale#4191
mkindahl added a commit to mkindahl/timescaledb that referenced this issue Mar 30, 2022
If a session is started and loads (and caches, by OID) functions in the
extension to use them in, for example, a `SELECT` query on a continuous
aggregate, the extension will be marked as loaded internally.

If an `ALTER EXTENSION` is then executed in a separate session, it will
update `pg_extension` to hold the new version, and any other sessions
will see this as the new version, including the session that already
loaded the previous version of the shared library.

Since the pre-update session has loaded some functions from the old
version already, running the same queries with the old named functions
will trigger a reload of the new version of the shared library to get
the new functions (same name, but different OID), but since this has
already been loaded in a different version, it will trigger an error
that GUC variables are re-defined.

Further queries after that will then corrupt the database causing a
crash.

This commit fixes this by recording the version loaded rather than if
it has been loaded and check that the version did not change after a
query has been analyzed (in the `post_analyze_hook`). If the version
changed, it will generate a fatal error to force an abort of the
session.

Fixes timescale#4191
mkindahl added a commit to mkindahl/timescaledb that referenced this issue Mar 30, 2022
If a session is started and loads (and caches, by OID) functions in the
extension to use them in, for example, a `SELECT` query on a continuous
aggregate, the extension will be marked as loaded internally.

If an `ALTER EXTENSION` is then executed in a separate session, it will
update `pg_extension` to hold the new version, and any other sessions
will see this as the new version, including the session that already
loaded the previous version of the shared library.

Since the pre-update session has loaded some functions from the old
version already, running the same queries with the old named functions
will trigger a reload of the new version of the shared library to get
the new functions (same name, but different OID), but since this has
already been loaded in a different version, it will trigger an error
that GUC variables are re-defined.

Further queries after that will then corrupt the database causing a
crash.

This commit fixes this by recording the version loaded rather than if
it has been loaded and check that the version did not change after a
query has been analyzed (in the `post_analyze_hook`). If the version
changed, it will generate a fatal error to force an abort of the
session.

Fixes timescale#4191
mkindahl added a commit that referenced this issue Mar 30, 2022
If a session is started and loads (and caches, by OID) functions in the
extension to use them in, for example, a `SELECT` query on a continuous
aggregate, the extension will be marked as loaded internally.

If an `ALTER EXTENSION` is then executed in a separate session, it will
update `pg_extension` to hold the new version, and any other sessions
will see this as the new version, including the session that already
loaded the previous version of the shared library.

Since the pre-update session has loaded some functions from the old
version already, running the same queries with the old named functions
will trigger a reload of the new version of the shared library to get
the new functions (same name, but different OID), but since this has
already been loaded in a different version, it will trigger an error
that GUC variables are re-defined.

Further queries after that will then corrupt the database causing a
crash.

This commit fixes this by recording the version loaded rather than if
it has been loaded and check that the version did not change after a
query has been analyzed (in the `post_analyze_hook`). If the version
changed, it will generate a fatal error to force an abort of the
session.

Fixes #4191
RafiaSabih pushed a commit to RafiaSabih/timescaledb that referenced this issue Apr 5, 2022
If a session is started and loads (and caches, by OID) functions in the
extension to use them in, for example, a `SELECT` query on a continuous
aggregate, the extension will be marked as loaded internally.

If an `ALTER EXTENSION` is then executed in a separate session, it will
update `pg_extension` to hold the new version, and any other sessions
will see this as the new version, including the session that already
loaded the previous version of the shared library.

Since the pre-update session has loaded some functions from the old
version already, running the same queries with the old named functions
will trigger a reload of the new version of the shared library to get
the new functions (same name, but different OID), but since this has
already been loaded in a different version, it will trigger an error
that GUC variables are re-defined.

Further queries after that will then corrupt the database causing a
crash.

This commit fixes this by recording the version loaded rather than if
it has been loaded and check that the version did not change after a
query has been analyzed (in the `post_analyze_hook`). If the version
changed, it will generate a fatal error to force an abort of the
session.

Fixes timescale#4191
RafiaSabih pushed a commit to RafiaSabih/timescaledb that referenced this issue Apr 8, 2022
If a session is started and loads (and caches, by OID) functions in the
extension to use them in, for example, a `SELECT` query on a continuous
aggregate, the extension will be marked as loaded internally.

If an `ALTER EXTENSION` is then executed in a separate session, it will
update `pg_extension` to hold the new version, and any other sessions
will see this as the new version, including the session that already
loaded the previous version of the shared library.

Since the pre-update session has loaded some functions from the old
version already, running the same queries with the old named functions
will trigger a reload of the new version of the shared library to get
the new functions (same name, but different OID), but since this has
already been loaded in a different version, it will trigger an error
that GUC variables are re-defined.

Further queries after that will then corrupt the database causing a
crash.

This commit fixes this by recording the version loaded rather than if
it has been loaded and check that the version did not change after a
query has been analyzed (in the `post_analyze_hook`). If the version
changed, it will generate a fatal error to force an abort of the
session.

Fixes timescale#4191
mkindahl added a commit to RafiaSabih/timescaledb that referenced this issue Apr 8, 2022
If a session is started and loads (and caches, by OID) functions in the
extension to use them in, for example, a `SELECT` query on a continuous
aggregate, the extension will be marked as loaded internally.

If an `ALTER EXTENSION` is then executed in a separate session, it will
update `pg_extension` to hold the new version, and any other sessions
will see this as the new version, including the session that already
loaded the previous version of the shared library.

Since the pre-update session has loaded some functions from the old
version already, running the same queries with the old named functions
will trigger a reload of the new version of the shared library to get
the new functions (same name, but different OID), but since this has
already been loaded in a different version, it will trigger an error
that GUC variables are re-defined.

Further queries after that will then corrupt the database causing a
crash.

This commit fixes this by recording the version loaded rather than if
it has been loaded and check that the version did not change after a
query has been analyzed (in the `post_analyze_hook`). If the version
changed, it will generate a fatal error to force an abort of the
session.

Fixes timescale#4191
svenklemm pushed a commit that referenced this issue Apr 11, 2022
If a session is started and loads (and caches, by OID) functions in the
extension to use them in, for example, a `SELECT` query on a continuous
aggregate, the extension will be marked as loaded internally.

If an `ALTER EXTENSION` is then executed in a separate session, it will
update `pg_extension` to hold the new version, and any other sessions
will see this as the new version, including the session that already
loaded the previous version of the shared library.

Since the pre-update session has loaded some functions from the old
version already, running the same queries with the old named functions
will trigger a reload of the new version of the shared library to get
the new functions (same name, but different OID), but since this has
already been loaded in a different version, it will trigger an error
that GUC variables are re-defined.

Further queries after that will then corrupt the database causing a
crash.

This commit fixes this by recording the version loaded rather than if
it has been loaded and check that the version did not change after a
query has been analyzed (in the `post_analyze_hook`). If the version
changed, it will generate a fatal error to force an abort of the
session.

Fixes #4191
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants