From: <ai...@gm...> - 2007-03-09 15:45:50
|
Hello, here is an Ubuntu Server box (6.06) with python 2.4, python-ldap 2.0.4, and slapd 2.2.26 - all of these from Ubuntu package. Here is an application, what runs by crontab in every minutes. It looks a list, and if list was modified, it modifies LDAP tree. (List generated by a directory's items.) Early version of that app use to add an entry OBJECT.add() method, but it was not sync mode, and crontabs 1 minute was not enough to sync tree. So I changed to add_s(), and then my application adds entry sync correctly. But now, when original list modified, and app runs by crontab, I get this error: Traceback (most recent call last): File "/usr/local/checkftpdir/chkdir.py", line 43, in ? L.addEntry(d, base, '') File "/usr/local/checkftpdir/Ldapfunctions.py", line 61, in addEntry self.l.add_s(_dn, ldif) File "/usr/lib/python2.4/site-packages/ldap/ldapobject.py", line 163, in add_s self.result(msgid,all=1,timeout=self.timeout) File "/usr/lib/python2.4/site-packages/ldap/ldapobject.py", line 399, in result res_type,res_data,res_msgid = self.result2(msgid,all,timeout) File "/usr/lib/python2.4/site-packages/ldap/ldapobject.py", line 405, in result2 return self._ldap_call(self._l.result2,msgid,all,timeout) File "/usr/lib/python2.4/site-packages/ldap/ldapobject.py", line 94, in _ldap_call result = func(*args,**kwargs) ldap.INVALID_DN_SYNTAX: {'info': 'invalid DN', 'desc': 'Invalid DN syntax'} and entry added correctly to tree. BUT, when I run it interactive, I _don't_get_any_ error. del_s() method doesn't give any error, just add_s(). Any suggestion? Thank you: a. |
From: <mi...@st...> - 2007-03-09 19:17:10
|
Ervin Hegedüs wrote: > > File "/usr/local/checkftpdir/Ldapfunctions.py", line 61, in addEntry > self.l.add_s(_dn, ldif) > File "/usr/lib/python2.4/site-packages/ldap/ldapobject.py", line 163, in add_s > self.result(msgid,all=1,timeout=self.timeout) > File "/usr/lib/python2.4/site-packages/ldap/ldapobject.py", line > 399, in result > res_type,res_data,res_msgid = self.result2(msgid,all,timeout) > File "/usr/lib/python2.4/site-packages/ldap/ldapobject.py", line > 405, in result2 > return self._ldap_call(self._l.result2,msgid,all,timeout) > File "/usr/lib/python2.4/site-packages/ldap/ldapobject.py", line 94, > in _ldap_call result = func(*args,**kwargs) > ldap.INVALID_DN_SYNTAX: {'info': 'invalid DN', 'desc': 'Invalid DN syntax'} This is an error the server sends back. Probably you're generating a DN with invalid syntax. I'd recommend to set trace_level=2 with ldap.initialize() to see what the python-ldap API receives from your script. Ciao, Michael. |
From: <ai...@gm...> - 2007-03-09 20:22:05
|
Hello, > > File "/usr/local/checkftpdir/Ldapfunctions.py", line 61, in addEntry > > self.l.add_s(_dn, ldif) [...] > > File "/usr/lib/python2.4/site-packages/ldap/ldapobject.py", line 94, > > in _ldap_call result = func(*args,**kwargs) > > ldap.INVALID_DN_SYNTAX: {'info': 'invalid DN', 'desc': 'Invalid DN syntax'} > > This is an error the server sends back. Probably you're generating a DN > with invalid syntax. I'd recommend to set trace_level=2 with > ldap.initialize() to see what the python-ldap API receives from your script. I'm not sure about it - as I wrote when I run script from system shell (I mean: interactively), then script doesn't drop any exception. I try to print out the DN value, what I give to the function as first argument, and it looks like a normally DN, eg.: cn=airtest,ou=ftp,o=company,dc=domain,dc=com. There aren't any spaces, or other chars, what I miss then. By the way: I try to set up those trace_level, may be it will be more informative... thanks: a. |
From: Chaos E. <cha...@gm...> - 2007-03-10 04:33:29
|
hello there, Since your script is run by cron every one minute, i wonder that do you have any lock mechanisms to prevent more than one instance of your script to start? some buggy or mis-configured ldapserver can not work properly when large amounts of write operations come simultaneously. What I suggest is carefully re-design your script. use some lock mechanisms and some queue technologies. On 3/10/07, Ervin Heged=FCs <ai...@gm...> wrote: > Hello, > > > > File "/usr/local/checkftpdir/Ldapfunctions.py", line 61, in addEntr= y > > > self.l.add_s(_dn, ldif) > [...] > > > File "/usr/lib/python2.4/site-packages/ldap/ldapobject.py", line 94= , > > > in _ldap_call result =3D func(*args,**kwargs) > > > ldap.INVALID_DN_SYNTAX: {'info': 'invalid DN', 'desc': 'Invalid DN sy= ntax'} > > > > This is an error the server sends back. Probably you're generating a DN > > with invalid syntax. I'd recommend to set trace_level=3D2 with > > ldap.initialize() to see what the python-ldap API receives from your sc= ript. > > I'm not sure about it - as I wrote when I run script from system shell (I= mean: > interactively), then script doesn't drop any exception. I try to print > out the DN > value, what I give to the function as first argument, and it looks > like a normally > DN, eg.: cn=3Dairtest,ou=3Dftp,o=3Dcompany,dc=3Ddomain,dc=3Dcom. > > There aren't any spaces, or other chars, what I miss then. > > By the way: I try to set up those trace_level, may be it will be more > informative... > > thanks: > > a. > > ------------------------------------------------------------------------- > Take Surveys. Earn Cash. Influence the Future of IT > Join SourceForge.net's Techsay panel and you'll get the chance to share y= our > opinions on IT & business topics through brief surveys-and earn cash > http://www.techsay.com/default.php?page=3Djoin.php&p=3Dsourceforge&CID=3D= DEVDEV > _______________________________________________ > Python-LDAP-dev mailing list > Pyt...@li... > https://lists.sourceforge.net/lists/listinfo/python-ldap-dev > -- Best Regards Chaos Eternal |
From: <ai...@gm...> - 2007-03-10 08:37:52
|
Hello, > Since your script is run by cron every one minute, i wonder that do > you have any lock mechanisms to prevent more than one instance of your > script to start? It's very interesting theory... > some buggy or mis-configured ldapserver can not work > properly when large amounts of write operations come simultaneously. Hmmm... I think there is _no_ other thread (or process), what wants to write to database. > What I suggest is carefully re-design your script. use some lock > mechanisms and some queue technologies. I don't think so it any LDAP client requires this feature. It's like any SQL server needs to lock a table, when a client wants to insert a simple record. (Don't wrong me: I know, there are many cases need to lock a table, but IMHO that's for other cases) Handle the clients requests is the most common function of any kind of "database" servers - in this case the database word means any kind of structure-handle application. :) But this is a flame-way, sorry. Back to my problem: on that machine there is just one user, who gets access to LDAP db, and that user write to db _only_ when original list was modified. That's occurrence is 1-5 event per week...(!) Thanks: a. |
From: <mi...@st...> - 2007-03-11 11:39:08
|
Chaos Eternal wrote: > hello there, > Since your script is run by cron every one minute, i wonder that do > you have any lock mechanisms to prevent more than one instance of your > script to start? some buggy or mis-configured ldapserver can not work > properly when large amounts of write operations come simultaneously. Very unlikely. This would be a really brain-dead LDAP server. > What I suggest is carefully re-design your script. use some lock > mechanisms and some queue technologies. LDAP add and modify operations are atomic. The LDAP server takes care of database locking. And python-ldap takes care of locks for using a LDAP connection in several threads. Ciao, Michael. |
From: Chaos E. <cha...@gm...> - 2007-03-11 05:06:01
|
Helo On 3/10/07, Ervin Heged=FCs <ai...@gm...> wrote: > Hello, > > > Since your script is run by cron every one minute, i wonder that do > > you have any lock mechanisms to prevent more than one instance of your > > script to start? > It's very interesting theory... chaos@felucia:~$ ps afx|grep sleep 25170 ? Ss 0:00 | \_ sleep 300 25246 ? Ss 0:00 | \_ sleep 300 25324 ? Ss 0:00 | \_ sleep 300 25403 ? Ss 0:00 | \_ sleep 300 25486 ? Ss 0:00 \_ sleep 300 25530 pts/5 S+ 0:00 | \_ grep sleep chaos@felucia:~$ crontab -l # m h dom mon dow command * * * * * sleep 300 have i missed something? > > > some buggy or mis-configured ldapserver can not work > > properly when large amounts of write operations come simultaneously. > Hmmm... I think there is _no_ other thread (or process), what wants to > write to database. Still dont get it? > > > What I suggest is carefully re-design your script. use some lock > > mechanisms and some queue technologies. > > I don't think so it any LDAP client requires this feature. It's like any > SQL server needs to lock a table, when a client wants to insert a > simple record. > (Don't wrong me: I know, there are many cases need to lock a table, > but IMHO that's for other cases) > > Handle the clients requests is the most common function of any kind > of "database" servers - in this case the database word means any kind > of structure-handle application. :) But this is a flame-way, sorry. > > Back to my problem: on that machine there is just one user, who gets > access to LDAP db, and that user write to db _only_ when original list > was modified. That's occurrence is 1-5 event per week...(!) If the event only occures 1-5 time per-week, why you make your script run every minute? > > Thanks: > a. > > ------------------------------------------------------------------------- > Take Surveys. Earn Cash. Influence the Future of IT > Join SourceForge.net's Techsay panel and you'll get the chance to share y= our > opinions on IT & business topics through brief surveys-and earn cash > http://www.techsay.com/default.php?page=3Djoin.php&p=3Dsourceforge&CID=3D= DEVDEV > _______________________________________________ > Python-LDAP-dev mailing list > Pyt...@li... > https://lists.sourceforge.net/lists/listinfo/python-ldap-dev > --=20 Best Regards Chaos Eternal |
From: <mi...@st...> - 2007-03-11 11:37:54
|
Chaos Eternal wrote: >> >> Back to my problem: on that machine there is just one user, who gets >> access to LDAP db, and that user write to db _only_ when original list >> was modified. That's occurrence is 1-5 event per week...(!) > > If the event only occures 1-5 time per-week, why you make your script > run every minute? I guess he does not want to have a longer latency for passing the modifications to the LDAP server and there's no other possibility to trigger running the script event-based when the original list is actually updated. Ciao, Michael. |
From: <mi...@st...> - 2007-03-11 11:54:22
|
Ervin Hegedüs wrote: > > I'm not sure about it - as I wrote when I run script from system shell (I mean: > interactively), then script doesn't drop any exception. If your script behaves differently when invoked from system shell then their is another problem. > I try to print > out the DN > value, what I give to the function as first argument, and it looks > like a normally > DN, eg.: cn=airtest,ou=ftp,o=company,dc=domain,dc=com. ^^^ I guess the trailing dot is the end of the sentence and not part of your DN? > By the way: I try to set up those trace_level, may be it will be more > informative... I recommend this since you see then which values get really passed into python-ldap. Ciao, Michael. |
From: <ai...@gm...> - 2007-03-11 19:55:15
|
Hello there, > If your script behaves differently when invoked from system shell then > their is another problem. I think that - but where could be that problem? > > DN, eg.: cn=airtest,ou=ftp,o=company,dc=domain,dc=com. > ^^^ > I guess the trailing dot is the end of the sentence and not part of your DN? No, that dot is the 'end of the sentence', not part of DN. > I recommend this since you see then which values get really passed into > python-ldap. thanks, I will try this... a. |
From: <ai...@gm...> - 2007-03-11 20:16:49
|
Hello, > chaos@felucia:~$ ps afx|grep sleep > 25170 ? Ss 0:00 | \_ sleep 300 > 25246 ? Ss 0:00 | \_ sleep 300 > 25324 ? Ss 0:00 | \_ sleep 300 > 25403 ? Ss 0:00 | \_ sleep 300 > 25486 ? Ss 0:00 \_ sleep 300 > 25530 pts/5 S+ 0:00 | \_ grep sleep > chaos@felucia:~$ crontab -l > # m h dom mon dow command > * * * * * sleep 300 > > have i missed something? Nothing. Or rather yes. :) I didn't wrote, the run-time of script usually less than 1sec. Here is my output: # ps axf | grep chkdir.py 24859 pts/2 S+ 0:00 \_ grep chkdir.py > > Hmmm... I think there is _no_ other thread (or process), what wants to > > write to database. > > Still dont get it? no, I don't. > If the event only occures 1-5 time per-week, why you make your script > run every minute? Because event occurs randomly: sometime it occur monday morning, sometime friday evening - sometime it occurs in workhours, sometime out of workhours. This is not so simple.... Thank you: a. |
From: Chaos E. <cha...@gm...> - 2007-03-12 02:05:54
|
hi, Obviously , you didn't aware when your script didn't finish in one minute the cron would start another script doing the same job. As you have mentioned, 1 minute was not enough to sync tree. I think that is the core problem. So my suggestion is , when your script starts, aquire a lock, then do all the sync things, and release the lock before exit. Hope my suggestion can help. On 3/12/07, Ervin Heged=FCs <ai...@gm...> wrote: > Hello, > > > chaos@felucia:~$ ps afx|grep sleep > > 25170 ? Ss 0:00 | \_ sleep 300 > > 25246 ? Ss 0:00 | \_ sleep 300 > > 25324 ? Ss 0:00 | \_ sleep 300 > > 25403 ? Ss 0:00 | \_ sleep 300 > > 25486 ? Ss 0:00 \_ sleep 300 > > 25530 pts/5 S+ 0:00 | \_ grep sleep > > chaos@felucia:~$ crontab -l > > # m h dom mon dow command > > * * * * * sleep 300 > > > > have i missed something? > Nothing. Or rather yes. :) > > I didn't wrote, the run-time of script usually less than 1sec. > > Here is my output: > # ps axf | grep chkdir.py > 24859 pts/2 S+ 0:00 \_ grep chkdir.py > > > > Hmmm... I think there is _no_ other thread (or process), what wants t= o > > > write to database. > > > > Still dont get it? > no, I don't. > > > If the event only occures 1-5 time per-week, why you make your script > > run every minute? > Because event occurs randomly: sometime it occur monday morning, > sometime friday evening - sometime it occurs in workhours, sometime > out of workhours. > > This is not so simple.... > > > Thank you: > > a. > > ------------------------------------------------------------------------- > Take Surveys. Earn Cash. Influence the Future of IT > Join SourceForge.net's Techsay panel and you'll get the chance to share y= our > opinions on IT & business topics through brief surveys-and earn cash > http://www.techsay.com/default.php?page=3Djoin.php&p=3Dsourceforge&CID=3D= DEVDEV > _______________________________________________ > Python-LDAP-dev mailing list > Pyt...@li... > https://lists.sourceforge.net/lists/listinfo/python-ldap-dev > --=20 Best Regards Chaos Eternal |