John Fawcett
2022-Jan-09 04:06 UTC
Patch: safeguard against too large value for uid being sent to solr for single mailbox searches
Hi I'm reposting a patch for solr integration which I have been applying locally. It applies against 2.3.17.1. Dovecot already has a mechanism when doing solr fts searches on multiple mailboxes that prevents a too large value for maximum rows being sent to solr. #define SOLR_MAX_MULTI_ROWS 100000 (defined and used in plugins/fts-solr/fts-backend-solr.c) However on single mailbox searches Dovecot uses the last uid of the mailbox, which can be too large for solr. My suggested patch is to also limit maximum rows to return on single mailbox searches. Here is the patch: diff -ur dovecot-2.3.17.1-orig/src/plugins/fts-solr/fts-backend-solr.c dovecot-2.3.17.1-new/src/plugins/fts-solr/fts-backend-solr.c --- dovecot-2.3.17.1-orig/src/plugins/fts-solr/fts-backend-solr.c 2021-12-03 12:48:47.000000000 +0100 +++ dovecot-2.3.17.1-new/src/plugins/fts-solr/fts-backend-solr.c 2022-01-09 01:33:23.401341959 +0100 @@ -837,7 +837,7 @@ ??????? str = t_str_new(256); ??????? str_printfa(str, "wt=xml&fl=uid,score&rows=%u&sort=uid+asc&q=%%7b!lucene+q.op%%3dAND%%7d", -?????????????????? status.uidnext); +?????????????????? I_MIN(status.uidnext,SOLR_MAX_MULTI_ROWS)); ??????? prefix_len = str_len(str); ??????? if (solr_add_definite_query_args(str, args, and_args)) { John