Re: [PATCH] initdb: do not exit after warn_on_mount_point

From: andrey(dot)arapov(at)nixaid(dot)com
To: "Tom Lane" <tgl(at)sss(dot)pgh(dot)pa(dot)us>
Cc: "PostgreSQL Hackers" <pgsql-hackers(at)lists(dot)postgresql(dot)org>
Subject: Re: [PATCH] initdb: do not exit after warn_on_mount_point
Date: 2022-09-10 19:14:59
Message-ID: 6b9b6017d0f13c257001478f474ef6fa@nixaid.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

Hi Tom,

I've updated the patch by adding the explanation behind and more comments. (please see the attachment)

Have slightly improved the logic so that it does not report an error
"directory \"%s\" exists but is not empty"
when it is only supposed to warn the user about the mountpoint, without exiting.

To me, my patch looks like a typo fix where exit(1) should not be called on the warn_on_mount_point(),
but only warn and continue as more people are mounting the device at `/var/lib/postgresql/data` (PGDATA) in the containerized world (K8s deployments, especially now in the Akash Network I am working for) for making sure their data persist.

As a workaround, we either have to `rmdir /var/lib/postgresql/data/lost+found` before running `docker-entrypoint.sh postgres` which in turn calls the `initdb`, or, alternatively we have to pass `PGDATA=/var/lib/postgresql/data/<something>` while mounting persistent storage over `/var/lib/postgresql/data` path so that it won't exit on the very first run.
To me, this in itself is an odd behavior, which led me to finding this typo (from my point of view) to which I've made this patch.

Please let me know if it makes sense or requires more information / explanation.

Kind regards,
Andrey Arapov

September 10, 2022 5:10 PM, "Tom Lane" <tgl(at)sss(dot)pgh(dot)pa(dot)us> wrote:

> andrey(dot)arapov(at)nixaid(dot)com writes:
>
>> please find my first patch for PostgreSQL is attached.
>
> You haven't explained why you think this would be a good
> change, or even a safe one.
>
> regards, tom lane

Attachment Content-Type Size
0001-initdb-do-not-exit-when-PGDATA-PGDATA-pg_wal-is-a-mo.patch application/octet-stream 2.7 KB

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Andres Freund 2022-09-10 19:15:33 Re: Splitting up guc.c
Previous Message Tom Lane 2022-09-10 19:04:59 Splitting up guc.c