Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Avoid inconsistencies due to multiple profiles using the same database #182

Closed
aiida-bot opened this issue Apr 1, 2016 · 8 comments
Closed

Comments

@aiida-bot
Copy link

Originally reported by: Giovanni Pizzi (Bitbucket: pizzi, GitHub: giovannipizzi)


The AiiDA guide tells to use a DB name 'aiidadb'. If two people work on the same workstation, and just follow the instructions, they will end up using the same DB, but with independent repository folders. This will create many problems when they do a query and want to access data from the other user (it will show as if the repository folder is missing in their repo).

We need a way to check that the two are consistent, and do this check at the right times (i.e., we also need to avoid to do it at every load_dbenv(), that will just slow down the procedure).


@aiida-bot
Copy link
Author

Original comment by Giovanni Pizzi (Bitbucket: pizzi, GitHub: giovannipizzi):


Suggested solution:

  1. Have an entry in the DbSetting table, with key database_uuid and value a uuid. At install time, this is created if the setting does not exist, otherwise the value is unchanged.

  2. In the repository folder, create a single file (e.g. database_uuid.json) containing the same UUID. This is created, if not existing, at install time, after step 1, containing the UUID of the DB, otherwise it is not changed.

  3. At install time, after step 2, read the DbSetting entry and the file in the repository, and stop with a ConfigurationError if the two don't match.

Additional considerations:

  • I think that doing it at install time should be enough (i.e., no need to do it every time one loads the dbenv). However, let's provide a way to check consistency afterwards, calling the same function used at step 3 (e.g., verdi devel consistencycheck, that can in the future be expanded with other checks.

  • If we access DbSetting with a backend-independent method, probably all the logic can stay in the common implementation.

  • In order to avoid issues in the future, change the guide to suggest a database name that contains the profile name (and probably also the linux username). Also, change verdi install to provide a default name customised as described above. Similarly, also the suggested DB user should change from just aiida to aiida_LINUXUSER or something like this (both in the documentation and in the default value provided).

@aiida-bot
Copy link
Author

Original comment by Giovanni Pizzi (Bitbucket: pizzi, GitHub: giovannipizzi):


Please, comment saying if you approve the suggested solution, or if you think there are issues that could arise.

@DropD
Copy link
Contributor

DropD commented Dec 18, 2017

In light of the movement away from multi user mode, a new suggested solution should be considered:

  • in aiida.common.setup: in create_config_noninteractiveas well ascreate_configuration` there should be a check that the new profile does not have the same database name as an existing one. Really the part of both functions that should contain this check should be reorganized so that the check can be written only once.
  • If it is the case the user should get a warning and have the choice to still use the same database in which case the previously described consistency check should be applied.
  • Add a test trying to create two profiles with the same db in all possible ways, asserting that it can not happen by accident.

@DropD DropD changed the title Have an automated way to check that the file repository and the database are consistent with each other Avoid inconsistencies due to multiple profiles using the same database Dec 18, 2017
@DropD
Copy link
Contributor

DropD commented Dec 18, 2017

Without the intention of properly implementing multi user, this now should be considered a major bug.

@sphuber sphuber modified the milestones: 1.0 release, v1.0.0 May 9, 2018
@giovannipizzi
Copy link
Member

�Optionally, check that there are no two profiles with the same UUID in the same file? From #2064

@sphuber sphuber modified the milestones: v1.0.0, v1.1.0 Apr 3, 2019
@sphuber sphuber removed this from the v1.1.0 milestone Feb 28, 2020
@giovannipizzi giovannipizzi added this to the v2.0.0 milestone Mar 24, 2021
@giovannipizzi
Copy link
Member

We discussed this today at the AiiDA meeting - in the "new 2.0" repository, this means e.g. adding in the DbSettings the disk-objectstore container ID, and checking that it matches on load_profile.

@sphuber
Copy link
Contributor

sphuber commented Mar 24, 2021

The check that database and repository are compatible solves the problem of accidentally coupling the wrong repo to a certain database. However, this does not tackle the potential problem of two profiles defining the exact same repo and database and then operating at the same time. I initially interpreted the issue to be mostly about this. But maybe this should be a separate issue. In that case I do think the title of this one should probably be clarified a bit.

@sphuber
Copy link
Contributor

sphuber commented Apr 28, 2021

I would vote to close this issue for the following reasons. In principle, I don't see a problem with multiple profiles defining the same database. Anyway this could be done across AiiDA installations, so there is no way we can stop it. With the merging of #4345 the database and repository are now at least cross-checked for compatibility and so the accidental configuration of an existing database with a new empty repository or incompatible repository is taken care off.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

5 participants