PostgresSQL: could not stat directory "base/<db_oid>": Unknown error - windows

I am getting error in starting PostgreSQL server after a machine restart on windows server 2019.
This server has a multiple databases and in logs it is showing error for one of the database may be corrupted.
I tried restart server few times, but it it is getting shut down after some time. How can I make server up again with other databases running?
2022-04-20 07:32:49.843 PDT [3720] LOG: starting PostgreSQL 13.3, compiled by Visual C++ build 1914, 64-bit
2022-04-20 07:32:49.844 PDT [3720] LOG: listening on IPv6 address "::", port 5432
2022-04-20 07:32:49.844 PDT [3720] LOG: listening on IPv4 address "0.0.0.0", port 5432
2022-04-20 07:32:57.949 PDT [6600] LOG: database system was interrupted while in recovery at 2022-04-20 06:29:00 PDT
2022-04-20 07:32:57.949 PDT [6600] HINT: This probably means that some data is corrupted and you will have to use the last backup for recovery.
2022-04-20 07:34:29.599 PDT [852] FATAL: the database system is starting up
2022-04-20 07:44:04.349 PDT [2480] FATAL: the database system is starting up
2022-04-20 07:52:28.107 PDT [4800] FATAL: the database system is starting up
2022-04-20 08:09:30.847 PDT [1872] FATAL: the database system is starting up
2022-04-20 08:21:41.884 PDT [6600] LOG: could not stat file "./base/22504705": Unknown error
2022-04-20 08:21:47.121 PDT [6600] LOG: database system was not properly shut down; automatic recovery in progress
2022-04-20 08:22:01.957 PDT [6600] LOG: redo starts at 22E/5419D678 2022-04-20 08:22:01.994 PDT [6600] FATAL: could not stat directory "base/22504705": Unknown error
2022-04-20 08:22:01.994 PDT [6600] CONTEXT: WAL redo at 22E/5422EDD8 for Heap/LOCK: off 3: xid 26378859: flags 0x00 LOCK_ONLY KEYSHR_LOCK
2022-04-20 08:22:02.000 PDT [3720] LOG: startup process (PID 6600) exited with exit code 1
2022-04-20 08:22:02.000 PDT [3720] LOG: aborting startup due to startup process failure
2022-04-20 08:22:02.085 PDT [3720] LOG: database system is shut down
logs

Related

Why GORM hangs after doing Save

Was trying to get an item from db, updates it and save it back to db using GORM. but the process hangs after doing the save.
I also tried to wrap these commands in a transaction, but still see the process hangs at save.
However I noticed if I just do "First" to get the item and "Save" to save back the item, the process completes successfully.
This really puzzles me because apparently in the GORM documentation, the example of an update is exactly what I am trying to achieve here.
Example in doc
db.First(&user)
user.Name = "jinzhu 2"
user.Age = 100
db.Save(&user)
My code
type Item struct {
PK int `json:"-" gorm:"index;primary_key"`
ID string `json:"id" gorm:"index" external_reference_key:"true"`
MEMO string `json:"MEMO"`
}
func main() {
db, err := gorm.Open("postgres", "host=localHost port=5432 user=postgres password=5206 dbname=item sslmode=disable")
if err != nil {
panic(err)
}
db.LogMode(true)
item := Item{}
db.First(&item) //Gets the item
item.MEMO = "[hpapaapodfiso]" //Change the field
db.Save(&item) //Save back to db
fmt.Printf("%v",item) //never executed, process stops at Save
}
Could anyone explain to me what made a difference? And what caused the process to stop/hang?
Really appreciated.
Update with the postgres log:
2019-06-22 15:39:07 PDT LOG: database system is ready to accept connections
2019-06-22 15:39:08 PDT LOG: autovacuum launcher started
2019-06-22 15:40:08 PDT FATAL: canceling authentication due to timeout
2019-06-22 15:49:23 PDT LOG: could not receive data from client: No connection could be made because the target machine actively refused it.
2019-06-22 15:53:22 PDT LOG: could not receive data from client: No connection could be made because the target machine actively refused it.
2019-06-22 15:53:31 PDT LOG: could not receive data from client: No connection could be made because the target machine actively refused it.
2019-06-22 15:53:46 PDT LOG: could not receive data from client: No connection could be made because the target machine actively refused it.
2019-06-22 16:05:42 PDT ERROR: role "username" does not exist
2019-06-22 16:05:42 PDT STATEMENT: REVOKE CONNECT ON DATABASE triggers FROM PUBLIC, username;
2019-06-22 16:06:14 PDT FATAL: terminating connection due to administrator command
2019-06-22 16:06:14 PDT FATAL: terminating connection due to administrator command
2019-06-22 16:06:14 PDT LOG: could not send data to client: No connection could be made because the target machine actively refused it.
2019-06-22 16:06:14 PDT FATAL: terminating connection due to administrator command
2019-06-22 16:06:14 PDT LOG: could not send data to client: No connection could be made because the target machine actively refused it.
2019-06-22 16:06:14 PDT FATAL: terminating connection due to administrator command
2019-06-22 16:06:14 PDT LOG: could not send data to client: No connection could be made because the target machine actively refused it.
2019-06-22 16:06:14 PDT LOG: could not send data to client: No connection could be made because the target machine actively refused it.

FreeSwitch Start Gives this Error: ==>freeswitch.service failed. See 'systemctl status freeswitch.service' and 'journalctl -xn' for details

When I try to start Freeswitch using bellow command :
/etc/init.d/freeswitch
It gives errors:-
[....] Starting freeswitch (via systemctl): freeswitch.serviceJob for
freeswitch.service failed. See 'systemctl status
freeswitch.service' and 'journalctl -xn' for details. failed!
Then I run this systemctl status freeswitch.service command that time it gives me this error:
● freeswitch.service - freeswitch Loaded: loaded
(/lib/systemd/system/freeswitch.service; enabled) Active: failed
(Result: start-limit) since Tue 2016-03-29 00:52:08 EDT; 8s ago
Process: 25997 ExecStart=/usr/bin/freeswitch -u freeswitch -g
freeswitch -ncwait $DAEMON_OPTS (code=exited, status=1/FAILURE)
Mar 29 00:52:07 systemd[1]: Failed to start freeswitch. Mar 29
00:52:07 systemd[1]: Unit freeswitch.service entered failed state.
Mar 29 00:52:08 systemd[1]: freeswitch.service start request repeated
too quickly, refusing to start. Mar 29 00:52:08 systemd[1]: Failed to
start freeswitch. Mar 29 00:52:08 media03 systemd[1]: Unit
freeswitch.service entered failed state.
Then I run journalctl -xn this command it gives me this error:
-- Logs begin at Tue 2016-03-22 15:12:38 EDT, end at Tue 2016-03-29 01:17:01 EDT. -- Mar 29 01:05:54 freeswitch[26066]: FreeSWITCH[26066]
Error starting system! pid:26067 Mar 29 01:05:54 systemd[1]:
freeswitch.service: control process exited, code=exited status=1 Mar
29 01:05:54 systemd[1]: Failed to start freeswitch.
-- Subject: Unit freeswitch.service has failed
-- Defined-By: systemd
-- Unit freeswitch.service has failed.
-- The result is failed. Mar 29 01:05:54 systemd[1]: Unit freeswitch.service entered failed state. Mar 29 01:17:01 CRON[26073]:
pam_unix(cron:session): session opened for user root by (uid=0) Mar 29
01:17:01 CRON[26074]: (root) CMD ( cd / && run-parts --report
/etc/cron.hourly) Mar 29 01:17:01 CRON[26073]:
pam_unix(cron:session): session closed for user root
Freeswitch.log
2016-03-18 13:13:16.027486 [NOTICE] switch_loadable_module.c:1183 Deleting File Format 'ul'
2016-03-18 13:13:16.027486 [NOTICE] switch_loadable_module.c:1183 Deleting File Format 'ulaw'
2016-03-18 13:13:16.027486 [NOTICE] switch_loadable_module.c:1183 Deleting File Format 'al'
2016-03-18 13:13:16.027486 [NOTICE] switch_loadable_module.c:1183 Deleting File Format 'alaw'
2016-03-18 13:13:16.027486 [NOTICE] switch_loadable_module.c:1183 Deleting File Format 'adpcm'
2016-03-18 13:13:16.027486 [NOTICE] switch_loadable_module.c:1183 Deleting File Format 'vox'
2016-03-18 13:13:16.027486 [CONSOLE] switch_loadable_module.c:2008 Stopping: mod_sndfile
2016-03-18 13:13:16.027486 [DEBUG] switch_loadable_module.c:1330 Write lock interface 'en' to wait for existing references.
2016-03-18 13:13:16.027486 [NOTICE] switch_loadable_module.c:1338 Deleting Say interface 'en'
2016-03-18 13:13:16.027486 [CONSOLE] switch_loadable_module.c:2011 mod_say_en has no shutdown routine
This problem is related to your init script is not working properly.
so try below
/usr/local/freeswitch/bin/freeswitch
If still problem exist just try to killall freeswitch processes.
Then again start the freeswitch

Slony sync to 14 slaves, 13 slave works great, but 1 slave slow

I setup Slony on my 15 machines, all slon --version is 2.2.2, I download source code and compile the slon and slonik by myself.
1 Master and 14 Slaves, the slaves are located at diff office and connection are all via internet
13 slaves works great, synced almost in no time.
1 slave behave wired, this wired slave can sync with Master but seems delay for hours
for example, one tabled named "accounts", all other slaves are synced, this wired slave is not until 30mins~3hours later.
I know there is a parameter slon -l lag interval, but I do not use the lag parameter
and iostate, htop, are seems normal.
I found below WARNING message and google this message but in vain, no helpful
05/09 15:37:03 ubuntu#slave:/var/log/postgresql$ sudo tail postgresql-9.1-main.log
2014-05-09 15:30:19 CST WARNING: pgstat wait timeout
2014-05-09 15:30:35 CST WARNING: pgstat wait timeout
2014-05-09 15:30:39 CST WARNING: pgstat wait timeout
2014-05-09 15:34:08 CST WARNING: pgstat wait timeout
2014-05-09 15:35:06 CST WARNING: pgstat wait timeout
2014-05-09 15:35:17 CST WARNING: pgstat wait timeout
2014-05-09 15:35:22 CST WARNING: pgstat wait timeout
2014-05-09 15:35:42 CST WARNING: pgstat wait timeout
2014-05-09 15:36:02 CST WARNING: pgstat wait timeout
2014-05-09 15:36:42 CST WARNING: pgstat wait timeout
Is there any thing I can check for this wired slave ?

Mongodb shell mongo: Only one usage of each socket address (protocol/network address/port) is normally permitted. for socket: 0.0.0.0:27017

It was fine 2 days ago, Now mongod does not work. Even echo ps -A | grep mongo printed nothing, yet it warns about error: "Only one usage of each socket address". How to kill that? I have also tried with different random port. How can they fail as well?
D:\mongodb-win32-x86_64-2.2.3\bin>mongod
mongod --help for help and startup options
Sun Mar 03 18:10:03 [initandlisten] MongoDB starting : pid=6292 port=27017 dbpat
h=\data\db\ 64-bit host=Sadaf
Sun Mar 03 18:10:03 [initandlisten] db version v2.2.3, pdfile version 4.5
Sun Mar 03 18:10:03 [initandlisten] git version: f570771a5d8a3846eb7586eaffcf4c2
f4a96bf08
Sun Mar 03 18:10:03 [initandlisten] build info: windows sys.getwindowsversion(ma
jor=6, minor=1, build=7601, platform=2, service_pack='Service Pack 1') BOOST_LIB
_VERSION=1_49
Sun Mar 03 18:10:03 [initandlisten] options: {}
Sun Mar 03 18:10:03 [initandlisten] journal dir=/data/db/journal
Sun Mar 03 18:10:03 [initandlisten] recover : no journal files present, no recov
ery needed
Sun Mar 03 18:10:04 [initandlisten] ERROR: listen(): bind() failed errno:10048 O
nly one usage of each socket address (protocol/network address/port) is normally
permitted. for socket: 0.0.0.0:27017
Sun Mar 03 18:10:04 [websvr] ERROR: listen(): bind() failed errno:10048 Only one
usage of each socket address (protocol/network address/port) is normally permit
ted. for socket: 0.0.0.0:28017
Sun Mar 03 18:10:04 [initandlisten] now exiting
Sun Mar 03 18:10:04 dbexit:
Sun Mar 03 18:10:04 [initandlisten] shutdown: going to close listening sockets..
.
Sun Mar 03 18:10:04 [initandlisten] shutdown: going to flush diaglog...
Sun Mar 03 18:10:04 [initandlisten] shutdown: going to close sockets...
Sun Mar 03 18:10:04 [initandlisten] shutdown: waiting for fs preallocator...
Sun Mar 03 18:10:04 [initandlisten] shutdown: lock for final commit...
Sun Mar 03 18:10:04 [initandlisten] shutdown: final commit...
Sun Mar 03 18:10:04 [initandlisten] shutdown: closing all files...
Sun Mar 03 18:10:04 [initandlisten] closeAllFiles() finished
Sun Mar 03 18:10:04 [initandlisten] journalCleanup...
Sun Mar 03 18:10:04 [initandlisten] removeJournalFiles
Sun Mar 03 18:10:04 [initandlisten] shutdown: removing fs lock...
Sun Mar 03 18:10:04 dbexit: really exiting now
D:\mongodb-win32-x86_64-2.2.3\bin>echo ps -A | grep mongo
D:\mongodb-win32-x86_64-2.2.3\bin>
In the command prompt type the following command
netstat -a -n -o | find "27017"
This will list all processes which are using port "27017" along with the PID.
Locate the PID using "27017".
For example if the PID is 10580, to kill it
taskkill /f /pid 10580
Now start mongo.
Hope this helps.
try to start mongo on a different port: http://docs.mongodb.org/manual/reference/mongod/#cmdoption-mongod--port
to be sure what port you can use, execute the command Sriukanth Venugopalan mentioned, it will list the current ports being used.
Regards,
Moacy
Open command prompt in Administrator mode
run net stop MongoDB

Mongodb takes 3 minutes to connect

Just reinstalled Mongodb on my mac (fresh install of mountain lion 10.8) and now my apps are taking ~3 mins to connect.
I put together a simple node script to test this:
var start = (new Date()).getTime();
var mongoose = require('mongoose');
var db = mongoose.connect('mongodb://localhost/passport-mongox',function(err){
var stop = (new Date()).getTime();
console.log('Took this long: ',(stop-start) / 1000 );
});
Both times were 175.273 and 175.316 seconds.
When I connect to an external, hosted mongodb it connects in less than a second,
Any idea why this would happen? Here is my mongo.log:
Fri Feb 1 12:43:25 [initandlisten] MongoDB starting : pid=2262 port=27017 dbpath=/usr/local/var/mongodb 64-bit host=w
Fri Feb 1 12:43:25 [initandlisten] db version v2.2.2, pdfile version 4.5
Fri Feb 1 12:43:25 [initandlisten] git version: d1b43b61a5308c4ad0679d34b262c5af9d664267
Fri Feb 1 12:43:25 [initandlisten] build info: Darwin bs-osx-106-x86-64-1.local 10.8.0 Darwin Kernel Version 10.8.0: Tue Jun 7 16:33:36 PDT 2011; root:xnu-1504.15.3~1/RELEASE_I386 i386 BOOST_LIB_VERSION=1_49
Fri Feb 1 12:43:25 [initandlisten] options: { bind_ip: "127.0.0.1", config: "/usr/local/etc/mongod.conf", dbpath: "/usr/local/var/mongodb", logappend: "true", logpath: "/usr/local/var/log/mongodb/mongo.log" }
Fri Feb 1 12:43:25 [initandlisten] journal dir=/usr/local/var/mongodb/journal
Fri Feb 1 12:43:25 [initandlisten] recover : no journal files present, no recovery needed
Fri Feb 1 12:43:26 [websvr] admin web console waiting for connections on port 28017
Fri Feb 1 12:43:26 [initandlisten] waiting for connections on port 27017
Fri Feb 1 12:44:05 [initandlisten] connection accepted from 127.0.0.1:52137 #1 (1 connection now open)
Fri Feb 1 12:44:40 [initandlisten] connection accepted from 127.0.0.1:52152 #2 (2 connections now open)
Fri Feb 1 12:45:15 [initandlisten] connection accepted from 127.0.0.1:52201 #3 (3 connections now open)
Fri Feb 1 12:45:50 [initandlisten] connection accepted from 127.0.0.1:52298 #4 (4 connections now open)
Fri Feb 1 12:46:25 [initandlisten] connection accepted from 127.0.0.1:52325 #5 (5 connections now open)
Fri Feb 1 12:51:26 [conn5] end connection 127.0.0.1:52325 (4 connections now open)
Fri Feb 1 12:51:26 [conn3] end connection 127.0.0.1:52201 (4 connections now open)
Fri Feb 1 12:51:26 [conn4] end connection 127.0.0.1:52298 (4 connections now open)
Fri Feb 1 12:51:26 [conn1] end connection 127.0.0.1:52137 (4 connections now open)
Fri Feb 1 12:51:26 [conn2] end connection 127.0.0.1:52152 (4 connections now open)
Answer from mongoose.js
Cause:
The underlying MongoDB driver defaults to looking for IPv6 addresses,
so the most likely cause is that your localhost DNS mapping isn't configured to handle IPv6.
Solution :
Use 127.0.0.1 instead of localhost or use the family option as shown in the connection docs.
mongoose.connect(url, {family:4}, function(err, connection) {
connection.db(your_db_name);
});
So the answer came from #AdamMeghji on twitter.
My hosts file has always looked like this:
127.0.0.1 localhost
127.0.0.1 test.com
127.0.0.1 wes.dev
I switched that to:
127.0.0.1 localhost test.com wes.dev
and connections went back to 0.015 seconds.

Resources