My Ancestry test failed three times, and my brother failed his twice. My Living DNA test failed on the first occasion. It can be more likely for older people, particularly if you have trouble producing enough saliva in a continuous attempt. Some of us apparently also have lower amounts of DNA in our saliva.
The procedure I adopted for my fourth and successful Ancestry test, was as follows:
Complete the test in the morning, before eating anything or cleaning your teeth, but drink some water when you first get up, and wait about an hour before taking the test.
If you have difficulty filling the tube in one go, leave it standing upright out of direct sunlight, away from heat sources and where it won't be disturbed, and have another go at topping it up a short while later.
Make sure you fill the sample tube at least to the indicated level, preferably a little higher rather than just to the line as Ancestry suggest, although not by too much. If there are bubbles in the saliva, leave the tube a short time to settle as above and add a little more saliva after settling if necessary.
Use a sterile swab such as those supplied in Covid test kits, to scrape gently on the insides of both cheeks for around 20-30 seconds per cheek, avoiding your tongue and gums. Place it in your saliva sample and stir it around for a few seconds to transfer the cells and DNA from your cheeks into the sample.
Seal the tube and post as normal.
The test I did following the above instructions passed with Ancestry, as did my brother's second test after he followed the same procedure. I have used the same procedure for other DNA saliva tests that I have since done, and have not had any other failures.