summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorEliot Horowitz <eliot@10gen.com>2013-03-05 00:51:07 -0500
committerEliot Horowitz <eliot@10gen.com>2013-03-05 00:51:07 -0500
commit9d9ea7b87d170711ddc17ac9abc2ead80d9cda60 (patch)
tree6d7bf0eed569939442021317da6b205aba02e270
parentcc1fd583aa2280f993efa1741b0a0197dd580269 (diff)
downloadmongo-9d9ea7b87d170711ddc17ac9abc2ead80d9cda60.tar.gz
SERVER-8431 - don't index docs where text index is too large for journal
-rw-r--r--src/mongo/db/fts/fts_index_format.cpp19
1 files changed, 19 insertions, 0 deletions
diff --git a/src/mongo/db/fts/fts_index_format.cpp b/src/mongo/db/fts/fts_index_format.cpp
index 56df0e219e5..f153dc02864 100644
--- a/src/mongo/db/fts/fts_index_format.cpp
+++ b/src/mongo/db/fts/fts_index_format.cpp
@@ -20,6 +20,7 @@
#include "mongo/base/init.h"
#include "mongo/db/fts/fts_index_format.h"
+#include "mongo/util/mongoutils/str.h"
namespace mongo {
@@ -70,6 +71,15 @@ namespace mongo {
// create index keys from raw scores
// only 1 per string
+
+ uassert( 16732,
+ mongoutils::str::stream() << "too many unique keys for a single document to"
+ << " have a text index, max is " << term_freqs.size() << obj["_id"],
+ term_freqs.size() <= 400000 );
+
+ long long keyBSONSize = 0;
+ const int MaxKeyBSONSizeMB = 4;
+
for ( TermFrequencyMap::const_iterator i = term_freqs.begin();
i != term_freqs.end();
++i ) {
@@ -96,6 +106,15 @@ namespace mongo {
verify( guess >= res.objsize() );
keys->insert( res );
+
+ keyBSONSize += res.objsize();
+
+ uassert( 16733,
+ mongoutils::str::stream()
+ << "trying to index text where term list is too big, max is "
+ << MaxKeyBSONSizeMB << "mb " << obj["_id"],
+ keyBSONSize <= ( MaxKeyBSONSizeMB * 1024 * 1024 ) );
+
}
}