When obtaining a new cursor, we call WT_SESSION::open_cursor(). We have an invariant that the return status is OK if the error is not ENOENT:
int ret = _session->open_cursor( _session, uri.c_str(), NULL, forRecordStore ? "" : "overwrite=false", &c); if (ret != ENOENT) invariantWTOK(ret);
If we hit the file limit, this call can also return EMFILE ("Too many open files"). We should consider either also checking for this (or similar) return codes so that we can crash with a friendlier error message, or make an fassertWTOK(), as this situation is not an invariant failure in the sense that we have made some sort of programming error.