Re: Error when setting default_text_search_config - Mailing list pgsql-bugs

From Erik Wienhold
Subject Re: Error when setting default_text_search_config
Date
Msg-id 9c480df9-720b-4419-85c6-09113f5d6f0a@ewie.name
Whole thread Raw
In response to Re: Error when setting default_text_search_config  (Erik Wienhold <ewie@ewie.name>)
Responses Re: Error when setting default_text_search_config
List pgsql-bugs
I wrote:
> I can reproduce a segfault on my Arch machine with 17.0, but only by
> also connecting to that database afterwards:
> 
>     postgres=# create database regress;
>     postgres=# alter database regress set default_text_search_config to 'german';
>     postgres=# \c regress
>     connection to server at "localhost" (::1), port 15432 failed: server closed the connection unexpectedly
>             This probably means the server terminated abnormally
>             before or while processing the request.

Here's better backtrace based on commit fee8cb9473 (not sure why the
first one lacked the additional info):

    #0  0x0000654521e03394 in MemoryContextReset (context=0x0) at mcxt.c:388
    #1  0x0000654521a165ea in spcache_init () at namespace.c:318
    #2  0x0000654521a16d46 in cachedNamespacePath (searchPath=0x654541b0f3f0 "\"$user\", public", roleid=10) at
namespace.c:4234
    #3  recomputeNamespacePath () at namespace.c:4294
    #4  0x0000654521a19d45 in get_ts_config_oid (names=0x654541b86860, missing_ok=missing_ok@entry=true) at
namespace.c:3162
    #5  0x0000654521dd5f88 in check_default_text_search_config (newval=0x7ffcb598c928, extra=<optimized out>,
source=PGC_S_DATABASE)at ts_cache.c:621
 
    #6  0x0000654521dee440 in call_string_check_hook (conf=conf@entry=0x65452215e830 <ConfigureNamesString+11600>,
newval=newval@entry=0x7ffcb598c928,extra=extra@entry=0x7ffcb598c930, source=source@entry=PGC_S_DATABASE,
elevel=elevel@entry=19)at guc.c:6890
 
    #7  0x0000654521df10fb in parse_and_validate_value (record=0x65452215e830 <ConfigureNamesString+11600>,
name=0x654541b86468"default_text_search_config", value=<optimized out>, source=PGC_S_DATABASE, elevel=19,
newval=0x7ffcb598c928,newextra=0x7ffcb598c930) at guc.c:3260
 
    #8  0x0000654521df202a in set_config_with_handle (name=name@entry=0x654541b86468 "default_text_search_config",
handle=handle@entry=0x0,value=value@entry=0x654541b867a0 "german", context=context@entry=PGC_SUSET,
source=source@entry=PGC_S_DATABASE,srole=10, action=GUC_ACTION_SET, changeVal=<optimized out>, elevel=19,
is_reload=false)at guc.c:4010
 
    #9  0x0000654521df65c5 in set_config_option (name=0x654541b86468 "default_text_search_config", value=0x654541b867a0
"german",context=<optimized out>, source=<optimized out>, action=<optimized out>, changeVal=true, elevel=0,
is_reload=false)at guc.c:3363
 
    #10 ProcessGUCArray (array=<optimized out>, context=PGC_SUSET, source=PGC_S_DATABASE, action=GUC_ACTION_SET) at
guc.c:6438
    #11 0x0000654521a274d7 in ApplySetting (snapshot=snapshot@entry=0x654541b855e8, databaseid=databaseid@entry=40965,
roleid=roleid@entry=0,relsetting=relsetting@entry=0x7be2b87866e8, source=source@entry=PGC_S_DATABASE) at
pg_db_role_setting.c:256
    #12 0x0000654521dea2d6 in process_settings (databaseid=40965, roleid=10) at postinit.c:1342
    #13 InitPostgres (in_dbname=in_dbname@entry=0x654541aeff60 "regress", dboid=<optimized out>, dboid@entry=0,
username=username@entry=0x654541b2db98"ewie", useroid=useroid@entry=0, flags=1, out_dbname=out_dbname@entry=0x0) at
postinit.c:1217
    #14 0x0000654521c9e8a6 in PostgresMain (dbname=0x654541aeff60 "regress", username=0x654541b2db98 "ewie") at
postgres.c:4324
    #15 0x0000654521c9a9df in BackendMain (startup_data=<optimized out>, startup_data_len=<optimized out>) at
backend_startup.c:105
    #16 0x0000654521c0acdb in postmaster_child_launch (child_type=child_type@entry=B_BACKEND,
startup_data=startup_data@entry=0x7ffcb598cfe0"", startup_data_len=startup_data_len@entry=4,
client_sock=client_sock@entry=0x7ffcb598d000)at launch_backend.c:277
 
    #17 0x0000654521c0e7a9 in BackendStartup (client_sock=0x7ffcb598d000) at postmaster.c:3593
    #18 ServerLoop () at postmaster.c:1674
    #19 0x0000654521c104bd in PostmasterMain (argc=argc@entry=4, argv=argv@entry=0x654541aedea0) at postmaster.c:1372
    #20 0x000065452194ab33 in main (argc=4, argv=0x654541aedea0) at main.c:197

InitPostgres calls process_settings before InitializeSearchPath, and so
SearchPathCacheContext is null.  Not sure how to fix this because
InitPostgres clearly states this before calling InitializeSearchPath:

    /*
     * Initialize various default states that can't be set up until we've
     * selected the active user and gotten the right GUC settings.
     */

Maybe just don't use the cache in that case?  For example,
check_search_path uses the cache only if SearchPathCacheContext is
initialized.

-- 
Erik



pgsql-bugs by date:

Previous
From: Tom Lane
Date:
Subject: Re: Server crash when selecting from pg_cursors
Next
From: Erik Wienhold
Date:
Subject: Re: Error when setting default_text_search_config