Page 1 of 1

ISP Monthly Quota Resetting on Wrong Day

Posted: September 23rd, 2012, 7:23 pm
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.

Re: ISP Monthly Quota Resetting on Wrong Day

Posted: September 23rd, 2012, 9:03 pm
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)

Re: ISP Monthly Quota Resetting on Wrong Day

Posted: September 23rd, 2012, 9:12 pm
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.

Re: ISP Monthly Quota Resetting on Wrong Day

Posted: September 23rd, 2012, 9:20 pm
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).

Re: ISP Monthly Quota Resetting on Wrong Day

Posted: September 23rd, 2012, 9:58 pm
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.

Re: ISP Monthly Quota Resetting on Wrong Day

Posted: September 23rd, 2012, 10:02 pm
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.

Re: ISP Monthly Quota Resetting on Wrong Day

Posted: September 24th, 2012, 1:07 pm
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?

Re: ISP Monthly Quota Resetting on Wrong Day

Posted: September 25th, 2012, 5:15 am
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 ?

Re: ISP Monthly Quota Resetting on Wrong Day

Posted: September 25th, 2012, 10:15 am
by shypike
Or wait until 0.7.4, which isn't far off.
We'll have solved it before that.

Re: ISP Monthly Quota Resetting on Wrong Day

Posted: September 25th, 2012, 3:52 pm
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.

Re: ISP Monthly Quota Resetting on Wrong Day

Posted: October 16th, 2012, 1:11 am
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!