Re: dropdb --force - Mailing list pgsql-hackers

From Ryan Lambert
Subject Re: dropdb --force
Date
Msg-id CAN-V+g_3YRqjs1jZc1b-0_VhTnzeAHX=Ouk32v18RHqrm6Y3xg@mail.gmail.com
Whole thread Raw
In response to Re: dropdb --force  (Filip Rembiałkowski <filip.rembialkowski@gmail.com>)
List pgsql-hackers
Hello,
This is a feature I have wanted for a long time, thank you for your work on this.
The latest patch [1] applied cleanly for me.  In dbcommands.c the comment
references a 5 second delay, I don't see where that happens, am I missing something?

I tested both the dropdb program and the in database commands.  Without FORCE I get
the expected error message about active connections.

    postgres=# DROP DATABASE testdb;
    ERROR:  source database "testdb" is being accessed by other users
    DETAIL:  There is 1 other session using the database.

With FORCE the database drops cleanly.

     postgres=# DROP DATABASE testdb FORCE;
     DROP DATABASE

The active connections get terminated as expected.  Thanks,


Ryan Lambert
RustProof Labs


On Sun, Mar 10, 2019 at 12:54 PM Filip Rembiałkowski <filip.rembialkowski@gmail.com> wrote:
Thank you. Updated patch attached.

On Sat, Mar 9, 2019 at 2:53 AM Thomas Munro <thomas.munro@gmail.com> wrote:
>
> On Wed, Mar 6, 2019 at 1:39 PM Filip Rembiałkowski
> <filip.rembialkowski@gmail.com> wrote:
> > Here is Pavel's patch rebased to master branch, added the dropdb
> > --force option, a test case & documentation.
>
> Hello,
>
> cfbot.cputube.org says this fails on Windows, due to a missing semicolon here:
>
> #ifdef HAVE_SETSID
> kill(-(proc->pid), SIGTERM);
> #else
> kill(proc->pid, SIGTERM)
> #endif
>
> The test case failed on Linux, I didn't check why exactly:
>
> Test Summary Report
> -------------------
> t/050_dropdb.pl (Wstat: 65280 Tests: 13 Failed: 2)
> Failed tests: 12-13
> Non-zero exit status: 255
> Parse errors: Bad plan. You planned 11 tests but ran 13.
>
> +/* Time to sleep after isuing SIGTERM to backends */
> +#define TERMINATE_SLEEP_TIME 1
>
> s/isuing/issuing/
>
> But, hmm, this macro doesn't actually seem to be used in the patch.
> Wait, is that because the retry loop forgot to actually include the
> sleep?
>
> +        /* without "force" flag raise exception immediately, or after
> 5 minutes */
>
> Normally we call it an "error", not an "exception".
>
> --
> Thomas Munro
> https://enterprisedb.com

pgsql-hackers by date:

Previous
From: Tomas Vondra
Date:
Subject: Re: patch to allow disable of WAL recycling
Next
From: Andres Freund
Date:
Subject: Re: dropdb --force