[Dovecot] Quota in mysql dict not properly recalculated on 1.2?
Good morning, I am trying to add quota storage on mysql following the guide in the wiki http://wiki.dovecot.org/Quota/Dict, and I am having some problems. My setup works fine for the newly created accounts, and correctly increases/decreases quota when necessary. The wrong part seems to be the recalculation. It seems to me that the system doesn't count the real occupation when it has to recreate the quota entry for a username. This is the case:
.- User test@testing.com has a quota 200000 bytes, I delete the entry of the database for user, and then when I do the: echo 'x GETQUOTAROOT Inbox' | USER=test@testing.com /usr/sbin/dovecot --exec-mail imap
.- These are ALL the queries I see, I am missing the userdb queries to get the real quota. INSERT INTO quota_dovecot (bytes,username) VALUES ('0','test@testing.com') ON DUPLICATE KEY UPDATE bytes='0' INSERT INTO quota_dovecot (messages,username) VALUES ('0','test@testing.com') ON DUPLICATE KEY UPDATE messages='0' COMMIT SELECT bytes FROM quota_dovecot WHERE username = 'test@testing.com' SELECT messages FROM quota_dovecot WHERE username = 'test@testing.com'
.- And the result also seems to indicate that it's not reading the quota from userdb
- PREAUTH [CAPABILITY IMAP4rev1 LITERAL+ SASL-IR LOGIN-REFERRALS ID ENABLE SORT SORT=DISPLAY THREAD=REFERENCES THREAD=REFS MULTIAPPEND UNSELECT IDLE CHILDREN NAMESPACE UIDPLUS LIST-EXTENDED I18NLEVEL=1 CONDSTORE QRESYNC ESEARCH ESORT SEARCHRES WITHIN CONTEXT=SEARCH LIST-STATUS QUOTA] Logged in as test@testing.com
- QUOTAROOT "Inbox" "user"
- QUOTA "user" (STORAGE 0 1048576) x OK Getquotaroot completed.
It seems to me that dovecot --exec-mail doesn't do the mysql lookups to get the usersdb. Note: attached are my dovecot -n output and the relevant .conf files
On Fri, 2010-07-02 at 10:06 +0200, Joan wrote:
It seems to me that dovecot --exec-mail doesn't do the mysql lookups to get the usersdb.
Yes, you're right. --exec-mail doesn't do a userdb lookup. With v2.0 you could use "imap -u username" and it does a userdb lookup.
Did you try the quota recalculation when logging in normally, instead of with --exec-mail?
On Fri, 2010-07-02 at 10:06 +0200, Joan wrote:
It seems to me that dovecot --exec-mail doesn't do the mysql lookups to get the usersdb.
Yes, you're right. --exec-mail doesn't do a userdb lookup. With v2.0 you could use "imap -u username" and it does a userdb lookup. It's seems I'm always a version before the cool feature :P, it's the
2010/7/2 Timo Sirainen tss@iki.fi: pain of using debian Stable ...
Did you try the quota recalculation when logging in normally, instead of with --exec-mail?
I sent a 5M mail to myself, there's the mail in inbox and the copy to sent (amounting 10M), I connected to the server and manually removed the mail (rm file). After that sending a new mail updates the quota, but it doesn't recalculate it. I only see: UPDATE quota_dovecot SET bytes=bytes+631,messages=messages+1 WHERE username = 'test@testing.com'
After deleting the entry for test@testing.com from the database, the quota gets properly recalculated.
The problem is that I rely on db quota for some accounting scritpts, and the users might not enter to their webmail or download the mail for days.
How could I trigger this quota recalculation? .- Maybe the most practical would be to have a crontab to update the real values from time to time, at least until 2.0 is not available in our environment... .- Any other solution?
On Fri, 2010-07-02 at 14:31 +0200, Joan wrote:
Did you try the quota recalculation when logging in normally, instead of with --exec-mail? I sent a 5M mail to myself, there's the mail in inbox and the copy to sent (amounting 10M), I connected to the server and manually removed the mail (rm file). After that sending a new mail updates the quota, but it doesn't recalculate it.
Right. Quota isn't automatically recalculated if you go manually adding or removing files.
After deleting the entry for test@testing.com from the database, the quota gets properly recalculated.
So the problem exists only with --exec-mail?
The problem is that I rely on db quota for some accounting scritpts, and the users might not enter to their webmail or download the mail for days.
How could I trigger this quota recalculation?
If the problem is only with --exec-mail, you could create a master user that can login to any user's account and triggers the quota recalculation. Something like:
printf "a login destuser*masteruser masterpass\nb getquotaroot inbox\n" | nc localhost 143
http://wiki.dovecot.org/Authentication/MasterUsers
.- Maybe the most practical would be to have a crontab to update the real values from time to time, at least until 2.0 is not available in our environment...
In v2.0 you can do it even more easily :) doveadm quota recalc -u username
2010/7/2 Timo Sirainen tss@iki.fi:
On Fri, 2010-07-02 at 14:31 +0200, Joan wrote:
Did you try the quota recalculation when logging in normally, instead of with --exec-mail? I sent a 5M mail to myself, there's the mail in inbox and the copy to sent (amounting 10M), I connected to the server and manually removed the mail (rm file). After that sending a new mail updates the quota, but it doesn't recalculate it.
Right. Quota isn't automatically recalculated if you go manually adding or removing files. I see, I expected to have something like when I delete the maildirsize file (when using maildir++ quotas) and dovecot automatically recalculates the quota.
After deleting the entry for test@testing.com from the database, the quota gets properly recalculated.
So the problem exists only with --exec-mail? Yes, you're right, the proper quotas don't get calculated with exec-mail and most of the users won't enter ever via webmail and only download mails via pop
The problem is that I rely on db quota for some accounting scritpts, and the users might not enter to their webmail or download the mail for days.
How could I trigger this quota recalculation?
If the problem is only with --exec-mail, you could create a master user that can login to any user's account and triggers the quota recalculation. Something like:
printf "a login destuser*masteruser masterpass\nb getquotaroot inbox\n" | nc localhost 143
http://wiki.dovecot.org/Authentication/MasterUsers Wow, yet another amazing feature of dovecot. This is really a swiss knife mailserver :P I will try to purge the wrong quotas and see what happens when new mail is delivered (it's better no quota than wrong quota)
.- Maybe the most practical would be to have a crontab to update the real values from time to time, at least until 2.0 is not available in our environment...
In v2.0 you can do it even more easily :) doveadm quota recalc -u username I hope I can get there soon :)
Thanks again
participants (2)
-
Joan
-
Timo Sirainen