There are a number of ways in which incoming sessions might get stuck in the XNAT prearchive. A server crash, power failure, disk error (e.g. no space left on the device), and even operator error (e.g. an administrator mistakenly deleting prearchive folders) can lead to entries in the prearchive that can't be removed through the standard UI or REST API calls.
The prearchive really consists of two components:
- The folder that contains all of the incoming data for the prearchive
- The database table that contains entries for the incoming data
Depending on whether the data in the prearchive folder is valid and complete, you may be able to clear stuck entries simply by clearing the prearchive table. The prearchive table is validated and rebuilt on each restart of the Tomcat server and will be rebuilt from any data that exists in the prearchive folder. If there are issues with the data stored in the folder, you may need to remove that as well, since the new prearchive entries will be rebuilt from that faulty data.
To clear stuck sessions from the prearchive:
- Shut down your Tomcat server.
Drop the database table for the prearchive:
psql -U xnat -c 'drop table xdat_search.prearchive'
- You can optionally delete data from your prearchive folder:
- If you have a particular session or sessions causing an issue, you can delete the folders containing that data. To delete a folder for a particular session:
- Look under your prearchive folder for a folder with the same name as the project to which the session is assigned. That will contain one or more folders named with a timestamp corresponding to the date and time that the session was uploaded to the prearchive. Underneath that folder will be a folder named the same as the session label.
- If the session is not assigned to a project, the timestamp folder will be directly under the prearchive folder. Once you have located the folder containing the problematic data, delete the entire folder.
- If you aren't sure what might be causing the problem, you can delete all of the folders underneath your prearchive folder. If you have data you'd like to preserve for forensic purposes or to try to restore later, you can also move the data to another location out from under the prearchive folder.
- Once you've dropped the database table and optionally cleared any faulty data, start your Tomcat server.
When XNAT starts up, it will rebuild the prearchive table from the data remaining in the prearchive folder. This includes creating the table if necessary and reviewing all session data.