Project import failure after database restore (attach error: project already locked to instance)

CS 4.1.2

We have had a CS database corruption (unknown reason), tried to repair it with

mongod --dbpath ./ --repair

but that failed after just a couple of seconds.
We had a backup and restored the database from that.

CS is now running and I tried to import a project that was created after the latest database backup.
I get this error in the CS GUI:

Unable to attach project: ServerError: attach error: project already locked to instance

There is a file named cs.lock in the project folder.
Is this how the project is locked to instance?
Should i manually remove this file before trying to import it?

Thanks!

It is okay to remove cs.lock provided it was created after the database backup that you restored (and you have not successfully attached the project in the meantime), then again try to attach.

2 Likes

Worked out great!

What would you recommend in the case where the project was already present in the latest database backup but a large number of jobs (~50) was created between the latest backup and database corruption?
We can import one by one right?
But would it make more sense to make a copy of the project folder with all the jobs, delete the project from the CS interface and then reimport the ‘whole’ project again?
Both approaches are feasible, right?

Thank you again!

  1. Ensure all CryoSPARC-related processes have been terminated, using a ps command like
    ps -eopid,ppid,cmd | grep -e cryosparc_ -e mongo
    
    Adjust the command according to the specific circumstances of your installation. Be aware of potential additional CryoSPARC instances running on the server (possible subject to certain constraints). kill, but not kill -9, any left-over CryoSPARC-related processes that belong to the specific CryoSPARC instance in question.
  2. Rename the project directory. Ensure the new directory name
    1. is unique.
    2. is distinct from the project directory path of any project that may be present in the database, even if the directory itself may not exist.
  3. Restore the database from the backup.
  4. Run:
    cryosparcm restart
  5. Open the CryoSPARC interactive command line interface (icli)
    cryosparcm icli
  6. Inside the icli, run the command (after substituting the actual project uid)
    db.projects.update_one({'uid': "P###"}, {'$set': {'detached': True, 'last_detached_version': cli.get_running_version()}})
    exit()
    
    to detach the old project whose project directory you renamed earlier.
  7. Attach the renamed project directory.
  8. For the project that you detached earlier, Delete project from database (guide).
1 Like