[SERVER-20235] Upsert (via PHP) on non-existsing database - results in 'permission denied' (storage: WiredTiger) Created: 01/Sep/15  Updated: 10/Feb/16  Resolved: 02/Sep/15

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

Type: Bug Priority: Major - P3
Reporter: Radek Assignee: Sam Kleinman (Inactive)
Resolution: Cannot Reproduce Votes: 0
Labels: None
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified

Issue Links:
Related
is related to SERVER-22450 Mongodb sub-folders sometimes don't g... Closed
Operating System: ALL
Steps To Reproduce:

e.g.
php test.php

PHP mongodb driver: https://pecl.php.net/package/mongo (version. 1.6.10)

test.php:
---------------------------------
$dbName = 'test1';
$mongoDb = new MongoClient();
$collection = new MongoCollection($mongoDb->selectDB($dbName), 'a');
$collection->update(array('_id' => 1), array('_id' => 1, 'v'=>2), array('w' => 0, 'upsert' => true));
---------------------------------
result (php test.php):

ls -l /var/lib/mongodb-wt/
drw-r-xr-x 2 mongodb nogroup   4096 wrz  1 08:47 test1
^^^ no 'x' for owner (mongodb) !!

mongodb.log:

2015-09-01T08:47:09.380+0200 E STORAGE  [conn89324] WiredTiger (13) [1441090029:380500][21638:0x7f07958ee700], session.create: /var/lib/mongodb-wt/test1/
collection-5--7277287853652342963.wt: Permission denied
2015-09-01T08:47:09.387+0200 I -        [conn89324] Assertion: 8:13: Permission denied

/etc/mongod.conf:

storage:
  dbPath: /var/lib/mongodb-wt
  directoryPerDB: true
  engine: wiredTiger
  wiredTiger:
    engineConfig:
      cacheSizeGB: 4
  journal:
    enabled: true
systemLog:
  quiet: true
  destination: file
  path: /var/log/mongodb/mongodb.log
  logAppend: true
  timeStampFormat: iso8601-local
net:
  port: 27017
  wireObjectCheck : false
  unixDomainSocket:
    enabled : true
    filePermissions: 0777
  http:
    RESTInterfaceEnabled: true
    enabled: true

Participants:

 Description   

When upserting a document to non-existing database - mongo creates database folder with invalid permission (drw-r-xr-x mongodb nogroup), so it can not create files in this folder (sic!).

ls -la /var/lib/mongodb-wt/test1/
drw-r-xr-x  2 mongodb nogroup 4096 wrz  1 08:47 .
drwxr-xr-x 51 mongodb mongodb 4096 wrz  1 08:47 ..

e.g. mongodb.log: /var/lib/mongodb-wt/test1/
collection-5--7277287853652342963.wt: Permission denied



 Comments   
Comment by Sam Kleinman (Inactive) [ 02/Sep/15 ]

Thanks for your understanding and help with this, and sorry that we couldn't figure out what happened here more clearly.

Comment by Radek [ 02/Sep/15 ]

Well..
0. I've tried to reproduce this mis-behaviour on a cleaned mongodb instance (i've stopped mongod, removed all storage files and restarted), (un)fortunatelly - after these steps - I can no longer replicate the bug. So I'm affraid newither will you.
Regarding your questions:
1. Unfortunetely I can not replicate the issue on my other mongo instances.
2. I did NOT create the 'test1' directory myself. I did not modify dbpath directory (or any of its elements; exept for symlinks for journal and local database)
3. The existing directories/databases come from earlier usage and were succesfully created with mongodb 3.0.1 (I think)

So in these circumstances I think you sould simply close this ticket.

Comment by Sam Kleinman (Inactive) [ 01/Sep/15 ]

Thanks for this report. I'm going to try and reproduce this on my end, but I've done some digging into the code, and I while I work on this, I'd like to ask a few more questions about your set up:

  1. Could you provide logging from earlier in this process? The error message you sent appears in WiredTiger itself after the directory is already created, it would be useful to see if there was something in the log from before the appearance of the error.
  2. Can you confirm that you did not create the test1 or modify the permissions of the dbpath directory or any of its elements manually?
  3. There are a large number of existing directories that seem to have the correct permission: how were these data files created, and has anything changed in your deployment since you successfully created a database?

Thanks again for the report and for your help in chasing this issue down.

Regards,
sam

Comment by Radek [ 01/Sep/15 ]

Sure.

ls -la /var/lib/mongodb-wt
 
drwxr-xr-x 21 mongodb mongodb   4096 wrz  1 14:20 .
drwxr-xr-x 53 root    root      4096 sie 10 12:05 ..
lrwxrwxrwx  1 root    root        23 maj 22 08:16 journal -> /ssd/mongodb-wt/journal
lrwxrwxrwx  1 root    root        21 maj 22 08:16 local -> /ssd/mongodb-wt/local
-rw-r--r--  1 mongodb nogroup  36864 wrz  1 09:54 _mdb_catalog.wt
-rwxr-xr-x  1 mongodb nogroup      6 sie 10 12:06 mongod.lock
drwxr-xr-x  2 mongodb nogroup   4096 cze 18 12:37 optimizer
drwxr-xr-x  2 mongodb nogroup   4096 sie  4 09:03 seo-1508-absurd
drwxr-xr-x  2 mongodb nogroup   4096 sie  4 09:02 seo-1508-building
drwxr-xr-x  2 mongodb nogroup   4096 sie  4 09:02 seo-1508-city
drwxr-xr-x  2 mongodb nogroup   4096 sie  4 10:02 seo-1508-citycinema
drwxr-xr-x  2 mongodb nogroup   4096 sie  4 10:08 seo-1508-citymovies
drwxr-xr-x  2 mongodb nogroup   4096 sie  4 09:04 seo-1508-event
drwxr-xr-x  2 mongodb nogroup   4096 sie  4 09:28 seo-1508-impendings
drwxr-xr-x  2 mongodb nogroup   4096 sie  4 09:29 seo-1508-movieincity
drwxr-xr-x  2 mongodb nogroup   4096 sie  4 09:02 seo-1508-pcode
drwxr-xr-x  2 mongodb nogroup   4096 sie  4 09:02 seo-1508-poiCategory
drwxr-xr-x  2 mongodb nogroup   4096 sie  4 09:02 seo-1508-point
drwxr-xr-x  2 mongodb nogroup   4096 sie  4 09:02 seo-1508-region
drwxr-xr-x  2 mongodb nogroup   4096 sie  4 09:02 seo-1508-roadNews
drwxr-xr-x  2 mongodb nogroup   4096 sie  4 09:02 seo-1508-street
drwxr-xr-x  2 mongodb nogroup   4096 sie  4 09:13 seo-1508-traffic
drwxr-xr-x  2 mongodb nogroup   4096 sie  4 09:02 seo-1508-transit
drwxr-xr-x  2 mongodb nogroup   4096 sie  4 09:04 seo-1508-vcard
-rw-r--r--  1 mongodb nogroup  45056 wrz  1 09:54 sizeStorer.wt
-rw-r--r--  1 mongodb nogroup     95 maj 28 12:41 storage.bson
drw-r-xr-x  2 mongodb nogroup   4096 wrz  1 14:20 test1
-rw-r--r--  1 mongodb nogroup     46 maj 28 12:41 WiredTiger
-rw-r--r--  1 mongodb nogroup    495 maj 28 12:41 WiredTiger.basecfg
-rw-r--r--  1 mongodb nogroup     21 maj 28 12:41 WiredTiger.lock
-rw-r--r--  1 mongodb nogroup    894 wrz  1 09:54 WiredTiger.turtle
-rw-r--r--  1 mongodb nogroup 139264 wrz  1 09:54 WiredTiger.wt

'test1' is the new folder with illegal permissions.

Comment by Ramon Fernandez Marina [ 01/Sep/15 ]

Can you please send the output of:

ls -la /var/lib/mongodb-wt

?

Thanks,
Ramón

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