function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion

Cannot Package due to "Your runAllTests request is using too many DB resources."

Hi All, I'm trying to package my release managed package, and i'm getting lot of failures related to the same error: 
"System.LimitException: Your runAllTests request is using too many DB resources." 

I was able to package before, but seems like we have a new limitation now.... 
I really need this package to go live ASAP and of course, this is a BLOCKER. 

Notice that ALL MY TEST CASES HAVE 0 FAILURES if i run them individually. 

Thanks in advance, 


This error means you have run afoul of a governor limit during testing.  This particular error typically occurs on a DML row limit exception, and most commonly when a large series of deletions are done at the beginning of a series of tests.


Are you using data-silo for your tests, where you create all the necessary test data in your test classes?  Are you doing blanket deletions of data at the start of your tests?


Hi Josh, sorry the delay. I couldn't work around the issue yet..... 


I don't think is related to a best practice issue, I think is just because I have more than 800 Test Methods in my org!


About your questions:

1 - Are you using data-silo for your tests, where you create all the necessary test data in your test classes?


2 - Are you doing blanket deletions of data at the start of your tests?

BEFORE, we were doing that in all our test (without issues). But now with the new Test Method behaviour, that there is no Data by default in the Test context, we REMOVED IT. (We are just doing it in one place, and for just a few Test methods (less than 10). So, I don't think this is the issue.


We are really stuck with this limitation and I don't think delete test methods just to workaround it, will be the best option. Also, that we could be lowing our All test methods percentage under 75%, blocking me to package anyways.


I contacted Salesforce Support, but they told me that basic support cannot help me,  "check discussion board"...... And seems like i'm the only one that is seeing this issue. At least, this looks pretty basic funcionatily to me, so, they should be taking care of it. Is not my fault if i have 4,199,251 characters of Apex Code, and the platform doesn't know how to handle that kind of volume while testing it....


Anyways, There is a place where this limitation is documented? Any Idea of how to work around it or resolve it?


Thanks in advance,




I checked your code out, and it's still deleting lots of data at the beginning of several tests, e.g.:


List <UserFeed> listPostTrash = [Select Id from UserFeed];
    delete listPostTrash;


This particular limit is impossible for us to relax, since you're essentially filling up the Oracle rollback segments. That error indicates that you're doing DML on many hundreds of thousands of rows over the course of all the tests. It's just too much for the rollback buffer.


If oracle were more intelligent, it wouldn't hold onto rollback segments from the tests you've already run, but unfortunately they haven't fixed this (we did file a bug with them). So, we have to conserve some rollback segments for the other requests running on that oracle rac node.


Hi Rich, thanks for the detailed explanation, and sorry the dealy on replying back....

I understand the database limit that we are hitting, but I don't really know how we can avoid it. My opinion is that is a volume issue, as I have around 1000 test cases (and around 200 commented). With around 800 i was still able to package. With 900, it fails.

The code example where you point that we are deleting lots of data, is not really deleting anything. I checked that query on the org where i'm getting the database error while uploading my package, and is empty, so, not data is actually deleted.
Could you point me somewhere else?

I was able to work around the issue, just commenting lot of my test methods, until it allow me to package. This worked for a while, but now, i'm getting under 75% of my org code coverage, so... I un-commented some of the test methods (around 50 of them), just to be over 75%, but now i'm getting the database error again....
I'm really stuck with this right now and I need a inmediate solution.
Could you please take another look?

Thanks in advance!!


Hi, we are getting the same error when we are trying to deploy to production.


We think the issue may be the data storage.  It is currently at 100% for us, but not sure.  If anyone has any insights, that would be helpful.

Paul Dyson.ax812Paul Dyson.ax812

We're also having this problem and we don't delete any data at the start of tests or anywhere in the tests other than for testing 'on delete' triggers (where we create one or two rows within a test and then delete them, in total we create and delete around 200 rows across 1800 tests).


Hi Paul, looks like your issue is more similar to what is happening to us. I'm still facing the issue and my guess is just related to volume of test cases and we are just hitting the resources limit. Right now we are struggling between the 75% restriction to package, and the too many DB resource limit....

Let me know if you find any workaround.



Paul Dyson.ax812Paul Dyson.ax812

How many tests do you have and what percentage of your apex allowance have you used Juan?


Right now I have around 1.000 test methods, but I had to remove lot of them to be able to workaround the too many DB Resources issue. So, I'm packaging with 874 test methods (i think with around 900-950 will fail). Downside is that i'm really close to 75%.


In terms of amount of apex code :


Percent of Apex Used: 79.47%

You are currently using 4,768,061 characters of Apex Code (excluding comments and @isTest annotated classes) in your organization, out of an allowed limit of 6,000,000 characters


Of course, I requested a few time to increase this limit. For now I'm ok with it and I don't believe is the case of my issue.



Paul Dyson.ax812Paul Dyson.ax812

Interesting. We have a lot less code (1.8m chars) but about twice as many tests (1850). So not much correlation there, must be something to do with what the tests are doing.

Nilesh DetheNilesh Dethe

Hi All,

I know this question was posted like 7 years back but it interests me as I am also getting similar issues as of today, stuck with my production deployment. I have 1305 test methods out of which almost 550+ are failing with "System.LimitException: Your runAllTests request is using too many DB resources."  we are already using the "@testSetup" for generating the test data in most of our test methods even we have used Test.loadData() method for loading data via static resource but still we are facing this issues. I have opened case with Salesforce Support but we are not close to finding any solutions hence decided to reach out to the community for help.

Since this is exactly what I am facing, I decided to post and find out what are possible options I have in my hands. Did anyone get any solutions for this? Any suggestion around this would be of huge help. 

Nilesh D