New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
SDBM_File/GDBM_File errors #12957
Comments
From cowboyatheart@gmail.comCreated by cowboyatheart@gmail.comGDBM_File, and SDBM_File both end early when using each to iterate over a Test script: use strict; # plain old hash # add 100 keys print "plain old hash has " . scalar(keys %hash) . " keys\n"; # iterate/delete # add 100 keys print "sdbm has " . scalar(keys %hash) . " keys\n"; # iterate/delete # add 100 keys # iterate/delete } # add 100 keys print "bdb has " . scalar(keys %hash) . " keys\n"; # iterate/delete Output: plain old hash has 100 keys Perl Info
|
From @jkeenanOn Fri May 10 13:22:59 2013, cowboyatheart@gmail.com wrote:
Can anyone make a determination as to whether this is the same bug as RT |
The RT System itself - Status changed from 'new' to 'open' |
From @jkeenanOn Fri, 10 May 2013 20:22:59 GMT, cowboyatheart@gmail.com wrote:
This persists in perl-5.28.0 and blead. See attachments. -- |
From @jkeenan#!/usr/bin/env perl my $expected; { # add 100 keys $expected = 100; # iterate/delete { # add 100 keys $expected = 100; # iterate/delete { # add 100 keys # iterate/delete { # add 100 keys $expected = 100; # iterate/delete done_testing; |
From @jkeenan# Failed test 'deleted 50 keys in sdbm' Test Summary Report 117953-sdbm-gdbm-file.t (Wstat: 512 Tests: 8 Failed: 2) |
From @iabynOn Tue, Nov 20, 2018 at 12:39:26PM -0800, James E Keenan via RT wrote:
Zefram added this documentation to GDBM_File.pm with Unlike Perl's built-in hashes, it is not safe to C<delete> the current I don't know whether a similar restriction applies to the other *DBM -- |
In gdbm, you cannot delete elements from the database while iterating over it. It is stated both in the GDBM Manual:
and in the documentation to GDBM_File:
I suspect the same is true for SDBM_File as well. |
Thanks for looking into this. Given what you say, should we infer that the original poster's complaint back in 2013 should be rejected? Should we update the documentation to reflect this? |
Relevant to the above:
|
Yes, I think so.
The GDBM_File documentation already says so clearly, as I've shown above. I'm not sure about SDBM_File, though. |
Sorry, but it actually does not. That statement was there until commit e03e7cdb6e3, which took care of this. |
Sorry, I was probably looking at the documentation from the 5.32 vendor perl on FreeBSD-12. |
From looking at the sdbm source it doesn't support deleting the current key and continuing from the next key, I'd expect it to skip a key. If a key is deleted, modified or inserted on some other page of the file it would end up returning some random key, since it depends on the page buffer not being modified. Since we ship the SDBM source, which we've extensively modified, we could fix that, but I'm not sure it's worth the trouble. Such a change wouldn't be completely trivial. |
I believe it would be a great feature. However, in hashed databases, ensuring that each key is visited (and visited exactly once) in presence of concurrent deletions or insertions is far from being trivial. A tentative implementation of this for gdbm required a considerable amount of changes and introduction of additional API call (gdbm_lastkey) to mark end of iteration. It is still in experimental stage, and far from being finished. |
My assessment upon reading the last several posts in this ticket is that the original poster's expectations (back in 2013!) were incorrect and that attempting to delete keys while iterating over a hash tied to these two kinds of non-SQL databases is a Bad Thing. Hence, we can close this ticket. If someone wants to suggest feature or documentation improvements, we can do that in a new ticket. Thank you very much. |
Hi James,
My assessment upon reading the last several posts in this ticket is
that the original poster's expectations (back in 2013!)
Can the tracker be configured so that I receive notifications when a
new GDBM_File ticket is opened? This could help avoid such long delays.
Regards,
Sergey
|
I don't see a way to do that with github. |
Migrated from rt.perl.org#117953 (status was 'open')
Searchable as RT117953$
The text was updated successfully, but these errors were encountered: