Martin Regner
2010-Mar-19 18:25 UTC
[Xapian-discuss] xapian-tcpsrv php in real fastcgi loop
Hello, i'm fresh new to xapian (and impressed.. fast, faster, xapian). And so i have a problem with no solution at the moment. I have a webapp based on php5 in a special fastcgi loop environment (thus there are some loops spawned handling multiple requests so there is no need for php to recreate classes and Objects all the time). I implemented a xapian wrapper class to access a remote database provided by xapian-tcpsrv using this command: xapian-tcpsrv --port 5050 --writable /var/lib/xapian/objects/ I indexed all ths stuff we need and tested the search. Fast and furious, but i randomly get: REMOTE:Unable to acquire database write lock on /var/lib/xapian/objects/: already locked First, this is a connection tried to open with Xapian::remote_open. So i think it should'nt create a write lock. Otherwise, i started xapian-tcpsrv with -- writable, do i have to start to instances on the same directory, one writable and one not? Second, if i understand the examples right i have to unset the database object to get the lock released. But i don't want to close the connection. I Just want to release the lock if possible. Is there any convenient way to let any lock go if everything is done in a process? Third, if there is a lock why is there a exception thrown? Wouldn't it be better to wait for the lock a well defined time similar to database locks for example? I think i do something (or some things) wrong here, but i don't know what it is. Any help greatly appreciated Greetings so far DonMartio
Martin Regner
2010-Mar-20 13:51 UTC
[Xapian-discuss] xapian-tcpsrv php in real fastcgi loop
Hello again, i've gone a little bit further by reseting the database objects every loop. But i still got randomly lock exceptions and netstat gives me connections in CLOSE_WAIT forever. After lighty restart they are gone. Is there any way to force a close on the connection? Greetings again DonMartio Am Freitag, 19. M?rz 2010 19:25:35 schrieb Martin Regner:> Hello, > > i'm fresh new to xapian (and impressed.. fast, faster, xapian). And so i > have a problem with no solution at the moment. > > I have a webapp based on php5 in a special fastcgi loop environment (thus > there are some loops spawned handling multiple requests so there is no need > for php to recreate classes and Objects all the time). > > I implemented a xapian wrapper class to access a remote database provided > by xapian-tcpsrv using this command: > > xapian-tcpsrv --port 5050 --writable /var/lib/xapian/objects/ > > I indexed all ths stuff we need and tested the search. Fast and furious, > but i randomly get: > > REMOTE:Unable to acquire database write lock on /var/lib/xapian/objects/: > already locked > > First, this is a connection tried to open with Xapian::remote_open. So i > think it should'nt create a write lock. Otherwise, i started xapian-tcpsrv > with -- writable, do i have to start to instances on the same directory, > one writable and one not? > > Second, if i understand the examples right i have to unset the database > object to get the lock released. But i don't want to close the connection. > I Just want to release the lock if possible. Is there any convenient way > to let any lock go if everything is done in a process? > > Third, if there is a lock why is there a exception thrown? Wouldn't it be > better to wait for the lock a well defined time similar to database locks > for example? > > I think i do something (or some things) wrong here, but i don't know what > it is. > > Any help greatly appreciated > > Greetings so far > DonMartio > > > _______________________________________________ > Xapian-discuss mailing list > Xapian-discuss at lists.xapian.org > http://lists.xapian.org/mailman/listinfo/xapian-discuss
On Fri, Mar 19, 2010 at 07:25:35PM +0100, Martin Regner wrote:> First, this is a connection tried to open with Xapian::remote_open. So i > think it should'nt create a write lock. Otherwise, i started xapian-tcpsrv > with -- writable, do i have to start to instances on the same directory, one > writable and one not?Yes, you do for Xapian 1.0.x. Xapian 1.1.0 fixed this: http://trac.xapian.org/ticket/145> Second, if i understand the examples right i have to unset the database > object to get the lock released. But i don't want to close the connection. I > Just want to release the lock if possible. Is there any convenient way to let > any lock go if everything is done in a process?Again, not in 1.0.x. It can be a problem as it is quite easy to inadvertently keep a reference to the database (either through another Xapian object, or with some scripting languages because there's a garbage collection phase which needs to run before the C++ destructor actually gets called). 1.1.0 added a Database::close() method to close a database right away, and release any lock and close any network connections.> Third, if there is a lock why is there a exception thrown? Wouldn't it be > better to wait for the lock a well defined time similar to database locks for > example?Sometimes you don't want to wait, but it would be useful to be able to specify that you want the attempt to block until it can get a write lock. There's already an open ticket for this: http://trac.xapian.org/ticket/275 Cheers, Olly