ISP Monthly Quota Resetting on Wrong Day

Report & discuss bugs found in SABnzbd
Forum rules
Help us help you:
  • Are you using the latest stable version of SABnzbd? Downloads page.
  • Tell us what system you run SABnzbd on.
  • Adhere to the forum rules.
  • Do you experience problems during downloading?
    Check your connection in Status and Interface settings window.
    Use Test Server in Config > Servers.
    We will probably ask you to do a test using only basic settings.
  • Do you experience problems during repair or unpacking?
    Enable +Debug logging in the Status and Interface settings window and share the relevant parts of the log here using [ code ] sections.
Post Reply
Ommi
Newbie
Newbie
Posts: 9
Joined: June 5th, 2011, 6:55 pm

ISP Monthly Quota Resetting on Wrong Day

Post by Ommi »

Version: 0.7.3
OS: XP SP3
Install-type: Windows Installer
Skin (if applicable): Plush
Firewall Software: n/a
Are you using IPV6? no
Is the issue reproducible? Yes, insofar as I can only check once a month

Short version: Using the Quota Block, with the Quota Period set to Month, and the reset day set to 16; the quota is actually resetting on the 8th.

Longer version: same as the short version, but with more words. I've been waiting to report this, as I have never really been certain it wasn't just me not paying attention. It's also possible that I'm just not understanding how the reset date works, but it doesn't seem that complex.

Details and fiddling upon request.

Edit: sab runs full time as a service, computer is always on. I do have a "pause" and "resume" set for three days of the week, nothing else scheduled.
User avatar
sander
Release Testers
Release Testers
Posts: 9264
Joined: January 22nd, 2008, 2:22 pm

Re: ISP Monthly Quota Resetting on Wrong Day

Post by sander »

Can you set Logging to +Debug (see Status tab)? Keep SAB running for some time, and then find the lines with "quota" in them. See mine below

Code: Select all

2012-09-23 22:12:01,798::INFO::[bpsmeter:298] Auto-resume due to quota reset
2012-09-23 22:12:01,798::DEBUG::[bpsmeter:331] Will reset quota at (2012, 10, 1, 0, 0, 0, 0, 0, 1)
2012-09-23 22:12:01,801::DEBUG::[bpsmeter:331] Will reset quota at (2012, 9, 23, 0, 25, 0, 0, 0, 1)
2012-09-23 22:44:45,352::DEBUG::[bpsmeter:171] Read quota q=1.073741824e+11 l=1.073741824e+11 reset=1348352700.0
2012-09-23 22:44:45,353::INFO::[bpsmeter:296] Quota was reset to 1.073741824e+11
2012-09-23 22:44:45,353::INFO::[bpsmeter:298] Auto-resume due to quota reset
2012-09-23 22:44:45,353::DEBUG::[bpsmeter:331] Will reset quota at (2012, 10, 1, 0, 0, 0, 0, 0, 1)
2012-09-23 22:44:45,357::DEBUG::[bpsmeter:331] Will reset quota at (2012, 9, 24, 0, 25, 0, 0, 0, 1)
2012-09-23 22:46:10,881::DEBUG::[bpsmeter:171] Read quota q=1.073741824e+11 l=1.073741824e+11 reset=1348439100.0
2012-09-23 22:46:10,884::DEBUG::[bpsmeter:331] Will reset quota at (2012, 9, 24, 0, 25, 0, 0, 0, 1)
2012-09-23 22:47:08,459::DEBUG::[bpsmeter:171] Read quota q=1.073741824e+11 l=1.073741824e+11 reset=1348439100.0
2012-09-23 22:47:08,465::DEBUG::[bpsmeter:331] Will reset quota at (2012, 9, 24, 0, 25, 0, 0, 0, 1)
User avatar
sander
Release Testers
Release Testers
Posts: 9264
Joined: January 22nd, 2008, 2:22 pm

Re: ISP Monthly Quota Resetting on Wrong Day

Post by sander »

Interesting: I set "16" as Reset Day in a Month:

Code: Select all

sander@R540:~$ grep -i quota .sabnzbd/sabnzbd.ini
quota_period = m
quota_day = 16
quota_size = 1000G
quota_resume = 1
sander@R540:~$
and now the logging says SAB will reset on 2012-10-7:

Code: Select all

2012-09-24 03:52:15,423::DEBUG::[bpsmeter:331] Will reset quota at (2012, 10, 7, 0, 0, 0, 0, 0, 1)
I would expect 2012-10-16. And 2012-10-7 is 13 days from now (not 16), so that's no explanation neither.

Strange.
User avatar
sander
Release Testers
Release Testers
Posts: 9264
Joined: January 22nd, 2008, 2:22 pm

Re: ISP Monthly Quota Resetting on Wrong Day

Post by sander »

I played a bit with the Day, and this is my test result:

If above 7, it will be lowered to 7.

(Your 8 does not completely match 7, but I guess 8 is your guess, and not exact)

So my hypothesis is there is a bug in the SABnzbd code that it incorrectly maximizes the day of month to 7 (possibly the number of days in a week).
User avatar
sander
Release Testers
Release Testers
Posts: 9264
Joined: January 22nd, 2008, 2:22 pm

Re: ISP Monthly Quota Resetting on Wrong Day

Post by sander »

I think the bug is in bpsmeter.py in the line:

Code: Select all

self.q_day = min(7, self.q_day)
I'll have to check further.
Ommi
Newbie
Newbie
Posts: 9
Joined: June 5th, 2011, 6:55 pm

Re: ISP Monthly Quota Resetting on Wrong Day

Post by Ommi »

Well, I was sure it was the 8th, but.. now I'm not so confident. I remember checking just after midnight on the 8th, even wrote it down. But, sigh, no, I can't promise it hadn't already changed on the 7th and I just missed it. Sorry!

The self.q_day = min(7, self.q_day) would make sense if the reset period was weekly. But not so good for monthly.
User avatar
sander
Release Testers
Release Testers
Posts: 9264
Joined: January 22nd, 2008, 2:22 pm

Re: ISP Monthly Quota Resetting on Wrong Day

Post by sander »

I've created a new bpsmeter.py: see http://www.appelboor.com/dump/bpsmeter.py . Two changes:
max day-of-month is now 31
It has a completely different way of calculating whether SAB is beyond the reset day. I'm not 100% sure it's good, because it is a bit hard to test: reset only each month.

As you're on Windows, I guess you don't run SABnzbd from source, do you?
Ommi
Newbie
Newbie
Posts: 9
Joined: June 5th, 2011, 6:55 pm

Re: ISP Monthly Quota Resetting on Wrong Day

Post by Ommi »

Goodness no. I'm far too lazy for that. Double click the .exe, go through the "windows service steps", shout "hurrah!" and not look at it again.

I do have a python installed here though (albeit a couple years old - that can be updated). Is it, perchance, as simple as replacing the .pyo file in \lib\sabnzbd.zip ?
User avatar
shypike
Administrator
Administrator
Posts: 19774
Joined: January 18th, 2008, 12:49 pm

Re: ISP Monthly Quota Resetting on Wrong Day

Post by shypike »

Or wait until 0.7.4, which isn't far off.
We'll have solved it before that.
User avatar
shypike
Administrator
Administrator
Posts: 19774
Joined: January 18th, 2008, 12:49 pm

Re: ISP Monthly Quota Resetting on Wrong Day

Post by shypike »

With your help I managed to fixed it.
Must have been after midnight when I wrote that.
In all time calculations in "next_reset" used hours+60*minutes instead of hours*60+minutes :(
Also the maximum day should be 7 for a week schedule and 31 for a month schedule.
Ommi
Newbie
Newbie
Posts: 9
Joined: June 5th, 2011, 6:55 pm

Re: ISP Monthly Quota Resetting on Wrong Day

Post by Ommi »

Follow up. 7th came and went, quota didn't change (which it shouldn't). 16th (today) arrived, and quote reset as scheduled. So all is well.

Thank you for the fix!
Post Reply