![]() | |
#1
| |||
| |||
|
#2
| |||
| |||
|
|
I don't quite understand your email. You ask if there is a way to have non-blocking locks in CDB, but then you say that at the point I would expect a block, you do not block but get an EINVAL error return. |
#3
| |||
| |||
|
|
Nathan, there is no no-blocking option with the Perl interface with CDB. If you are getting a EINVAL error, it sounds like you are passing db_cursor an invalid argument. Can we have a look at the code? cheers PAul |
#4
| |||
| |||
|
|
I'm not aware of any OSX issues with my Perl interface. Whether there are any problems with Berkeley DB itself, I don't know. Perhaps someone from Sleepycat could comment. I've tried your code on Soaris and it seems to work fine. When I fire up multiple instances of the script, only one will get the lock. When that process is killed, one of the other blocked processes acquires the lock. |
|
Also, what is the variable "ix"? I can't find its declaration or when it is assigned. From BerkeleyDB.xs line 2811: if (ix == 1 && db->cdb_enabled) { #ifdef AT_LEAST_DB_3 flags = DB_WRITECURSOR; #else flags = DB_RMW; #endif } That code is used internally when you associate a Perl hash with a Berkeley DB database and you write something like this %hash = () ; Application code like yours that uses db_cursor will not execute that code (the ix variable will always be 0). |
|
My tests on FreeBSD appear to be working though, so I don't think that DB_WRITECURSOR is actually being set on every cursor? That would not be good I don't think? If you are referring to the code you posted, then DB_WRITECURSOR *is* being set on every cursor. Is there a a reason why you think it isn't behaving properly on FreeBSD? |
#5
| |||
| |||
|
|
In article <22fa329d.0308150020.7c2cd9b3 (AT) posting (DOT) google.com>, Paul.Marquess (AT) btinternet (DOT) com (Paul Marquess) writes: I'm not aware of any OSX issues with my Perl interface. Whether there are any problems with Berkeley DB itself, I don't know. Perhaps someone from Sleepycat could comment. I've tried your code on Soaris and it seems to work fine. When I fire up multiple instances of the script, only one will get the lock. When that process is killed, one of the other blocked processes acquires the lock. That is what happens when I test on FreeBSD as well. But when I test it on OSX then the second invocation of the script fails as described earlier on this thread. This is discouraging since I have been developing on OSX based on Apples sales pitch "it's based on FreeBSD". |
|
My tests on FreeBSD appear to be working though, so I don't think that DB_WRITECURSOR is actually being set on every cursor? That would not be good I don't think? If you are referring to the code you posted, then DB_WRITECURSOR *is* being set on every cursor. Is there a a reason why you think it isn't behaving properly on FreeBSD? Sorry that I was not very clear on this. Since I did not know the functionality of ix, then I was concerned that the DB_WRITECURSOR was being set for me by BerkeleyDB on every cursor. I have a second script that is identical to the first but without the DB_WRITECURSOR to test if read and write locks play together properly. |
|
Still no joy on OSX though. Any hints as to where to look would be helpful, but I can't spend a lot of time spinning my wheels here. I may have to dump OSX for development work for a while. It has been a little problematic in other ways as well. |
#6
| |||
| |||
|
|
When you got the EINVAL error, was that from $! or $BerkeleyDB::Error ? Can you run the test again and see what the values of both are please? |
|
I wonder if this is a signal handling issue? Lets see if we can remove it from the equation. |
#7
| |||
| |||
|
|
Here is a variation on your code, that replaces the signal handler with a prompt for input - so the script will hold the lock until you press return. Try running multiple instances and see if there is the same problem. O.K. So I ran your modified script and this brings up another odity in |
#8
| |||
| |||
|
#9
| |||
| |||
|
|
In article <22fa329d.0308160049.7936a943 (AT) posting (DOT) google.com>, Paul.Marquess (AT) btinternet (DOT) com (Paul Marquess) writes: Here is a variation on your code, that replaces the signal handler with a prompt for input - so the script will hold the lock until you press return. Try running multiple instances and see if there is the same problem. O.K. So I ran your modified script and this brings up another odity in OSX. The first time I run the script it runs exactly as I would expect (the db file already exists before this first invocation). Then, when I run it the second time, it gives error 22 on db_create(). It does this on my OSX machine when I pass DB_CREATE as a flag to ::Btree. I can't figure this one out either. The first one runs fine, then the second one won't run unless I remove DB_CREATE. Anyway, after I removed DB_CREATE flag, then I get exactly the same thing: "db_cursor returned 22: Invalid argument, Successful return: 0" /Nathan. P.S. I wonder if this has to do with my db installation on OSX. what I did was steel the tarball from my FreeBSD ports collection and just build it on OSX. It seemed to build fine, but I'm going to try a fresh build and see if that helps. |
#10
| |||
| |||
|
|
Is it possible that when I built the BerkeleyDB perl module that it linked against the static libraries instead of the dynamic ones and that is causing my trouble? How can I verify this? |
![]() |
| Thread Tools | |
| Display Modes | |
| |