X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=blobdiff_plain;f=lib%2FDBM%2FDeep.pod;h=5179182ede023209b993affa19731e1f1711a41d;hb=065e75fbf63183feddc2dd69a860026996033949;hp=33b7eb9c83227d9129497ebf18a46cc7afa69b01;hpb=c767a64cd4ec349539460b4bb074ccbe2811861a;p=dbsrgits%2FDBM-Deep.git diff --git a/lib/DBM/Deep.pod b/lib/DBM/Deep.pod index 33b7eb9..5179182 100644 --- a/lib/DBM/Deep.pod +++ b/lib/DBM/Deep.pod @@ -1023,6 +1023,26 @@ been an C<$x> or what memory location to assign an C to. B This does not affect importing because imports do a walk over the reference to be imported in order to explicitly leave it untied. +=head2 Stale References + +If you take a reference to an array or hash from the database, it is tied +to the database itself. This means that if the datum in question is subsequently deleted from the database, the reference to it will point to +an invalid location and unpredictable things will happen if you try to use +it. + +So a seemingly innocuous piece of code like this: + + my %hash = %{ $db->{some_hash} }; + +can fail if another process deletes or clobbers C<< $db->{some_hash} >> +while the data are being extracted, since S> is not atomic. +(This actually happened.) The solution is to lock the database before +reading the data: + + $db->lock_exclusive; + my %hash = %{ $db->{some_hash} }; + $db->unlock; + =head1 CODE COVERAGE L is used to test the code coverage of the tests. Below is the