0

I edited a PostgreSQL config file:

vi /var/lib/pgsql/10/data/postgresql.conf

I didn't save it successfully then it created a .swp file.

Everytime I try to edit this file again, the terminal will stop without any aciton. I have to close the terminal.

I tried to stop the PostgreSQL process by root user:

sudo systemctl stop postgresql-10

Again, the terminal went to silent. Can't accept any input further more.

When I run:

sudo ls -la /var/lib/pgsql/10/data/

The same terminal stoped.

When I run:

sudo ls -la /var/lib/pgsql/10/

It works.

I don't know what happened in the data folder. I know the swp file exists there. But can't rm from that path now.

When I tried to edit the postgresql.conf file again, it shown:

E325: ATTENTION
Found a swap file by the name "~/10/data/.postgresql.conf.swp"
          owned by: postgres   dated: Thu Feb 27 17:57:51 2020
         file name: ~postgres/10/data/postgresql.conf
          modified: YES
         user name: postgres   host name: server
        process ID: 25896 (still running)
While opening file "/var/lib/pgsql/10/data/postgresql.conf"
             dated: Thu Feb 27 17:57:57 2020
      NEWER than swap file!

(1) Another program may be editing the same file.  If this is the case,
    be careful not to end up with two different instances of the same
    file when making changes.  Quit, or continue with caution.
(2) An edit session for this file crashed.
    If this is the case, use ":recover" or "vim -r /var/lib/pgsql/10/data/postgresql.conf"
    to recover the changes (see ":help recovery").
    If you did this already, delete the swap file "/var/lib/pgsql/10/data/.postgresql.conf.swp"
    to avoid this message.

I used this way killed that process number:

sudo kill -9 25896

Then can list the files under /var/lib/pgsql/10/data/ path.

But when tried to edit the postgresql.conf again, it stoped again!

I close the terminal and login to the server, did these things. They can't be deleted.

[user@server ~]$ ps aux | grep postgresql
postgres 12569  0.0  0.0 126476  1920 ?        D    09:20   0:00 vi /var/lib/pgsql/10/data/postgresql.conf
postgres 25896  0.0  0.0 126416  2156 ?        D    Feb27   0:00 vi /var/lib/pgsql/10/data/postgresql.conf
postgres 26080  0.0  0.0 126320  1856 ?        D    Feb27   0:00 vi /var/lib/pgsql/10/data/postgresql.conf
postgres 26542  0.0  0.0 126476  1916 ?        D    13:35   0:00 vi /var/lib/pgsql/10/data/postgresql.conf
postgres 26741  0.0  0.0 126472  1832 ?        D    13:37   0:00 vi /var/lib/pgsql/10/data/postgresql.conf
root     26924  0.0  0.0 241036  4552 ?        S    13:39   0:00 sudo rm /var/lib/pgsql/10/data/postgresql.conf
root     26926  0.4  0.0 107984   640 ?        D    13:39   0:00 rm /var/lib/pgsql/10/data/postgresql.conf
postgres 27027  0.0  0.0 126332  1828 ?        D    13:40   0:00 vi /var/lib/pgsql/10/data/postgresql.conf
user     27085  0.0  0.0 112684  1000 pts/14   S+   13:40   0:00 grep --color=auto postgresql
[user@server ~]$ sudo kill -9 12569
[user@server ~]$ sudo kill -9 25896
[user@server ~]$ sudo kill -9 26080
[user@server ~]$ sudo kill -9 26542
[user@server ~]$ sudo kill -9 26741
[user@server ~]$ sudo kill -9 26924
[user@server ~]$ sudo kill -9 26926
[user@server ~]$ sudo kill -9 27027
[user@server ~]$ ps aux | grep postgresql
postgres 12569  0.0  0.0 126476  1920 ?        D    09:20   0:00 vi /var/lib/pgsql/10/data/postgresql.conf
postgres 25896  0.0  0.0 126416  2156 ?        D    Feb27   0:00 vi /var/lib/pgsql/10/data/postgresql.conf
postgres 26080  0.0  0.0 126320  1856 ?        D    Feb27   0:00 vi /var/lib/pgsql/10/data/postgresql.conf
postgres 26542  0.0  0.0 126476  1916 ?        D    13:35   0:00 vi /var/lib/pgsql/10/data/postgresql.conf
postgres 26741  0.0  0.0 126472  1832 ?        D    13:37   0:00 vi /var/lib/pgsql/10/data/postgresql.conf
root     26926  0.4  0.0 107984   640 ?        D    13:39   0:00 rm /var/lib/pgsql/10/data/postgresql.conf
postgres 27027  0.0  0.0 126332  1828 ?        D    13:40   0:00 vi /var/lib/pgsql/10/data/postgresql.conf
user     27155  0.0  0.0 112684   996 pts/14   S+   13:41   0:00 grep --color=auto postgresql

What's the reason? How to fix it?

5
  • sudo kill -9 postmaster_process_no? – Vérace Feb 28 '20 at 4:01
  • @Vérace Yes, I tried. I added some detailed to the question. – rawmain Feb 28 '20 at 4:50
  • This one has me puzzled root 26926 0.4 0.0 107984 640 ? D 13:39 0:00 rm /var/lib/pgsql/10/data/postgresql.conf - why is a file rm process enduring over several seconds - the time it took you to type all those kills? Have you tried the dreaded reboot? Can you? Is the server still responding to queries? – Vérace Feb 28 '20 at 4:57
  • @Vérace I don't know the reason you asked. When I reboot system, tried to login again, can't login any more. ssh_exchange_identification: Connection closed by remote host . I created the instance by OpenStack, even from its console, can't login to the system:( – rawmain Feb 28 '20 at 5:45
  • I don't know the reason you asked. Well, when a system goes wonky and even root can't kill things (zombies), normally a reboot is the way to go - unless a reboot is impossible. Is the OpenStack setup yours or is it remote? Restore from backup? – Vérace Feb 28 '20 at 6:33
2

Your vi process is in “uninterruptable sleep” (state D), that's why you cannot kill it.

That is usually a sign that the I/O system has a problem, for example a hard NFS mount that has network problems.

There is nothing you can do except fix the underlying problem. You can reboot the machine, but if it is a hard, foreground NFS mount, booting will get stuck when the filesystems are mounted.

Using NFS with PostgreSQL is considered dangerous by many people because of weaknesses in Linux' NFS implementation.

1
  • Thank you very much. I reboot the system then it can't been accessed again. I just installed PostgreSQL on one VM which created by OpenStack. I think it isn't using NFS now. – rawmain Feb 28 '20 at 7:55

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.