A few days ago several thousand errors started pouring in to Google Stackdriver about Error: too many index entries for entity
from one of our Cloud Functions.
Our code hasn't changed in a while so I believe the error is due to something in Firestore changing and causing queries or write operations to fail in this function.
The full stacktrace is below.
Note that none of the files referenced are code that we wrote, only Google's internal stuff for functions.
Error: too many index entries for entity
at Http2CallStream.call.on (/srv/functions/node_modules/@grpc/grpc-js/build/src/client.js:96:45)
at Http2CallStream.emit (events.js:194:15)
at Http2CallStream.EventEmitter.emit (domain.js:459:23)
at process.nextTick (/srv/functions/node_modules/@grpc/grpc-js/build/src/call-stream.js:71:22)
at process._tickCallback (internal/process/next_tick.js:61:11)
Brief research made us believe that we had too many documents that were covered under an index. The collection being accessed by the function has around 35,000 documents right now. We deleted the one composite index we had created but the error continued to occur. The error will cause the function to crash and the HTTP request that triggered it will return an error page. This is not consistently reproducible and seems to be happening at random (around 5% of requests are failing).
I am happy to provide more information about our Firestore setup or our function source code if necessary. Any help is greatly appreciated.