Have you ever been in a situation where the second stage library has a folder that is very large say about 56 GB. And it cannot be deleted because the database locks during deletion and the site becomes inaccessible. The process eventually times out and the site access resumes, but the item remains in the second stage recycle bin.
Then this article might be helpful….read on
First lets get a little familiar with the terms used
- First stage recycle bin – It is nothing but the site’s Recycle Bin. Anything a user delete’s from the site goes here.
Users can delete it from here or restore the item back
- Second stage recycle bin – The site Collection Recycle Bin. If item is deleted from the site recycle bin it lands here.
Site collection Administrators can delete it from here or restore the item back
Some helpful articles
- New to SharePoint 2007 recycle bin, read View, restore, or delete items in the Recycle Bin of a SharePoint site
- Want to know how to configure it then refer SharePoint Recycle Bin Administration
- An interesting article on how to use the recycle bin
- Protect and restore content by using Recycle Bins and versioning http://technet.microsoft.com/en-us/library/cc288451.aspx
How does deletion work
When you delete an item from a Web site, the item is sent to the site’s Recycle Bin. If you click Recycle Bin on the Quick Launch, you can see all of the items that you’ve deleted from your site. You can either restore or delete the item from the Recycle Bin. When you delete an item from the Recycle Bin, the item is sent to the Site Collection Recycle Bin.
When an item is deleted from the site collection recycle bin (manually or automatically) the item is flushed from the content database. Other wise it remains in the database. Only one flag
Few thoughts that crossed my mind
- How can one land up with this big an item in the second stage recycle bin?
- If it is in second stage recycle bin, how did they flush it from first stage?
- Is this an acceptable behavior?
Here’s what i found
- Lets consider one example: say there is a folder in the document library which has many files uploaded. The folder is deleted which is few GB in size.
- When we delete items from the site or the first stage recycle bin it remains in the content database. But when we delete it from second stage recycle bin, that is when it is flushed from the content database. So deleting a large file from first stage bin was not a problem.
- Ideally speaking no, but as of now we need to leave with it.
There are certain things that can be done to avoid this situation
1. Restore the problem library to its original location. Delete the documents few at a time. Flush the second stage recycle bin periodically.
By default the below command will show the period at which the recycle job will be run
STSADM -o getproperty -propertyname job-recycle-bin-cleanup -url http://<sitename>
Run the below command to run the recycle timer job periodically
STSADM -o setproperty -propertyname job-recycle-bin-cleanup -propertyvalue “<configure a convenient time>” -url http://<site name>
2. Disable Second stage recycle bin from the central administration page
Go to Central Administration > Application Management > Web Application General Settings
Set Recycle Bin > Second stage Recycle Bin > OFF
Note: This will flush the items in the second stage recycle bin for site collections in that web application. This is a web application level setting.
On enabling second stage recycle bin the items will be removed from the recycle bin. The files are deleted from the database so it cannot be retrieved.
3. A custom code based on SharePoint Object Model can be used to flush the large files from the second stage recycle bin.
SPSite site = new SPSite(<<siteurl>>);
SPWeb web = site.RootWeb;
SPRecycleBinQuery q = new SPRecycleBinQuery();
q.RowLimit = Int32.Parse(<<number of items to be deleted>>);
q.OrderBy = SPRecycleBinOrderBy.Default;
SPRecycleBinItemCollection itemColl = web.GetRecycleBinItems(q);
foreach (SPRecycleBinItem item in itemColl)
Guid id = new Guid;
id = item.ID;
The sample code provided is on “AS IS” basis with no warranties, and confers no rights.