Re: Postgres on macOS 10

2020-03-04 Thread John DeSoi


> On Mar 3, 2020, at 5:06 AM, Nick Renders  wrote:
> 
> In the system.log we see the following 2 lines over and over again, until a 
> user has logged in:
> 
>   Mar  3 09:37:19 postgrestest com.apple.xpc.launchd[1] 
> (com.edb.launchd.postgresql-12[319]): Service exited with abnormal code: 2
>   Mar  3 09:37:19 postgrestest com.apple.xpc.launchd[1] 
> (com.edb.launchd.postgresql-12): Service only ran for 0 seconds. Pushing 
> respawn out by 10 seconds.

To understand the issue, I think you need to look at the Postgres log and see 
if it gives a clue about why it did not start. The startup log might be 
different from the normal Postgres logs depending on how the launch daemon sets 
it up. I assume you will find that at /Library/LaunchDaemons/.

John DeSoi, Ph.D.





Re: Using unlogged tables for web sessions

2020-04-17 Thread John DeSoi



> On Apr 16, 2020, at 1:39 PM, Stephen Carboni  
> wrote:
> 
> I was wondering if anyone was using unlogged tables for website
> sessions in production. I'm interested if it breaks the prevailing
> opinion that you don't put sessions in PG.

Popular CMS systems like Drupal use the database for web sessions. Probably 
only logged tables unless you did some extra customization of the installation. 
I'm not aware of any issues with it performance or otherwise.

John DeSoi, Ph.D.






Re: Can I get some PostgreSQL developer feedback on these five general issues I have with PostgreSQL and its ecosystem?

2020-09-26 Thread John DeSoi


> On Sep 22, 2020, at 5:28 PM, tutilu...@tutanota.com wrote:
> 
> I hate the "wrong tool for the job" argument. It assumes that everyone has 
> infinite time, energy and brain capacity to learn endless redundant tools 
> just to "use the right tool for the job" rather than "use what you actually 
> know". I know PG. I don't know SQLite. They are very different. So obviously, 
> I want to use PG.


https://duckdb.org/docs/why_duckdb

Maybe this would provide something in between. I have not used it, but it 
sounds interesting. Based on SQLite engine and uses the Postgres SQL parser. 
Lots of built-in functions appear to be the same or very similar to Postgres.


John DeSoi, Ph.D.





libpq crashing on macOS during connection startup

2023-11-30 Thread John DeSoi
I have a macOS web server using Postgres that has been very stable until a 
month or two ago. If I restart the web server the problem seems to go away for 
a while, but starts happening again within days. I thought it was a PHP issue 
as discussed in the link below, but I just noticed in the crash report it seems 
to be something related to a call from libpq.   

https://github.com/shivammathur/homebrew-php/issues/1862


Any ideas or suggestions appreciated. 


John DeSoi, Ph.D.



-
Translated Report (Full Report Below)
-

Process:   httpd [54877]
Path:  /opt/homebrew/*/httpd
Identifier:httpd
Version:   ???
Code Type: ARM-64 (Native)
Parent Process:httpd [6040]
Responsible:   httpd [6040]
User ID:   502

Date/Time: 2023-11-30 07:06:00.0651 -0600
OS Version:macOS 12.7 (21G816)
Report Version:12
Anonymous UUID:750F146C-B2B5-BECA-EC21-1FEC0471D5AC


Time Awake Since Boot: 100 seconds

System Integrity Protection: enabled

Crashed Thread:0  Dispatch queue: com.apple.root.utility-qos

Exception Type:EXC_BAD_ACCESS (SIGSEGV)
Exception Codes:   KERN_INVALID_ADDRESS at 0x0110
Exception Codes:   0x0001, 0x0110
Exception Note:EXC_CORPSE_NOTIFY

VM Region Info: 0x110 is not in any region.  Bytes before following region: 
105553518919408
  REGION TYPESTART - END [ VSIZE] PRT/MAX 
SHRMOD  REGION DETAIL
  UNUSED SPACE AT START
--->  
  MALLOC_NANO (reserved)   60001800-60002000 [128.0M] rw-/rwx 
SM=NUL  ...(unallocated)

Application Specific Information:
*** multi-threaded process forked ***
crashed on child side of fork pre-exec


Kernel Triage:
VM - pmap_enter failed with resource shortage
VM - pmap_enter failed with resource shortage


Thread 0 Crashed::  Dispatch queue: com.apple.root.utility-qos
0   libdispatch.dylib  0x199dd825c 
_dispatch_apply_with_attr_f + 1136
1   libdispatch.dylib  0x199dd8234 
_dispatch_apply_with_attr_f + 1096
2   libdispatch.dylib  0x199dd847c dispatch_apply + 108
3   CoreFoundation 0x19a172a80 
__104-[CFPrefsSearchListSource 
synchronouslySendDaemonMessage:andAgentMessage:andDirectMessage:replyHandler:]_block_invoke.92
 + 132
4   CoreFoundation 0x19a007e8c 
CFPREFERENCES_IS_WAITING_FOR_SYSTEM_AND_USER_CFPREFSDS + 100
5   CoreFoundation 0x19a007ccc 
-[CFPrefsSearchListSource 
synchronouslySendDaemonMessage:andAgentMessage:andDirectMessage:replyHandler:] 
+ 232
6   CoreFoundation 0x19a00649c 
-[CFPrefsSearchListSource 
alreadylocked_generationCountFromListOfSources:count:] + 252
7   CoreFoundation 0x19a006178 
-[CFPrefsSearchListSource alreadylocked_getDictionary:] + 468
8   CoreFoundation 0x19a005cec 
-[CFPrefsSearchListSource alreadylocked_copyValueForKey:] + 172
9   CoreFoundation 0x19a005c20 -[CFPrefsSource 
copyValueForKey:] + 60
10  CoreFoundation 0x19a005bcc 
__76-[_CFXPreferences 
copyAppValueForKey:identifier:container:configurationURL:]_block_invoke + 44
11  CoreFoundation 0x199ffe9e0 
__108-[_CFXPreferences(SearchListAdditions) 
withSearchListForIdentifier:container:cloudConfigurationURL:perform:]_block_invoke
 + 384
12  CoreFoundation 0x19a173350 -[_CFXPreferences 
withSearchListForIdentifier:container:cloudConfigurationURL:perform:] + 384
13  CoreFoundation 0x199ffe394 -[_CFXPreferences 
copyAppValueForKey:identifier:container:configurationURL:] + 168
14  CoreFoundation 0x199ffe2b0 
_CFPreferencesCopyAppValueWithContainerAndConfiguration + 128
15  Heimdal0x1a5d4cb80 
init_context_from_config_file + 2732
16  Heimdal0x1a5d33944 
krb5_set_config_files + 392
17  Heimdal0x1a5d33284 
krb5_init_context_flags + 308
18  Heimdal0x1a5d33144 krb5_init_context + 
32
19  Kerberos   0x1a7fc32e8 mshim_ctx + 64
20  Kerberos   0x1a7fc16e4 
context_new_ccache_iterator + 92
21  libkrb5.3.3.dylib  0x1017accc8 
api_macos_ptcursor_next + 220
22  libkrb5.3.3.dylib  0x1017a9f0c 
krb5_cccol_cursor_next + 76
23  libkrb5.3.3.dylib  0x1017aa1f4 
krb5_cccol_have_content + 92
24  libgssapi_krb5.2.2.dylib   0x1016a1f58 acquire_cred_context 
+ 1668
25  libgssapi_krb5.2.2.dy

Re: libpq crashing on macOS during connection startup

2023-11-30 Thread John DeSoi


> On Nov 30, 2023, at 8:59 AM, Joe Conway  wrote:
> 
> Did you recently get an OpenSSL upgrade to v3.2.0? This is a shot in the 
> dark, but perhaps related to the discussion here?
> 
> https://www.postgresql.org/message-id/flat/CAN55FZ1eDDYsYaL7mv%2BoSLUij2h_u6hvD4Qmv-7PK7jkji0uyQ%40mail.gmail.com

No, this server is on openssl 3.1.4. But thanks for sending that, I'm about to 
setup a new server and I'm sure it will end up with the latest versions.

John DeSoi, Ph.D.






Re: libpq crashing on macOS during connection startup

2023-11-30 Thread John DeSoi


> On Nov 30, 2023, at 9:36 AM, Adrian Klaver  wrote:
> 
> What starts happening?

Random web process crashes when connecting to PostgreSQL.


> 
> Does the Postgres log show anything?

No.

> 
> Postgres version?
> 
> How was Postgres installed?


PostgreSQL 15.4 installed with Homebrew. 


John DeSoi, Ph.D.






Re: libpq crashing on macOS during connection startup

2023-11-30 Thread John DeSoi


> On Nov 30, 2023, at 10:21 AM, Adrian Klaver  wrote:
> 
> To be clear, at the times the Web processes crash there is are no traces in 
> the Postgres log of an issue on the Postgres side?
> 
> Is there evidence in the Postgres logs of what the Web process was doing just 
> before it crashed?


No entry in the Postgres log that I can see. The backtrace I posted in the 
original message was today at 7:06am. There is nothing in the Postgres log 
around that time except for some checkpoint messages. 

I think the backtrace shows that Postgres has just connected and is 
authenticating by calling Kerberos which calls Heimdal and then crashes in 
CoreFoundation. I also posted this issue on the Heimdal GitHub account.


John DeSoi, Ph.D.





Re: libpq crashing on macOS during connection startup

2023-11-30 Thread John DeSoi



> On Nov 30, 2023, at 2:07 PM, Tom Lane  wrote:
> 
> What troubles me about that stack trace is the references to Heimdal.
> We gave up supporting Heimdal (and v16 explicitly rejects building
> with it) because its support for Kerberos credentials was too
> incomplete and flaky.  So I'm inclined to guess that you are running
> into some Heimdal bug.  Try to rebuild libpq using MIT Kerberos
> and see if things get better.


I'm using v16 on my development machine and it is crashing on me at times with 
the same backtrace. Restarting the web server fixes it for a while for some 
reason. 

Is there a way to simply disable GSSAPI authentication? I could not find it.

The builds are from homebrew (https://brew.sh/). I'll have to see if there is a 
way for me to override build options.

The otool output below shows that Apple's Kerberos is being used and I assume 
by extension, their Heimdal library. The Heimdal project told me as much - 
Apple has a fork and would not pull from their project.

John DeSoi, Ph.D.




$ otool -L /usr/local/opt/postgresql@16/lib/libpq.5.dylib
/usr/local/opt/postgresql@16/lib/libpq.5.dylib:
/usr/local/opt/postgresql@16/lib/libpq.5.dylib (compatibility version 
5.0.0, current version 5.16.0)
/usr/local/opt/gettext/lib/libintl.8.dylib (compatibility version 
13.0.0, current version 13.0.0)
/usr/local/opt/openssl@3/lib/libssl.3.dylib (compatibility version 
3.0.0, current version 3.0.0)
/usr/local/opt/openssl@3/lib/libcrypto.3.dylib (compatibility version 
3.0.0, current version 3.0.0)
/usr/local/opt/krb5/lib/libgssapi_krb5.2.2.dylib (compatibility version 
2.0.0, current version 2.2.0)
/usr/lib/libSystem.B.dylib (compatibility version 1.0.0, current 
version 1319.100.3)
/System/Library/Frameworks/LDAP.framework/Versions/A/LDAP 
(compatibility version 1.0.0, current version 2.4.0)

$ otool -L /usr/local/opt/krb5/lib/libgssapi_krb5.2.2.dylib
/usr/local/opt/krb5/lib/libgssapi_krb5.2.2.dylib:
/usr/local/opt/krb5/lib/libgssapi_krb5.2.2.dylib (compatibility version 
2.0.0, current version 2.2.0)
@loader_path/libkrb5.3.3.dylib (compatibility version 3.0.0, current 
version 3.3.0)
@loader_path/libk5crypto.3.1.dylib (compatibility version 3.0.0, 
current version 3.1.0)
@loader_path/libcom_err.3.0.dylib (compatibility version 3.0.0, current 
version 3.0.0)
@loader_path/libkrb5support.1.1.dylib (compatibility version 1.0.0, 
current version 1.1.0)
/usr/lib/libresolv.9.dylib (compatibility version 1.0.0, current 
version 1.0.0)
/usr/lib/libSystem.B.dylib (compatibility version 1.0.0, current 
version 1319.100.3)

$ otool -L /usr/local/opt/krb5/lib/libkrb5.3.3.dylib
/usr/local/opt/krb5/lib/libkrb5.3.3.dylib:
/usr/local/opt/krb5/lib/libkrb5.3.3.dylib (compatibility version 3.0.0, 
current version 3.3.0)
@loader_path/libk5crypto.3.1.dylib (compatibility version 3.0.0, 
current version 3.1.0)
@loader_path/libcom_err.3.0.dylib (compatibility version 3.0.0, current 
version 3.0.0)
@loader_path/libkrb5support.1.1.dylib (compatibility version 1.0.0, 
current version 1.1.0)
/System/Library/Frameworks/Kerberos.framework/Versions/A/Kerberos 
(compatibility version 5.0.0, current version 6.0.0)
/usr/lib/libresolv.9.dylib (compatibility version 1.0.0, current 
version 1.0.0)
/usr/lib/libSystem.B.dylib (compatibility version 1.0.0, current 
version 1319.100.3)



Re: libpq crashing on macOS during connection startup

2023-12-01 Thread John DeSoi


> On Nov 30, 2023, at 7:53 PM, Tom Lane  wrote:
> 
> gssencmode=disable in your connection options; but that's a tad
> inconvenient probably.

Yes, the application uses PHP PDO to connect to PostgreSQL. I don't see any way 
to specify that in the connection options.


> Ugh, not only Heimdal but a very obsolete version thereof?  It borders
> on negligence for the homebrew PG package to be building against that.
> They should be pulling in homebrew's MIT Kerberos package and using
> that, if they want to enable GSSAPI.

I was looking at the homebrew source for PostgreSQL package to see if there was 
a way to customize the build options. I did not find one but saw the comment 
below. Apparently this is a known issue and it was suggested to use the MIT 
Kerberos package 4 years ago. Instead they just added this comment in 2020.

# GSSAPI provided by Kerberos.framework crashes when forked.
# See https://github.com/Homebrew/homebrew-core/issues/47494.


John DeSoi, Ph.D.



Re: libpq crashing on macOS during connection startup

2023-12-01 Thread John DeSoi



> On Dec 1, 2023, at 11:02 AM, Tom Lane  wrote:
> 
> I'd suggest filing a bug against Homebrew's krb5 package.
> Whatever this is, it seems pretty clear that it's not a
> Postgres bug.

Will do, thank you and everyone else for the help and feedback.

John DeSoi, Ph.D.






Re: libpq crashing on macOS during connection startup

2023-12-04 Thread John DeSoi


> On Nov 30, 2023, at 7:53 PM, Tom Lane  wrote:
> 
>> Is there a way to simply disable GSSAPI authentication? I could not find it.
> 
> gssencmode=disable in your connection options; but that's a tad
> inconvenient probably.


I discovered there is a PGGSSENCMODE environment variable. I set it to 
'disable' in the environment used to run the http server. Hopefully this will 
solve it.

https://www.postgresql.org/docs/current/libpq-envars.html


John DeSoi, Ph.D.