Hello everyone,
Our server has these installed:
dovecot-2.0.21-2.el6.x86_64
dovecot-pigeonhole-2.0.21-2.el6.x86_64
dovecot-mysql-2.0.21-2.el6.x86_64
...and has been running for quite a long time, with several hundred domains
and thousands of accounts on it. My colleagues reported that it's been
showing quota usage values that are more than actual disk usage, so I
investigated and found that Dovecot shows a quota usage value roughly
around 140% of actual disk usage. It's also valid on newly created
accounts. My test account for example:
doveadm quota get -u test at example.local
Quota name Type Value Limit %
User quota STORAGE 4359 512000 0
User quota MESSAGE 7 - 0
du -sc /home/vmail/example.local/test/Maildir/{*,.[!.]*}
1044 /home/vmail/example.local/test/Maildir/cur
28 /home/vmail/example.local/test/Maildir/dovecot.index.cache
8 /home/vmail/example.local/test/Maildir/dovecot.index.log
4 /home/vmail/example.local/test/Maildir/dovecot.mailbox.log
4 /home/vmail/example.local/test/Maildir/dovecot-uidlist
4 /home/vmail/example.local/test/Maildir/dovecot-uidvalidity
0 /home/vmail/example.local/test/Maildir/dovecot-uidvalidity.56a4dc8e
4 /home/vmail/example.local/test/Maildir/new
4 /home/vmail/example.local/test/Maildir/subscriptions
4 /home/vmail/example.local/test/Maildir/tmp
24 /home/vmail/example.local/test/Maildir/.Junk
1932 /home/vmail/example.local/test/Maildir/.Sent
44 /home/vmail/example.local/test/Maildir/.Trash
3104 total
4359/3104=1,40431701
So it shows roughly around 1,4*actualDiskUsage.
The ratio is mostly the same for almost all the other accounts. It can vary
between like 1,3-1,6. So, the gap gets insane when more disk space is used,
say like with 2GB disk usage, Dovecot thinks 3,5GB quota is used...
dovecot quota recalc does not fix the issue, it only sets the same value
again (I've checked with tcpdump and saw the query with the same quota
usage value).
The method is Dictionary quota with SQL.
I'm attaching the dovecot -n output with some other config files.
I've tried setting messages and bytes value to -1 on the MariaDB database
to force recalculation. But as soon as I run doveadm quota recalc, it gets
the same wrong value again.
What can I do to fix this?
Thanks in advance.
-------------- next part --------------
##
## Quota configuration.
##
# Note that you also have to enable quota plugin in mail_plugins setting.
# <doc/wiki/Quota.txt>
##
## Quota limits
##
# Quota limits are set using "quota_rule" parameters. To get per-user
quota
# limits, you can set/override them by returning "quota_rule" extra
field
# from userdb. It's also possible to give mailbox-specific limits, for
example
# to give additional 100 MB when saving to Trash:
plugin {
quota_rule = *:storage=500M
quota_rule2 = Trash:storage=+10%%
quota_rule3 = Spam:storage=+20%%
}
##
## Quota warnings
##
# You can execute a given command when user exceeds a specified quota limit.
# Each quota root has separate limits. Only the command for the first
# exceeded limit is excecuted, so put the highest limit first.
# The commands are executed via script service by connecting to the named
# UNIX socket (quota-warning below).
# Note that % needs to be escaped as %%, otherwise "% " expands to
empty.
plugin {
quota_warning = storage=99%% quota-warning 99 %u
quota_warning2 = storage=80%% quota-warning 80 %u
}
# Quota Warning service
service quota-warning {
executable = script /usr/local/bin/quota-warning.sh
user = vmail
unix_listener quota-warning {
user = vmail
group = vmail
mode = 0660
}
}
##
## Quota backends
##
# Multiple backends are supported:
# dirsize: Find and sum all the files found from mail directory.
# Extremely SLOW with Maildir. It'll eat your CPU and disk I/O.
# dict: Keep quota stored in dictionary (eg. SQL)
# maildir: Maildir++ quota
# fs: Read-only support for filesystem quota
plugin {
#quota = dirsize:User quota
#quota = maildir:User quota
quota = dict:User quota::proxy::sqlquota
#quota = dict:User quota::proxy::quota
#quota = fs:User quota
}
# Multiple quota roots are also possible, for example this gives each user
# their own 100MB quota and one shared 1GB quota within the domain:
plugin {
#quota = dict:user::proxy::quota
#quota2 = dict:domain:%d:proxy::quota_domain
#quota_rule = *:storage=102400
#quota2_rule = *:storage=1048576
quota_status_success = DUNNO
quota_status_nouser = DUNNO
quota_status_overquota = "552 5.2.2 Mailbox is full"
}
-------------- next part --------------
connect = host=192.168.95.8 dbname=postfix_masterdb user=postfix_user
password=someStrongPassword
map {
pattern = priv/quota/storage
table = quota
username_field = username
value_field = bytes
}
map {
pattern = priv/quota/messages
table = quota
username_field = username
value_field = messages
}
-------------- next part --------------
# 2.0.21: /etc/dovecot/dovecot.conf
# OS: Linux 2.6.32-642.6.2.el6.centos.plus.x86_64 x86_64 CentOS release 6.8
(Final) ext4
auth_master_user_separator = *
auth_mechanisms = plain login
debug_log_path = /var/log/dovecot-debug.log
dict {
sqlquota = mysql:/etc/dovecot/dovecot-quota-sql.conf.ext
}
disable_plaintext_auth = no
hostname = mailbox.radore.net
mail_location = maildir:/home/vmail/%Ld/%Ln/Maildir
mail_plugins = " notify mail_log quota autocreate zlib"
managesieve_notify_capability = mailto
managesieve_sieve_capability = fileinto reject envelope encoded-character
vacation subaddress comparator-i;ascii-numeric relational regex imap4flags copy
include variables body enotify environment mailbox date ihave
mbox_write_locks = fcntl
passdb {
args = /etc/dovecot/dovecot-sql.conf.ext
driver = sql
}
plugin {
autocreate = Trash
autocreate2 = Junk
autocreate3 = Sent
autosubscribe = Trash
autosubscribe2 = Junk
autosubscribe3 = Sent
mail_log_events = delete undelete expunge copy mailbox_delete mailbox_rename
mail_log_fields = uid box msgid size
quota = dict:User quota::proxy::sqlquota
quota_rule = *:storage=500M
quota_rule2 = Trash:storage=+10%%
quota_rule3 = Spam:storage=+20%%
quota_status_nouser = DUNNO
quota_status_overquota = 552 5.2.2 Mailbox is fullradore
quota_status_success = DUNNO
quota_warning = storage=99%% quota-warning 99 %u
quota_warning2 = storage=80%% quota-warning 80 %u
sieve = ~/.dovecot.sieve
sieve_before = /etc/dovecot/sieve-scripts/before/
sieve_dir = ~/sieve
sieve_max_actions = 10
sieve_max_redirects = 2
sieve_max_script_size = 100K
sieve_quota_max_scripts = 10
sieve_quota_max_storage = 1M
zlib_save = bz2
zlib_save_level = 9
}
postmaster_address = postmaster at mx01.some.where
protocols = imap pop3 lmtp sieve
service auth {
client_limit = 15000
inet_listener smtp-auth {
address = 192.168.95.9
port = 40025
}
unix_listener auth-userdb {
mode = 0600
user = vmail
}
}
service dict {
unix_listener dict {
group = vmail
mode = 0600
user = vmail
}
}
service imap-login {
inet_listener imap {
port = 143
}
inet_listener imaps {
port = 993
ssl = yes
}
process_min_avail = 24
service_count = 0
vsz_limit = 1 G
}
service imap {
process_limit = 8192
vsz_limit = 1 G
}
service lmtp {
inet_listener lmtp {
address = 192.168.95.9
port = 10025
}
}
service managesieve-login {kk
inet_listener sieve {
port = 4190
}
process_min_avail = 8
service_count = 0
vsz_limit = 128 M
}
service pop3-login {
inet_listener pop3 {
port = 110
}
inet_listener pop3s {
port = 995
ssl = yes
}
process_min_avail = 24
service_count = 0
vsz_limit = 1 G
}
service quota-warning {
executable = script /usr/local/bin/quota-warning.sh
unix_listener quota-warning {
group = vmail
mode = 0660
user = vmail
}
user = vmail
}
ssl_ca = </etc/ssl/private/rapidsslCA.crt
ssl_cert = </etc/ssl/private/some.where.crt
ssl_key = </etc/ssl/private/some.where.key
userdb {
driver = prefetch
}
userdb {
args = /etc/dovecot/dovecot-sql.conf.ext
driver = sql
}
verbose_proctitle = yes
protocol lmtp {
mail_plugins = " notify mail_log quota autocreate zlib sieve"
}
protocol lda {
mail_plugins = " notify mail_log quota autocreate zlib sieve"
}
protocol imap {
mail_plugins = " notify mail_log quota autocreate zlib imap_quota"
}
protocol sieve {
managesieve_max_compile_errors = 5
}