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?
Best Answer
Your
vi
process is in “uninterruptable sleep” (stateD
), 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.