diff --git a/indra/newview/lltexturecache.cpp b/indra/newview/lltexturecache.cpp
index 10003777183eae35c0fdf172aacb381cae12a51d..71d3731f93fa91272c4fc35e128fd00cc63807b7 100644
--- a/indra/newview/lltexturecache.cpp
+++ b/indra/newview/lltexturecache.cpp
@@ -1879,24 +1879,27 @@ S32 LLTextureCache::getHeaderCacheEntry(const LLUUID& id, Entry& entry)
 S32 LLTextureCache::setHeaderCacheEntry(const LLUUID& id, Entry& entry, S32 imagesize, S32 datasize)
 {
 	mHeaderMutex.lock();
-	S32 idx = openAndReadEntry(id, entry, true);
+	S32 idx = openAndReadEntry(id, entry, true); // read or create
 	mHeaderMutex.unlock();
 
-	if (idx >= 0)
-	{
-		updateEntry(idx, entry, imagesize, datasize);				
-	}
-
-	if(idx < 0) // retry
+	if(idx < 0) // retry once
 	{
 		readHeaderCache(); // We couldn't write an entry, so refresh the LRU
-	
+
 		mHeaderMutex.lock();
-		llassert_always(!mLRU.empty() || mHeaderEntriesInfo.mEntries < sCacheMaxEntries);
+		idx = openAndReadEntry(id, entry, true);
 		mHeaderMutex.unlock();
+	}
 
-		idx = setHeaderCacheEntry(id, entry, imagesize, datasize); // assert above ensures no inf. recursion
+	if (idx >= 0)
+	{
+		updateEntry(idx, entry, imagesize, datasize);				
 	}
+	else
+	{
+		LL_WARNS() << "Failed to set cache entry for image: " << id << LL_ENDL;
+	}
+
 	return idx;
 }