Skip Menu |

This queue is for tickets about the Data-Throttler CPAN distribution.

Report information
The Basics
Id: 80127
Status: resolved
Priority: 0/
Queue: Data-Throttler

People
Owner: Nobody in particular
Requestors: NHORNE [...] cpan.org
Cc:
AdminCc:

Bug Information
Severity: Normal
Broken in: 0.05
Fixed in: (no value)



Subject: YAML_LOAD_WARN_DUPLICATE_KEY in try_push
Sometimes (very rarely, about once a fortnight) I get this error: * YAML Warning: Duplicate map key found. Ignoring. Code: YAML_LOAD_WARN_DUPLICATE_KEY Line: 51 Document: 1 at /home/nigelhorne/perlmods/share/perl/5.10.0/YAML/Mo.pm line 24, <$IN> line 1. YAML::Mo::__ANON__('YAML::Loader=HASH(0x13ce380)', 'YAML_LOAD_WARN_DUPLICATE_KEY') called at /home/nigelhorne/perlmods/share/perl/5.10.0/YAML/Loader.pm line 359 YAML::Loader::_parse_mapping('YAML::Loader=HASH(0x13ce380)', '') called at /home/nigelhorne/perlmods/share/perl/5.10.0/YAML/Loader.pm line 168 YAML::Loader::_parse_node('YAML::Loader=HASH(0x13ce380)') called at /home/nigelhorne/perlmods/share/perl/5.10.0/YAML/Loader.pm line 358 YAML::Loader::_parse_mapping('YAML::Loader=HASH(0x13ce380)', '') called at /home/nigelhorne/perlmods/share/perl/5.10.0/YAML/Loader.pm line 168 YAML::Loader::_parse_node('YAML::Loader=HASH(0x13ce380)') called at /home/nigelhorne/perlmods/share/perl/5.10.0/YAML/Loader.pm line 103 YAML::Loader::_parse('YAML::Loader=HASH(0x13ce380)') called at /home/nigelhorne/perlmods/share/perl/5.10.0/YAML/Loader.pm line 25 YAML::Loader::load('YAML::Loader=HASH(0x13ce380)', '---\x{a}chain: !!perl/hash:Data::Throttler::BucketChain\x{a} bucket_...') called at /home/nigelhorne/perlmods/share/perl/5.10.0/YAML.pm line 34 YAML::Load('---\x{a}chain: !!perl/hash:Data::Throttler::BucketChain\x{a} bucket_...') called at /home/nigelhorne/perlmods/share/perl/5.10.0/YAML.pm line 75 YAML::LoadFile('/home/nigelhorne/concert-bands.co.uk/../tmp/throttle') called at /home/nigelhorne/perlmods/share/perl/5.10.0/Data/Throttler.pm line 623 Data::Throttler::Backend::YAML::load('Data::Throttler::Backend::YAML=HASH(0xdf40f8)') called at /home/nigelhorne/perlmods/share/perl/5.10.0/Data/Throttler.pm line 131 Data::Throttler::try_push('Data::Throttler=HASH(0xdf3c18)', 'key', 78.150.225.52) called at cbl2.pl line 237 I do not have code to 100% reproduce it, it only happens on rare occaisions. Here is the caller: my $throttler = Data::Throttler->new( max_items => 15, interval => 90, backend => 'YAML', backend_options => { db_file => $info->tmpdir() . '/throttle' } ); unless($throttler->try_push(key => $remote)) { $istrawler = 1; }
That's very odd indeed, I've never seen that happening. You might want to consider upgrading from 5.10.0 to something more stable and also make sure you're running the latest YAML from CPAN. -- Mike
On Tue Oct 23 21:31:25 2012, MSCHILLI wrote: Show quoted text
> That's very odd indeed, I've never seen that happening. You might want to > consider upgrading from 5.10.0 to something more stable and also make > sure you're running the latest YAML from CPAN.
I am running the latest YAML already. As for upgrading Perl, the site is hosted by Dreamhost and I'm therefore not able to upgrade it. -Nigel
Interesting, I'm on dreamhost as well and my shared host has got perl- 5.10.1. I'm puzzled as to why YAML might end up with dupe keys, if you want to get to the bottom of this, you can compile your own perl on dreamhost shared server (I've done it before, it's easy, just get the tarball, configure it to install into ~/perl and 'make') and see if that helps getting rid of the issue.
Subject: Re: [rt.cpan.org #80127] YAML_LOAD_WARN_DUPLICATE_KEY in try_push
Date: Thu, 25 Oct 2012 10:13:42 -0400
To: bug-Data-Throttler [...] rt.cpan.org
From: Nigel Horne <njh [...] bandsman.co.uk>
On 10/23/2012 09:50 PM, Michael_Schilli via RT wrote: Show quoted text
> <URL: https://rt.cpan.org/Ticket/Display.html?id=80127> > > Interesting, I'm on dreamhost as well and my shared host has got perl- > 5.10.1.
I recently added a new site on Dreamhost and it's on 5.10.1, but for some reason they've not updated all hosts some are still running 5.10.0, including this site :-( Show quoted text
> > I'm puzzled as to why YAML might end up with dupe keys, if you want to > get to the bottom of this, you can compile your own perl on dreamhost > shared server (I've done it before, it's easy, just get the tarball, > configure it to install into ~/perl and 'make') and see if that helps > getting rid of the issue.
Can I ask what difference there is between 5.10.0 and 5.10.1 that would cause Data::Throttler to break? -Nigel
It's probably unrelated, but I wanted to rule out perl-5.10.0 being the culprit because I've seen lots of unexplicable bugs with it in the past.
On Thu Oct 25 11:13:57 2012, MSCHILLI wrote: Show quoted text
> It's probably unrelated, but I wanted to rule out perl-5.10.0 being the > culprit because I've seen lots of unexplicable bugs with it in the past.
I'm sorry for the delay. Dreamhost has now given me an update but that has the same problem: Code: YAML_PARSE_ERR_INCONSISTENT_INDENTATION Line: 50 Document: 1 at /home/nigelhorne/perlmods/share/perl/5.10.1/YAML/Loader.pm line 719. Code: YAML_LOAD_ERR_FILE_INPUT at /home/nigelhorne/perlmods/share/perl/5.10.1/YAML.pm line 71.
On Wed Feb 06 09:03:07 2013, NHORNE wrote: Show quoted text
> On Thu Oct 25 11:13:57 2012, MSCHILLI wrote:
> > It's probably unrelated, but I wanted to rule out perl-5.10.0 being
> the
> > culprit because I've seen lots of unexplicable bugs with it in the
> past. > > I'm sorry for the delay. Dreamhost has now given me an update but > that has the same problem: > > Code: YAML_PARSE_ERR_INCONSISTENT_INDENTATION > Line: 50 > Document: 1 > at /home/nigelhorne/perlmods/share/perl/5.10.1/YAML/Loader.pm line > 719. > Code: YAML_LOAD_ERR_FILE_INPUT > at /home/nigelhorne/perlmods/share/perl/5.10.1/YAML.pm line 71.
Actually now I look closer it may not be the same problem, but it's a problem nevertheless which I could do with some help on please.
Thanks for enhancing the error message. I am now seeing this, I hope it helps: Can't call method "try_push" on an undefined value at /home/nigelhorne/perlmods/share/perl/5.10.1/Data/Throttler.pm line 132. YAML Error: Couldn't open /home/nigelhorne/bandsman.co.uk/../tmp/throttle for input:\nBad file descriptor Code: YAML_LOAD_ERR_FILE_INPUT at /home/nigelhorne/perlmods/share/perl/5.10.1/YAML.pm line 71.
On Mon Jun 10 09:48:32 2013, NHORNE wrote: Show quoted text
> Can't call method "try_push" on an undefined value at > /home/nigelhorne/perlmods/share/perl/5.10.1/Data/Throttler.pm line > 132.
Hi Nigel, sorry about the delay on this, I've looked at the code some more and saw that it's not the newly added diagnostics line that's triggering the error but it seems to originate from a general problem loading the YAML file. Did you specify it in the constructor using the db_file option? Would be great if you could post the code (or snippets thereof) here to make sure I'm reproducing the problem correctly.
Here is a snippet which shows, in general terms, how I'm using the code: my $info = CGI::Info->new(); my $db_file = $info->tmpdir() . '/throttle'; my $throttler = Data::Throttler->new( max_items => 15, interval => 90, backend => 'YAML', backend_options => { db_file => $db_file } ); unless($throttler->try_push(key => $ENV{'REMOTE_ADDR'})) { $block = 1; }
On Tue Jul 16 08:49:51 2013, NHORNE wrote: Show quoted text
> Here is a snippet which shows, in general terms, how I'm using the code:
That looks pretty straight-forward, and I don't see anything wrong with it. So far, you've seen several instances of a corrupted YAML file or (the last time) a missing YAML file. The file locking employed by the throttler should have prevented this. You've mentioned that you're running on a dreamhost shared server, so I wonder if there's something strange happening to the tmp directory you're using to store the db_file. I presume their servers mount the file system on a filer, and this could mean that file locking is no longer atomic, which might create the error conditions you're seeing. Have you been able to reproduce the problem on a local file system?
Show quoted text
> You've mentioned that you're running on a dreamhost shared server, so > I wonder if there's something strange happening to the tmp > directory you're using to store the db_file. I presume their > servers mount the file system on a filer, and this could mean that > file locking is no longer atomic, which might create the error > conditions you're seeing.
There shouldn't be a problem since the tmp directory I'm using is on a local disc drive (/dev/sdb1). Show quoted text
> Have you been able to reproduce the problem on a local file system?
No, but then I'm not surprised since it only happens on rare occasions and probably in a race condition.
Here's a quick script to verify if locking works correctly with Data::Throttler: https://raw.github.com/mschilli/data-throttler-perl/master/eg/forktest You might want to point the db_file to a location within the temporary directory you're using. If you're getting no output, locking works correctly. If you're getting YAML and locking errors, flock isn't working on your platform. I was able to successfully reproduce the problem by removing locking from Data::Throttler, but it works fine with the original Data::Throttler code, both on my local file system and on my dreamhost shared server account.
On Wed Jul 17 11:48:51 2013, MSCHILLI wrote: Show quoted text
> Here's a quick script to verify if locking works correctly with > Data::Throttler:
Show quoted text
I ran the script in the script in the tmp directory that I use. I got no output. -Nigel
Subject: Re: [rt.cpan.org #80127] YAML_LOAD_WARN_DUPLICATE_KEY in try_push
Date: Thu, 18 Jul 2013 09:03:37 -0700 (PDT)
To: Nigel Horne via RT <bug-Data-Throttler [...] rt.cpan.org>
From: Mike Schilli <m [...] perlmeister.com>
On Thu, 18 Jul 2013, Nigel Horne via RT wrote: Show quoted text
> I ran the script in the script in the tmp directory that I use. I got > no output.
If there's no inherent problem with the locking on the file system you're using, then the only other idea I have on how this could happen is that a third party process interferes with the yaml file in some other way. -- -- Mike Mike Schilli m@perlmeister.com
Closed due to inactivity.