Hello list, I believe I found a bug with quota. The dovecot quota replies with incorrect values when the mailbox is above 2GB.
du -ks returns 2005764bytes
dovecot IMAP on the same user/directory: 1 getquotaroot inbox
- QUOTAROOT "INBOX" "user"
- QUOTA "user" (STORAGE 1096 2000000)* QUOTAROOT "INBOX" "user"
- QUOTA "user" (STORAGE 1096 2000000) 1 OK Getquotaroot completed.
Is there any way to fix this ?
linux system: dovecot 1.2.15-7 linux 2.6.32-5-amd64
dovecot.conf: dict { quotadict= mysql:/etc/dovecot/dovecot-dict-quota.conf } plugin { quota = dict:user::proxy::quotadict }
dovecot-dict-quota.conf : user_query = SELECT '/home/%d/%n' as home, 'maildir:/home/%d/%n' as mail, 150 AS uid, 8 AS gid, CONCAT('*:bytes=', CAST(quota AS CHAR)) AS quota_rule FROM mailbox WHERE username = '%u' AND active = '1'
On Wed, 2011-11-09 at 14:59 +0200, Adrian M wrote:
Hello list, I believe I found a bug with quota. The dovecot quota replies with incorrect values when the mailbox is above 2GB.
du -ks returns 2005764bytes
dovecot IMAP on the same user/directory: 1 getquotaroot inbox
- QUOTAROOT "INBOX" "user"
- QUOTA "user" (STORAGE 1096 2000000)* QUOTAROOT "INBOX" "user"
- QUOTA "user" (STORAGE 1096 2000000) 1 OK Getquotaroot completed.
So it wraps.
dovecot.conf: dict { quotadict= mysql:/etc/dovecot/dovecot-dict-quota.conf } plugin { quota = dict:user::proxy::quotadict }
dovecot-dict-quota.conf : user_query = SELECT '/home/%d/%n' as home, 'maildir:/home/%d/%n' as mail, 150 AS uid, 8 AS gid, CONCAT('*:bytes=', CAST(quota AS CHAR)) AS quota_rule FROM mailbox WHERE username = '%u' AND active = '1'
This is dovecot-sql.conf, not dovecot-dict-quota.conf (or alternatively you've named them in a "wrong" way).
Anyway, here's a guess: the quota is stored in mysql in "integer", which has a maximum value of 2 GB. Actually looks like Dovecot wiki pages also use "integer". Replace that with "bigint" and recalculate quota and it should work.
On 11/09/11 19:59, Timo Sirainen wrote:
Anyway, here's a guess: the quota is stored in mysql in "integer", which has a maximum value of 2 GB. Actually looks like Dovecot wiki pages also use "integer". Replace that with "bigint" and recalculate quota and it should work.
Actually the mysql part is OK: quota | bigint(20)
As you can see the value readed from mysql ( 2000000bytes) is also OK:
- QUOTA "user" (STORAGE 1096 2000000)
The problem is the 1096 number calculated internally by dovecot. By tweaking the SQL querry I coud put any value instead of 2000000, but I was unable to change 1096 part.
-- Best regards, Adrian Minta MA3173-RIPE, www.minta.ro
On Wed, 2011-11-09 at 20:35 +0200, Adrian Minta wrote:
On 11/09/11 19:59, Timo Sirainen wrote:
Anyway, here's a guess: the quota is stored in mysql in "integer", which has a maximum value of 2 GB. Actually looks like Dovecot wiki pages also use "integer". Replace that with "bigint" and recalculate quota and it should work.
Actually the mysql part is OK: quota | bigint(20)
As you can see the value readed from mysql ( 2000000bytes) is also OK:
2000000 kilobytes is the quota limit.
- QUOTA "user" (STORAGE 1096 2000000)
The problem is the 1096 number calculated internally by dovecot. By tweaking the SQL querry I coud put any value instead of 2000000, but I was unable to change 1096 part.
Is the quota in the database 1096 or >2GB? i.e. is the problem with reading it, or updating it? In general the quota code uses 64bit integers everywhere so this shouldn't be happening.
Is the quota in the database 1096 or>2GB? i.e. is the problem with reading it, or updating it? In general the quota code uses 64bit integers everywhere so this shouldn't be happening.
In the database quota field is 2048000000.
-- Best regards, Adrian Minta MA3173-RIPE, www.minta.ro
On Wed, 2011-11-09 at 20:44 +0200, Adrian Minta wrote:
Is the quota in the database 1096 or>2GB? i.e. is the problem with reading it, or updating it? In general the quota code uses 64bit integers everywhere so this shouldn't be happening.
In the database quota field is 2048000000.
In the dict quota value? That looks more like the quota limit, not the current quota usage.
On 11/09/11 20:46, Timo Sirainen wrote:
On Wed, 2011-11-09 at 20:44 +0200, Adrian Minta wrote:
Is the quota in the database 1096 or>2GB? i.e. is the problem with reading it, or updating it? In general the quota code uses 64bit integers everywhere so this shouldn't be happening.
In the database quota field is 2048000000. In the dict quota value? That looks more like the quota limit, not the current quota usage. In the mailbox table.
The 2000000 value commes from:
user_query = SELECT '/home/%d/%n' as home, 'maildir:/home/%d/%n' as mail, 150 AS uid, 8 AS gid, CONCAT('*:bytes=', CAST(quota AS CHAR)) AS quota_rule FROM mailbox WHERE username = '%u' AND active = '1'
This value is easy to change by modifying the above mysql query, but the 1096 value I don't know how to change. Maybe to "instruct" dovecot to work internal with Kilobytes ?
For instance by altering the query like this:
user_query = SELECT '/home/%d/%n' as home, 'maildir:/home/%d/%n' as mail, 150 AS uid, 8 AS gid, CONCAT('*:bytes=', quota, 'K') AS quota_rule FROM mailbox WHERE username = '%u' AND active = '1'
... I get ...
- QUOTA "user" (STORAGE 1096 2048000000)
-- Best regards, Adrian Minta MA3173-RIPE, www.minta.ro
After some deep investigations I manage to solve the problem. I was only reading quota in user_querry. Now I read it in user_querry and in password_query and all seems fine:
--dovecot-sql.conf---
user_query = SELECT '/home/%d/%n' as home, 'maildir:/home/%d/%n' as mail, 150 AS uid, 8 AS gid, CONCAT('*:bytes=', quota) AS quota_rule FROM mailbox WHERE username = '%u' AND active = '1' password_query = SELECT username as user, password, '/home/%d/%n' as userdb_home, 'maildir:/home/%d/%n' as userdb_mail, 150 as userdb_uid, 8 as userdb_gid, CONCAT('*:bytes=', quota) as userdb_quota_rule FROM mailbox WHERE username = '%u' AND active = '1'
--dovecot.conf---
plugin { quota = dict:user::proxy::quotadict quota_rule2 = Trash:storage=10%% quota_rule3 = SPAM:storage=10%% }
the result is fine now:
2 getquotaroot inbox
- QUOTAROOT "INBOX" "user"
- QUOTA "user" (STORAGE 1997999 2000000) 2 OK Getquotaroot completed.
Only one "cosmetic" bug remains when an empty mailbox appear as a small negative number in quota2 table, but this is fixable in postfixadmin.
--
Best regards, Adrian Minta MA3173-RIPE,www.minta.ro
participants (3)
-
Adrian M
-
Adrian Minta
-
Timo Sirainen