[SOLVED] Fix for dd-wrt's chronic cron issues

Post new topic   Reply to topic    DD-WRT Forum Index -> Contributions Upload
Goto page 1, 2  Next
Author Message
yoyoma2
DD-WRT User


Joined: 24 Sep 2016
Posts: 371

PostPosted: Fri Sep 27, 2019 5:06    Post subject: [SOLVED] Fix for dd-wrt's chronic cron issues Reply with quote
Here's a fix to this file for dd-wrt's chronic cron issues. This should help with a number of bugs such as 6744, 1955, 6683, 6688 and others.

One of the comments in defect 1955 states: "Not reproducable, works fine here and the code for it is correct". A quick look at database.c will show that "*system*" is repeatedly used as "unique key" for multiple distinct records. The fix simply makes the unique key actually unique by appending the filename to it and everything works.

Cron is actually always running fine every minute, but with the database unique keys being invalid, when changes occur to cron table files, anything can happen. To reproduce, touching /tmp/crontab and touching/editing/adding/removing files in /etc/cron.d/ should result in erratic cron behavior quick enough.

Fix it any way you like, but please don't sweep it under the now 14 year old rug.


Last edited by yoyoma2 on Wed Oct 09, 2019 12:54; edited 1 time in total
Sponsor
egc
DD-WRT Guru


Joined: 18 Mar 2014
Posts: 12812
Location: Netherlands

PostPosted: Sat Sep 28, 2019 10:54    Post subject: Reply with quote
@yoyoma2, like I already posted, your patch looked valid to me and I contacted BS and he has already patched the source code. see: https://svn.dd-wrt.com/changeset/41189

So in the next build it should be good.

If you can test the next build and report your findings (you can PM me or report in the original thread) that would be great.

Thanks for your work, much appreciated

_________________
Routers:Netgear R7000, R6400v1, R6400v2, EA6900 (XvortexCFE), E2000, E1200v1, WRT54GS v1.
Install guide R6400v2, R6700v3,XR300:https://forum.dd-wrt.com/phpBB2/viewtopic.php?t=316399
Install guide R7800/XR500: https://forum.dd-wrt.com/phpBB2/viewtopic.php?t=320614
Forum Guide Lines (important read):https://forum.dd-wrt.com/phpBB2/viewtopic.php?t=324087
giles02134
DD-WRT User


Joined: 25 Feb 2007
Posts: 142

PostPosted: Sat Sep 28, 2019 11:48    Post subject: Reply with quote
That's great news! I'll wait for reports on the effectiveness of the patch in the coming release, before I update my own installation.

Thanks to all for following this through.

_________________
Router: Linksys WRT1900ACSv2
Modem: Verizon Fios
DD-WRT v3.0-r44048 std (08/02/20)
ISP: Verizon Fios
NAS: ReadyNas314
yoyoma2
DD-WRT User


Joined: 24 Sep 2016
Posts: 371

PostPosted: Sat Sep 28, 2019 14:49    Post subject: Reply with quote
Wow thats a quick turnaround!

Unfortunately I only have one router (Asus RT-AC56U: DD-WRT v3.0-r39960M kongac) with lots of stuff configured. To switch over to a BS build with minimal downtime I just ordered a cheap Netgear R6300v2 (almost same specs as RT-AC56U) from China but the sea shipping can take months. To be safe I wouldn't switch Kong->BS without a full reset.

I'm quite confident dd-wrt's cron reliability will greatly improve after 41189.

Thanks egc and BS for the quick reaction.
egc
DD-WRT Guru


Joined: 18 Mar 2014
Posts: 12812
Location: Netherlands

PostPosted: Sat Sep 28, 2019 15:33    Post subject: Reply with quote
yoyoma2 wrote:
Wow thats a quick turnaround!

Unfortunately I only have one router (Asus RT-AC56U: DD-WRT v3.0-r39960M kongac) with lots of stuff configured. To switch over to a BS build with minimal downtime I just ordered a cheap Netgear R6300v2 (almost same specs as RT-AC56U) from China but the sea shipping can take months. To be safe I wouldn't switch Kong->BS without a full reset.

I'm quite confident dd-wrt's cron reliability will greatly improve after 41189.

Thanks egc and BS for the quick reaction.



Thank you for your contribution greatly appreciated!
I agree about the full reset so lets hope the chinese postal service delivers quickly Smile

_________________
Routers:Netgear R7000, R6400v1, R6400v2, EA6900 (XvortexCFE), E2000, E1200v1, WRT54GS v1.
Install guide R6400v2, R6700v3,XR300:https://forum.dd-wrt.com/phpBB2/viewtopic.php?t=316399
Install guide R7800/XR500: https://forum.dd-wrt.com/phpBB2/viewtopic.php?t=320614
Forum Guide Lines (important read):https://forum.dd-wrt.com/phpBB2/viewtopic.php?t=324087
giles02134
DD-WRT User


Joined: 25 Feb 2007
Posts: 142

PostPosted: Wed Oct 09, 2019 8:19    Post subject: Cron in R41218 Reply with quote
I did a firmware update yesterday (9-Oct) with Firefox 69.0.2 x64). The flash proceeded normally, and the router rebooted without a problem.

I can report that the cron issue has indeed been fixed. Before flashing, I removed all startup commands which referenced yoyoma2's cronwd.sh, and also removed the cronwd.sh cron job Administration->management->additional cron jobs. The router rebooted on its own at 3:00a.m. as specified in Administration->Keepalive.

Thanks to yoyoma2 for not only submitting a fix for the bug, but for the workaround he'd provided prior to the new release.

_________________
Router: Linksys WRT1900ACSv2
Modem: Verizon Fios
DD-WRT v3.0-r44048 std (08/02/20)
ISP: Verizon Fios
NAS: ReadyNas314
kernel-panic69
DD-WRT Guru


Joined: 08 May 2018
Posts: 14102
Location: Texas, USA

PostPosted: Wed Nov 06, 2019 15:41    Post subject: Reply with quote
Well, looking at this while merging cron 4.1 to another project, it is obvious that DD-WRT doesn't use cron 4.1, and THEREIN probably lies the obvious problem. This patch maybe not necessary if DD-WRT was using cron 4.1 (the latest ever released...!) SMDH.
_________________
"Life is but a fleeting moment, a vapor that vanishes quickly; All is vanity"
Contribute To DD-WRT
Pogo - A minimal level of ability is expected and needed...
DD-WRT Releases 2023 (PolitePol)
DD-WRT Releases 2023 (RSS Everything)

----------------------
Linux User #377467 counter.li.org / linuxcounter.net
yoyoma2
DD-WRT User


Joined: 24 Sep 2016
Posts: 371

PostPosted: Wed Nov 06, 2019 22:39    Post subject: Reply with quote
The bug was not in the original Vixie cron code but rather in the integration changes made to fit dd-wrt's special needs (single user with multiple cron tables).

I'm all for using updated code versions but I don't think any of the subtle bug fixes would be noticed by dd-wrt users given this severely broken cron sat there for 14 years. BS's time is so limited he'll probably aim for changes that offer more bang for the buck.

This patch seems to fix dd-wrt's chronic cron issues as we see here.
kernel-panic69
DD-WRT Guru


Joined: 08 May 2018
Posts: 14102
Location: Texas, USA

PostPosted: Thu Nov 07, 2019 4:01    Post subject: Reply with quote
Vixie CRON (ISC Cron, as it ended up with the last release at version 4.1) was released in 2004: https://ftp.isc.org/isc/cron/ ... I literally did a side-by-side diff of the entire source tree, and the version in DD-WRT is still a v3.x version, so it's older than 14 years. So, the likelihood of the bug still being there in 4.1 is unlikely. BUT, without the last official version of Vixie / ISC cron being merged, I can only speculate... but I guess if it now works, it now works.
_________________
"Life is but a fleeting moment, a vapor that vanishes quickly; All is vanity"
Contribute To DD-WRT
Pogo - A minimal level of ability is expected and needed...
DD-WRT Releases 2023 (PolitePol)
DD-WRT Releases 2023 (RSS Everything)

----------------------
Linux User #377467 counter.li.org / linuxcounter.net
yoyoma2
DD-WRT User


Joined: 24 Sep 2016
Posts: 371

PostPosted: Thu Nov 07, 2019 14:20    Post subject: Reply with quote
The patched database.c says "Copyright ... 1994" so yes it's older than 14 years so an update from BS would be nice. It also says "mark your changes (don't get me blamed for your possible bugs)". This was not done 14 years ago when this bug was added by BS.

Specifically in load_database(), an entire loop was added by BS reading any number of cron job files with arbitrary filenames. Only a single system cron job file and one cron job file per user (named after them) are assumed by the underlying code.

The fix in process_crontab() specifically accomodates the BS addition above so no, the 4.1 release most certainly does not accomodate for BS's 14 year old addition.
kernel-panic69
DD-WRT Guru


Joined: 08 May 2018
Posts: 14102
Location: Texas, USA

PostPosted: Thu Nov 07, 2019 20:05    Post subject: Reply with quote
I guess I don't understand the purpose of hacking an older version of cron vs. updating to the last known version that seems to work fine without enhancement. But hey, good job. Thanks for fixing his likely unnecessary non-industry-standard-following hack, if that is what it is. I would have to extract the cron tree from all of my GPL stuff here to look and see. I was only saying that the code itself, especially in that file, is not line-for-line with upstream latest release of v4.1, feel free to check it for yourself. There is a lot of hacked old code in this firmware that I have noticed that was not updated to the latest version or has not been. Nothing new.
_________________
"Life is but a fleeting moment, a vapor that vanishes quickly; All is vanity"
Contribute To DD-WRT
Pogo - A minimal level of ability is expected and needed...
DD-WRT Releases 2023 (PolitePol)
DD-WRT Releases 2023 (RSS Everything)

----------------------
Linux User #377467 counter.li.org / linuxcounter.net
yoyoma2
DD-WRT User


Joined: 24 Sep 2016
Posts: 371

PostPosted: Fri Nov 08, 2019 2:13    Post subject: Reply with quote
kernel-panic69 wrote:
I guess I don't understand the purpose of hacking an older version of cron vs. updating to the last known version that seems to work fine without enhancement.
It has already been shown that your "obvious" idea that: upgrading cron code would fix dd-wrt's cron issues, is wrong. Your "shaking my damn head" was unwarranted.

kernel-panic69 wrote:
But hey, good job.
Thanks, your opinion means alot.

kernel-panic69 wrote:
Thanks for fixing his likely unnecessary non-industry-standard-following hack, if that is what it is.
Yes BS tweaked cron in an unusual way but a router is an unusual platform. His check_ps and scheduled reboot features and any third party scheduled task can be done simply by adding/removing a file in /etc/cron.d which is simple, lightweight and efficient.

kernel-panic69 wrote:
I would have to extract the cron tree from all of my GPL stuff here to look and see. I was only saying that the code itself, especially in that file, is not line-for-line with upstream latest release of v4.1, feel free to check it for yourself.
Checked the latest code before fixing this but feel free to study it and educate everyone here.

kernel-panic69 wrote:
There is a lot of hacked old code in this firmware that I have noticed that was not updated to the latest version or has not been. Nothing new.
Your best statement so far but not related to this thread. You should elaborate in this thread. BTW I agree with the comment in the first link in the aforementioned thread's original post: "it's kind of a bloated cobbled-together mess these days" but nevertheless the end result is very useful.
kernel-panic69
DD-WRT Guru


Joined: 08 May 2018
Posts: 14102
Location: Texas, USA

PostPosted: Fri Nov 08, 2019 2:53    Post subject: Reply with quote
So, you're trying to tell me that the cron code in DD-WRT is 4.1 or started as 4.1? Ok, yeah, let me wave the bullshit flag on that one. But again, thank you for fixing a bad hack.
_________________
"Life is but a fleeting moment, a vapor that vanishes quickly; All is vanity"
Contribute To DD-WRT
Pogo - A minimal level of ability is expected and needed...
DD-WRT Releases 2023 (PolitePol)
DD-WRT Releases 2023 (RSS Everything)

----------------------
Linux User #377467 counter.li.org / linuxcounter.net
yoyoma2
DD-WRT User


Joined: 24 Sep 2016
Posts: 371

PostPosted: Fri Nov 08, 2019 4:14    Post subject: Reply with quote
yoyoma2 wrote:
The patched database.c says "Copyright ... 1994" so yes it's older than 14 years so an update from BS would be nice.

If in 2005 I buy an 11 year old pickup truck and build my own trailer. Problem is my trailer brakes rub all the time and cause all sorts of problems driving the setup. My buddy notices this in 2019 and repairs my trailer brakes for free. Driving the rig finally works well and the trailer accomplishes all my jobs flawlessly. A neighbor shakes his head in disgust and goes on endlessly to my buddy about why I should have bought a brand new truck instead to solve the trailer brake problem. He calls my buddy who fixed the trailer brakes for free, a bullshitter and that trailers are non-standard and bad and shouldn't exist.

I'm done with this thread unless something worthy of a response is posted.
kernel-panic69
DD-WRT Guru


Joined: 08 May 2018
Posts: 14102
Location: Texas, USA

PostPosted: Fri Nov 08, 2019 5:33    Post subject: Reply with quote
yoyoma2 wrote:
Checked the latest code before fixing this but feel free to study it and educate everyone here.


^ I read this as you checked the latest cron code, not DD-WRT. Maybe if you clarified a little further sometimes, I wouldn't be such a dick. I made a simple observation to start off with and you blasted me. This is not the first time I have noticed something and made a comment, don't get your panties all in a bunch. And I guess I didn't quite fully get what you were saying at first about added code. Most of the bugs in this firmware are added code by the developer. But hey, it's all whatever to me.

_________________
"Life is but a fleeting moment, a vapor that vanishes quickly; All is vanity"
Contribute To DD-WRT
Pogo - A minimal level of ability is expected and needed...
DD-WRT Releases 2023 (PolitePol)
DD-WRT Releases 2023 (RSS Everything)

----------------------
Linux User #377467 counter.li.org / linuxcounter.net
Goto page 1, 2  Next Display posts from previous:    Page 1 of 2
Post new topic   Reply to topic    DD-WRT Forum Index -> Contributions Upload All times are GMT

Navigation

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
You cannot attach files in this forum
You cannot download files in this forum