[SERVER-22072] Unable to start service with error " ERROR: Cannot write pid file to /var/run/mongodb/mongod.pid: Success" Created: 06/Jan/16  Updated: 30/Jan/16  Resolved: 30/Jan/16

Status: Closed
Project: Core Server
Component/s: Admin
Affects Version/s: None
Fix Version/s: None

Type: Bug Priority: Major - P3
Reporter: Dharshan Rangegowda Assignee: Ramon Fernandez Marina
Resolution: Done Votes: 0
Labels: None
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified

Issue Links:
Related
is related to SERVER-22364 Fix confusing error message when pid ... Closed
Operating System: ALL
Sprint: Platforms F (01/29/16)
Participants:

 Description   

CentOS 6.x
mongodb 3.0.5

I started my service manually using "mongod -f /etc/mongod.conf". I think this messed up permissions.

However I reset permissions using "chown -R mongod:mongod /mongodb_data"

However after this I am unable to start the service anymore. It fails with error message
2016-01-06T08:20:19.867+0000 I CONTROL ***** SERVER RESTARTED *****
2016-01-06T08:20:19.882+0000 I CONTROL ERROR: Cannot write pid file to /var/run/mongodb/mongod.pid: Success

The pid file and director are present and are writeable by mongod



 Comments   
Comment by Support support [ 30/Jan/16 ]

Hi Ramon,

Unfortunately both these solutions dont fix the issue - so there might be some other root cause here.

Comment by Ramon Fernandez Marina [ 30/Jan/16 ]

One of our engineers was able to trigger this error message with a full filesystem, so in addition to checking permissions please make sure that there's sufficient space in the filesystem to start mongod.

We've opened SERVER-22364 to track the improvement of the error message for this particular case, feel free to vote for that ticket and to watch it for updates.

If you need additional assistance troubleshooting this node please post on the mongodb-user group.

Regards,
Ramón.

Comment by Support support [ 27/Jan/16 ]

Thanks. The file is owned by the mongod user - so its surprising there are permission issues.

Are there some commands I can run on the command line to verify this?

Comment by Ramon Fernandez Marina [ 27/Jan/16 ]

dharshanr@scalegrid.net, the odd error message may be happening because of an incorrect use of the errno value in the code that writes the pid file. We're investigating how to fix this – but while confusing, the error message does point to a permissions issue whereas the user running the mongod process can't write to to /var/run/mongodb/mongod.pid.

Comment by Dharshan Rangegowda [ 16/Jan/16 ]

Folks - any thoughts on how to debug further?

Comment by Dharshan Rangegowda [ 07/Jan/16 ]

Here you go

processManagement:
  fork: true
  pidFilePath: /var/run/mongodb/mongod.pid
systemLog:
  path: /var/log/mongodb/mongod.log
  logAppend: true
  destination: file
net:
  port: 27017
  ssl:
    allowInvalidHostnames: true
    allowInvalidCertificates: true
    PEMKeyFile: /etc/ssl/mongodb.pem
    mode: requireSSL
storage:
  journal:
    enabled: true
  engine: wiredTiger
  dbPath: /mongodb_data
  wiredTiger:
    collectionConfig:
      blockCompressor: none
security:
  keyFile: /var/lib/mongo/rskey
replication:
  replSetName: RS-ProductionV2-0

Comment by Ramon Fernandez Marina [ 07/Jan/16 ]

Can you please post your mongod.conf file? As pointed out by Amanpreet this looks like running mongod manually messed up permissions, but I agree the error message you're getting is confusing.

Comment by Dharshan Rangegowda [ 07/Jan/16 ]

I am using the default init scripts. I am starting the service using "service mongod start"

Comment by Amanpreet Singh [ 07/Jan/16 ]

That is the case if you use the default init scripts and run mongod as a service. In your case, use runuser or su to start the process as mongod user.

Comment by Dharshan Rangegowda [ 06/Jan/16 ]

I am just using the default setup by the mongo rpm file. I think it configures the mongo process to run as mongod user.

Comment by Amanpreet Singh [ 06/Jan/16 ]

Okay. mongod is the owner of pid file. But are you starting the process as mongod user? If not, try doing that.

Comment by Dharshan Rangegowda [ 06/Jan/16 ]

Hi,

That was the first thing I checked. Both /var/run/mongodb and the .pid file are owned by mongod.

drwxr-xr-x  2 mongod    mongod    4096 Jan  6 09:10 mongodb
-rw-r--r--  1 mongod    mongod       0 Jan  6 09:10 mongod.pid

I also deleted the folder and tried to restart but it did not work. Tried to restart the machine - that didn't make a difference. If it was a permissions issue wouldn't the error code say "permissions" instead of "success" ?

Comment by Amanpreet Singh [ 06/Jan/16 ]

My guess is only root user has write access to /var/run/mongodb/mongod.pid and you're not running mongod as root user.

Generated at Thu Feb 08 03:59:18 UTC 2024 using Jira 9.7.1#970001-sha1:2222b88b221c4928ef0de3161136cc90c8356a66.