pmem / libpmemobj-cpp

C++ bindings & containers for libpmemobj

Home Page:https://pmem.io

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Failed opening pool: flock, Resource temporarily unavailable

xjqbest opened this issue · comments

I run the following code with pybind

     int my_id = 0;
     const int POOLSIZE = 1024 * 1024 * 64;
     const std::string LAYOUT = "concurrent_hash_map";
     try {
       std::string file = "./my_test/test_pmemobj_" + std::to_string(getpid()) + "_" + std::to_string(my_id);
       if (file_exists(file) != 0) {
         pop_ = pmem::obj::pool<root>::create(file, LAYOUT, POOLSIZE);
       } else {
         pop_ = pmem::obj::pool<root>::open(file, LAYOUT);
       }
     } catch (pmem::pool_error &e) {
         std::cerr << e.what() << std::endl;
         assert(false);
     }

I run two process with root user, and see files are created

image

but there are errors:


Failed opening pool: flock "./test_pmemobj_1076_0": Resource temporarily unavailable

Failed opening pool: flock "./test_pmemobj_1075_0": Resource temporarily unavailable

I am also wondering why the files are "----------" instead of "-rw-------"

Thanks for your help!

Hi,

As for the file mode - it's weird, by default, if mode is not given to create function, it should equal to DEFAULT_MODE = S_IWUSR | S_IRUSR. Please verify if these constants are available in sys/stat.h in your system. Your code creates file (on my Ubuntu 20.10) with rw access.
What OS are you running?

As for errors - when do you get these, exactly?

Also, it would be good to know on what filesystem you're running this code.

OK, thanks, I will check the file open mode. The filesystem is disk, I first compile and test my code in a docker which does not have aep, and after the test is ok, I will try running my code on aep machine.

I find that when I compile my c++ code to executable, and run it, the mode of file created is ok, and my code runs well. But when I use SWIG, my code is a .so file , and run my code through python, then the same error occurs as before.

this is my python env:

which python
/usr/bin/python
-----------------------------------------
/usr/bin/python --version
Python 3.6.8
-----------------------------------------
ll /usr/bin/python
lrwxrwxrwx 1 root root 16 Sep 27 12:30 /usr/bin/python -> /usr/bin/python3

this is my .so file:

-rwxr-xr-x  1 root root 391193384 Mar 17 11:44 my_test.so

the OS is centos, and the error occurs at pmem::obj::pool<root>::create

If the code works when compiled to executable I think this is some environmental issue. Could you show us the entire code (both c++ and python)?

Also, please clarify the filesystem which you are using. Is it ext4, tmpfs or something else?

Thanks! I will first check the filesystem, and then check my code again.

Thanks for your help ! I finally find the problem, it is because there are multi threads run the same code, and they create the same file name at same time, so I change my_id to static, and use mutex for my_id ++ for each thread to get its unique file name, and then the file mode is ok, as following:

image

👍 👍 Pmem is very useful, next I will try using hash map on it, to save memory, and observe the performance.

It's great to hear that! If you have any more comments, questions or observations please share with us.

OK, thanks!

I'll allow myself to close this issue, since the merit is solved.
Please contact us again in case you have more questions :)