Re: [Dovecot] quota dict mysql not working (2.0.beta4)

2010-05-26 Thread e-frog
On 26.05.2010 16:32, wrote Timo Sirainen:
> On Mon, 2010-05-24 at 00:47 +0400, Andrey Melnikov wrote:
> 
>> after mysql_query() - mysql return right data (affected rows = 1), but
>> there is no result to store (this is UPDATE/DELETE query),
>> next unconditional call to mysql_store_result() return nothing (right,
>> there no result) and reset affected_rows to -1ULL.
>>
>> You should modify driver_mysql_query_s() to call mysql_field_count()
>> first, to ensure - there is any data to read or no.
> 
> But the whole point of the code is to get number of affected rows for
> previous UPDATE, so that if there is no quota row for user, the quota
> gets recalculated.
> 
> This fixed it for my tests:
> http://hg.dovecot.org/dovecot-2.0/rev/0c15a760dab8
> 

Yes, this fixed it. Thanks Timo!


Re: [Dovecot] quota dict mysql not working (2.0.beta4)

2010-05-26 Thread Timo Sirainen
On Mon, 2010-05-24 at 00:47 +0400, Andrey Melnikov wrote:

> after mysql_query() - mysql return right data (affected rows = 1), but
> there is no result to store (this is UPDATE/DELETE query),
> next unconditional call to mysql_store_result() return nothing (right,
> there no result) and reset affected_rows to -1ULL.
> 
> You should modify driver_mysql_query_s() to call mysql_field_count()
> first, to ensure - there is any data to read or no.

But the whole point of the code is to get number of affected rows for
previous UPDATE, so that if there is no quota row for user, the quota
gets recalculated.

This fixed it for my tests:
http://hg.dovecot.org/dovecot-2.0/rev/0c15a760dab8




Re: [Dovecot] quota dict mysql not working (2.0.beta4)

2010-05-25 Thread e-frog
On 20.05.2010 19:52, wrote Timo Sirainen:
> On 5.5.2010, at 20.34, Michael Kliewe wrote:
> 
>> -- dovecot-2.0.beta4-25/src/lib-sql/driver-mysql.c 2010-04-02 
>> 16:47:13.0 +0400
>> +++ dovecot-2.0.beta4/src/lib-sql/driver-mysql.c2010-05-01 
>> 03:29:02.0 +0400
>> @@ -630,7 +631,9 @@
>>   struct mysql_result *my_result = (struct mysql_result *)result;
>>
>>   rows = mysql_affected_rows(my_result->conn->mysql);
>> -   i_assert(rows != (my_ulonglong)-1);
>> +   if (mysql_errno(my_result->conn->mysql))
>> +   i_assert(rows != (my_ulonglong)-1);
>> +   else rows = 0;
>>   *ctx->head->affected_rows = rows;
>>   }
>>   sql_result_unref(result);
> 
> The above patch works, but it doesn't really fix the cause of the bug. This 
> should fix it in a cleaner way: 
> http://hg.dovecot.org/dovecot-2.0/rev/1e45b463b93a

Hhm, this doesn't seem to fix it for me. Just tested with the latest hg
version (f7527971fed0) and hitting the assertion again. Unfortunately I
don't manage to get a "real" core dump from the dictionary process, just
the backtrace attached.

May 25 19:51:20 ubuntu-test dovecot: master: Dovecot v2.0.beta5 (f7527971fed0) 
starting up
...
May 25 19:53:34 ubuntu-test dovecot: master: Error: service(dict): child 9755 
killed with signal 6 (core not dumped)
May 25 19:53:34 ubuntu-test dovecot: dict: Panic: file driver-mysql.c: line 482 
(transaction_send_query): assertion failed: (rows != (my_ulonglong)-1)
May 25 19:53:34 ubuntu-test dovecot: dict: Error: Raw backtrace: 
/usr/lib/dovecot/libdovecot.so.0(+0x33dd1) [0xb77a2dd1] -> 
/usr/lib/dovecot/libdovecot.so.0(+0x33e3f) [0xb77a2e3f] -> /usr/
lib/dovecot/libdovecot.so.0(i_error+0) [0xb777d70e] -> dovecot/dict() 
[0x805219a] -> dovecot/dict() [0x805220f] -> 
dovecot/dict(sql_transaction_commit_s+0x20) [0x804f9e0] -> dovecot/dict()
 [0x805144e] -> dovecot/dict(sql_transaction_commit_s+0x20) [0x804f9e0] -> 
dovecot/dict() [0x804e982] -> 
/usr/lib/dovecot/libdovecot.so.0(dict_transaction_commit_async+0x2f) 
[0xb778285f] -
> dovecot/dict() [0x804cc40] -> dovecot/dict() [0x804c6ad] -> 
> /usr/lib/dovecot/libdovecot.so.0(io_loop_handler_run+0xe2) [0xb77af3a2] -> 
> /usr/lib/dovecot/libdovecot.so.0(io_loop_run+0x30)
[0xb77ae3f0] -> /usr/lib/dovecot/libdovecot.so.0(master_service_run+0x2a) 
[0xb779bb5a] -> dovecot/dict(main+0x19c) [0x804d30c] -> 
/lib/tls/i686/cmov/libc.so.6(__libc_start_main+0xe6) [0xb7
379bd6] -> dovecot/dict() [0x804c391]
May 25 19:53:34 ubuntu-test dovecot: lmtp(9754): Error: 
read(/var/run/dovecot/dict) failed: Remote disconnected
May 25 19:53:34 ubuntu-test dovecot: lmtp(9754): Disconnect from local: Client 
quit
...

Re: [Dovecot] quota dict mysql not working (2.0.beta4)

2010-05-20 Thread Timo Sirainen
On 5.5.2010, at 20.34, Michael Kliewe wrote:

> -- dovecot-2.0.beta4-25/src/lib-sql/driver-mysql.c 2010-04-02 
> 16:47:13.0 +0400
> +++ dovecot-2.0.beta4/src/lib-sql/driver-mysql.c2010-05-01 
> 03:29:02.0 +0400
> @@ -630,7 +631,9 @@
>   struct mysql_result *my_result = (struct mysql_result *)result;
> 
>   rows = mysql_affected_rows(my_result->conn->mysql);
> -   i_assert(rows != (my_ulonglong)-1);
> +   if (mysql_errno(my_result->conn->mysql))
> +   i_assert(rows != (my_ulonglong)-1);
> +   else rows = 0;
>   *ctx->head->affected_rows = rows;
>   }
>   sql_result_unref(result);

The above patch works, but it doesn't really fix the cause of the bug. This 
should fix it in a cleaner way: 
http://hg.dovecot.org/dovecot-2.0/rev/1e45b463b93a



Re: [Dovecot] quota dict mysql not working (2.0.beta4)

2010-05-05 Thread Michael Kliewe

Ok, found the problem and fixed it.

Two things had to be done:


master.cnf

service dict {
 extra_groups = vmail
 unix_listener dict {
   group = vmail
   mode = 0660
 }
}


After restart I got another problem which I fixed with this patch  
(Thanks Andrey!)



-- dovecot-2.0.beta4-25/src/lib-sql/driver-mysql.c 2010-04-02  
16:47:13.0 +0400
+++ dovecot-2.0.beta4/src/lib-sql/driver-mysql.c2010-05-01  
03:29:02.0 +0400

@@ -630,7 +631,9 @@
   struct mysql_result *my_result = (struct mysql_result  
*)result;


   rows = mysql_affected_rows(my_result->conn->mysql);
-   i_assert(rows != (my_ulonglong)-1);
+   if (mysql_errno(my_result->conn->mysql))
+   i_assert(rows != (my_ulonglong)-1);
+   else rows = 0;
   *ctx->head->affected_rows = rows;
   }
   sql_result_unref(result);


I also wrote Timo an email regarding this problem. Hope he fixes it  
soon.


Michael


On May 5, 2010, at 3:11 PM, Michael Kliewe wrote:


Hi,

I have a problem when setting up the quota dict plugin. I get this  
error in my logfile when trying to store a draft (APPEND):


May 05 14:44:53 imap(t...@domain.de): Error: net_connect_unix(/usr/ 
local/var/run/dovecot/dict) failed: Permission denied
May 05 14:44:53 imap(t...@domain.de): Error: Internal quota  
calculation error


The file is there:

u...@imap01:/$ ls -al /usr/local/var/run/dovecot/
total 20
drwxr-xr-x 4 rootroot4096 2010-05-05 14:44 .
drwxr-xr-x 3 rootroot4096 2010-04-20 18:50 ..
srw--- 1 rootroot   0 2010-05-05 14:44 anvil
srw--- 1 rootroot   0 2010-05-05 14:44 anvil-auth-penalty
srw--- 1 rootroot   0 2010-05-05 14:44 auth-client
srw--- 1 rootroot   0 2010-05-05 14:44 auth-master
srw--- 1 rootroot   0 2010-05-05 14:44 auth-userdb
srw--- 1 dovecot root   0 2010-05-05 14:44 auth-worker
srw--- 1 rootroot   0 2010-05-05 14:44 config
srw--- 1 rootroot   0 2010-05-05 14:44 dict
srw-rw-rw- 1 rootroot   0 2010-05-05 14:44 dns-client
lrwxrwxrwx 1 rootroot  35 2010-05-05 14:44 dovecot.conf -> / 
usr/local/etc/dovecot/dovecot.conf

drwxr-xr-x 2 rootroot4096 2010-04-20 18:50 empty
srw-rw-rw- 1 rootroot   0 2010-05-05 14:44 lmtp
drwxr-x--- 2 rootdovecot 4096 2010-05-05 14:44 login
-rw--- 1 rootroot   5 2010-05-05 14:44 master.pid

What is going on there, how can I fix this?

Michael