Skip to content
This repository has been archived by the owner on Mar 22, 2023. It is now read-only.

Add create_if_missing option to config #576

Closed
karczex opened this issue Jan 24, 2020 · 3 comments · Fixed by #944
Closed

Add create_if_missing option to config #576

karczex opened this issue Jan 24, 2020 · 3 comments · Fixed by #944
Assignees

Comments

@karczex
Copy link

karczex commented Jan 24, 2020

It would be useful to add to config option to create pool if not exists, or just open if exists. Let's name it 'soft_create' or 'create_if_not_exists'.
Currently if user is able to create pool due to OS configuration, he cannot just read config from file and apply it . Instead he have to check if file exists and modify config accordingly, like in this python snippet:

if not os.path.exists(config['path']):
    config[force_create]  = 1
@karczex karczex added new need to be triaged Type: Feature labels Jan 24, 2020
@igchor
Copy link
Contributor

igchor commented Jan 24, 2020

If you need to have this kind of logic in your app then your code snippet is exactly how it should be handled. We cannot do this in pmemkv because path can be anything - /dev/dax (always exists), path to a file or path to a poolset. To have this feature we would need obj support.

@igchor igchor added wontfix and removed new need to be triaged labels Feb 3, 2020
@karczex
Copy link
Author

karczex commented Oct 14, 2020

rocksdb implements create_if_missing option:

#include <assert>
#include "rocksdb/db.h"

rocksdb::DB* db;
rocksdb::Options options;
options.create_if_missing = true;
rocksdb::Status status =
  rocksdb::DB::Open(options, "/tmp/testdb", &db);

snippet from: https://rocksdb.org/docs/getting-started.html

@igchor
Copy link
Contributor

igchor commented Jan 15, 2021

Ok, we should add create_if_missing option which can be implemented as:

int err = pmemobj_create()
if (err != 0) return pmemobj_open()

We can also create an error_if_exists alias for force_create to be consistent with rocksDB.

config.put_force_create() can be depracted (we'd replace it with config.put_error_if_exists().

@igchor igchor added new need to be triaged and removed wontfix labels Jan 18, 2021
@lukaszstolarczuk lukaszstolarczuk removed the new need to be triaged label Feb 16, 2021
@igchor igchor changed the title Add soft_create option to config Add create_if_missing option to config Feb 16, 2021
@lukaszstolarczuk lukaszstolarczuk self-assigned this Feb 19, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants