Postfix instance that will be responsible for cache
cleanup.
- NOTE 2: When different tables share the same mem-
+ NOTE 2: When multiple tables share the same mem-
cache database, each table should use the <b>key_for-</b>
<b>mat</b> feature (see below) to prepend its own unique
string to the lookup key. Otherwise, automatic
<b>MEMCACHE KEY PARAMETERS</b>
<b>key_format (default: %s)</b>
- Format of the lookup and update keys in memcache
- requests. By default, these are the same as the
- lookup and update keys that are given to the Post-
- fix memcache client.
+ Format of the lookup and update keys that the Post-
+ fix memcache client sends to the memcache server.
+ By default, these are the same as the lookup and
+ update keys that the memcache client receives from
+ Postfix applications.
- NOTE 1: The <b>key_format</b> feature is not used for
+ NOTE 1: The <b>key_format</b> feature is not used for
<b>backup</b> database requests.
- NOTE 2: When different tables share the same mem-
- cache database, each table should prepend its own
- unique string to the lookup key. Otherwise, auto-
- matic <a href="postscreen.8.html"><b>postscreen</b>(8)</a> or <a href="verify.8.html"><b>verify</b>(8)</a> cache cleanup may
+ NOTE 2: When multiple tables share the same mem-
+ cache database, each table should prepend its own
+ unique string to the lookup key. Otherwise, auto-
+ matic <a href="postscreen.8.html"><b>postscreen</b>(8)</a> or <a href="verify.8.html"><b>verify</b>(8)</a> cache cleanup may
not work.
Examples:
<b>%%</b> This is replaced by a literal '%' character.
- <b>%s</b> This is replaced by the memcache client
+ <b>%s</b> This is replaced by the memcache client
input key.
<b>%u</b> When the input key is an address of the form
user@domain, <b>%u</b> is replaced by the SQL
- quoted local part of the address. Other-
- wise, <b>%u</b> is replaced by the entire search
+ quoted local part of the address. Other-
+ wise, <b>%u</b> is replaced by the entire search
string. If the localpart is empty, a lookup
- is silently suppressed and returns no
- results (an update is skipped with a warn-
+ is silently suppressed and returns no
+ results (an update is skipped with a warn-
ing).
<b>%d</b> When the input key is an address of the form
- user@domain, <b>%d</b> is replaced by the domain
+ user@domain, <b>%d</b> is replaced by the domain
part of the address. Otherwise, a lookup is
- silently suppressed and returns no results
+ silently suppressed and returns no results
(an update is skipped with a warning).
<b>%[SUD]</b> The upper-case equivalents of the above
- expansions behave in the <b>key_format</b> parame-
+ expansions behave in the <b>key_format</b> parame-
ter identically to their lower-case counter-
parts.
- <b>%[1-9]</b> The patterns %1, %2, ... %9 are replaced by
+ <b>%[1-9]</b> The patterns %1, %2, ... %9 are replaced by
the corresponding most significant component
- of the input key's domain. If the input key
+ of the input key's domain. If the input key
is <i>user@mail.example.com</i>, then %1 is <b>com</b>, %2
- is <b>example</b> and %3 is <b>mail</b>. If the input key
+ is <b>example</b> and %3 is <b>mail</b>. If the input key
is unqualified or does not have enough
- domain components to satisfy all the speci-
- fied patterns, a lookup is silently sup-
+ domain components to satisfy all the speci-
+ fied patterns, a lookup is silently sup-
pressed and returns no results (an update is
skipped with a warning).
<b>domain (default: no domain list)</b>
This feature can significantly reduce database
server load. Specify a list of domain names, paths
- to files, or "<a href="DATABASE_README.html">type:table</a>" databases. When speci-
+ to files, or "<a href="DATABASE_README.html">type:table</a>" databases. When speci-
fied, only fully qualified search keys with a *non-
empty* localpart and a matching domain are eligible
- for lookup or update: bare 'user' lookups, bare
- domain lookups and "@domain" lookups are silently
+ for lookup or update: bare 'user' lookups, bare
+ domain lookups and "@domain" lookups are silently
skipped (updates are skipped with a warning).
Example:
The maximal memcache reply line length in bytes.
<b>max_try (default: 2)</b>
- The number of times to try a memcache command
- before giving up. The memcache client does not
+ The number of times to try a memcache command
+ before giving up. The memcache client does not
retry a command when the memcache server accepts no
connection.
<b>retry_pause (default: 1)</b>
- The time in seconds before retrying a failed mem-
+ The time in seconds before retrying a failed mem-
cache command.
<b>timeout (default: 2)</b>
- The time limit for sending a memcache command and
+ The time limit for sending a memcache command and
for receiving a memcache reply.
<b>BUGS</b>
- The Postfix memcache client cannot be used for security-
- sensitive tables such as <b><a href="postconf.5.html#alias_maps">alias_maps</a></b> (these may contain
- "<i>|command</i> and "<i>/file/name</i>" destinations), or <b><a href="postconf.5.html#virtual_uid_maps">vir</a>-</b>
- <b><a href="postconf.5.html#virtual_uid_maps">tual_uid_maps</a></b>, <b><a href="postconf.5.html#virtual_gid_maps">virtual_gid_maps</a></b> and <b><a href="postconf.5.html#virtual_mailbox_maps">virtual_mailbox_maps</a></b>
- (these specify UNIX process privileges or "<i>/file/name</i>"
- destinations). In a typical deployment a memcache data-
- base is writable by any process that can talk to the mem-
- cache server; in contrast, security-sensitive tables must
+ The Postfix memcache client cannot be used for security-
+ sensitive tables such as <b><a href="postconf.5.html#alias_maps">alias_maps</a></b> (these may contain
+ "<i>|command</i> and "<i>/file/name</i>" destinations), or <b><a href="postconf.5.html#virtual_uid_maps">vir</a>-</b>
+ <b><a href="postconf.5.html#virtual_uid_maps">tual_uid_maps</a></b>, <b><a href="postconf.5.html#virtual_gid_maps">virtual_gid_maps</a></b> and <b><a href="postconf.5.html#virtual_mailbox_maps">virtual_mailbox_maps</a></b>
+ (these specify UNIX process privileges or "<i>/file/name</i>"
+ destinations). In a typical deployment a memcache data-
+ base is writable by any process that can talk to the mem-
+ cache server; in contrast, security-sensitive tables must
never be writable by the unprivileged Postfix user.
The Postfix memcache client requires additional configura-
- tion when used as <a href="postscreen.8.html"><b>postscreen</b>(8)</a> or <a href="verify.8.html"><b>verify</b>(8)</a> cache. For
- details see the <b>backup</b> and <b>ttl</b> parameter discussions in
+ tion when used as <a href="postscreen.8.html"><b>postscreen</b>(8)</a> or <a href="verify.8.html"><b>verify</b>(8)</a> cache. For
+ details see the <b>backup</b> and <b>ttl</b> parameter discussions in
the MEMCACHE MAIN PARAMETERS section above.
<b>SEE ALSO</b>
<a href="MEMCACHE_README.html">MEMCACHE_README</a>, Postfix memcache client guide
<b>LICENSE</b>
- The Secure Mailer license must be distributed with this
+ The Secure Mailer license must be distributed with this
software.
<b>HISTORY</b>
- Memcache support was introduced with Postfix version 2.9.
+ Memcache support was introduced with Postfix version 2.9.
<b>AUTHOR(S)</b>
Wietse Venema
msg_fatal("env_create %s: %s", mdb_path, mdb_strerror(status));
/*
- * For continued availability, try to ensure that the LMDB size limit is
- * at least 3x the current LMDB file size. This should be sufficient for
- * short-lived Postfix daemon processes.
+ * Try to ensure that the LMDB size limit is at least 3x the current LMDB
+ * file size. This should be sufficient to ensure that short-lived
+ * Postfix daemon processes can recover from a "table full" error.
+ *
+ * Note: readers must increase their LMDB size limit, too, otherwise they
+ * won't be able to continue reading a table after grows.
*/
-#ifdef SIZE_T_MAX
+#ifndef SIZE_T_MAX
#define SIZE_T_MAX __MAXINT__(size_t)
#endif
+#define LMDB_SIZE_FUDGE_FACTOR 3
- if (stat(mdb_path, &st) == 0 && st.st_size >= dict_lmdb_map_size / 2) {
- msg_warn("%s: file size %lu >= (%s map size limit %ld)/3 -- "
+ if (stat(mdb_path, &st) == 0
+ && st.st_size >= dict_lmdb_map_size / LMDB_SIZE_FUDGE_FACTOR) {
+ msg_warn("%s: file size %lu >= (%s map size limit %ld)/%d -- "
"using a larger map size limit",
mdb_path, (unsigned long) st.st_size,
- DICT_TYPE_LMDB, (long) dict_lmdb_map_size);
- dict_lmdb_map_size = 3 * st.st_size;
- if (dict_lmdb_map_size / 3 != st.st_size)
+ DICT_TYPE_LMDB, (long) dict_lmdb_map_size,
+ LMDB_SIZE_FUDGE_FACTOR);
+ /* Defense against naive optimizers. */
+ if (st.st_size < SIZE_T_MAX / LMDB_SIZE_FUDGE_FACTOR)
+ dict_lmdb_map_size = st.st_size * LMDB_SIZE_FUDGE_FACTOR;
+ else
dict_lmdb_map_size = SIZE_T_MAX;
}
if ((status = mdb_env_set_mapsize(env, dict_lmdb_map_size)))