• Resolved KratosGemini

    (@kratosgemini)


    I have a handful of sites running on the same server with very similar WordPress setups, and recently once has gotten stuck in an infinite loop when trying to run a full scan. I turned on debugging to confirm this. The log shows that it starts scanning files, gets as far as it can within the limit set by “Maximum execution time for each scan stage”, and then restarts scanning the files from the very beginning again.

    As another test, I cut the “Maximum execution time for each scan stage” in half (from 20 to 10). The result was it got about half as far at each stage. It always started from the very beginning each stage, while reporting an increasing number of files and MB analyzed (far beyond the total number of files contained on the site).

    Any thoughts on how to solve this? Thanks.

Viewing 6 replies - 1 through 6 (of 6 total)
  • Plugin Support wfpeter

    (@wfpeter)

    Hi @kratosgemini, thanks for getting in touch.

    Sometimes the scan can actually report if it thinks its in an infinite loop, but there are certainly a few pieces of information that’d be good for me to check in this case.

    • Go to the Wordfence > Tools > Diagnostics page
    • In the “Debugging Options” section check the circle “Enable debugging mode”
    • Click to “Save Changes”.
    • CANCEL any current scan and start a NEW scan
    • Copy the last 20 lines from the Log (click the “Show Log” link) or so of the activity log once the scan finishes and paste them in this post.

    Wordfence > Tools > Diagnostic > Debugging Screenshot

    This will help me see exactly what is happening when the scan fails or ends.

    It’d also be good to grab a diagnostic so I can see the configuration on top of the scan logs. You can send a diagnostic report to wftest @ wordfence . com by finding the link at the top of the Wordfence > Tools > Diagnostics page. Then click on “Send Report by Email”. Please add your forum username where indicated and respond here after you have sent it.

    NOTE: It should look as follows – Screenshot of Tools > Diagnostic > Send by Email

    Thanks,

    Peter.

    Thread Starter KratosGemini

    (@kratosgemini)

    Ok, I’ll do that. One question on the configuration: Do I need to set anything in particular for “Maximum execution time for each scan stage”, or should I leave it at the default? (The default has usually worked fine.)

    Thanks.

    Plugin Support wfpeter

    (@wfpeter)

    Hi @kratosgemini,

    You can reduce the scan stage value to 20 or even 10 to see if it helps prevent timeouts/issues occurring. Generally, Wordfence will only try to use half of the value set in your php.ini file for max_execution_time, but if this is above 60, I have seen problems arise.

    Thanks again,

    Peter.

    Thread Starter KratosGemini

    (@kratosgemini)

    I emailed the diagnostic just now. I noticed when going through it that some DB permissions seem to be missing. I hadn’t noticed that before, but I assume that’s not new. (It’s not a site I do much with at this point.) Would that cause an infinite loop like this?

    Anyway, here’s the top of the scan log. It reports that 331,126 files were scanned and about 5 GB, but the entire website (WordPress included) is only 12,976 files at around 392 MB. This is because the log shows that the same set of files is scanned over and over again until the 3 hours limit hits.

    [Mar 09 13:57:06] Scanning: /var/www/vhosts/thewayministries.org/html/wp-admin/css/dashboard-rtl.css (Mem:35.0M)
    [Mar 09 13:57:06] Scanning: /var/www/vhosts/thewayministries.org/html/wp-admin/css/dashboard-rtl.min.css (Mem:35.0M)
    [Mar 09 13:57:06] Scanning: /var/www/vhosts/thewayministries.org/html/wp-admin/css/dashboard.css (Mem:35.0M)
    [Mar 09 13:57:06] Scanning: /var/www/vhosts/thewayministries.org/html/wp-admin/css/dashboard.min.css (Mem:35.0M)
    [Mar 09 13:57:06] Scanning: /var/www/vhosts/thewayministries.org/html/wp-admin/css/deprecated-media-rtl.css (Mem:35.0M)
    [Mar 09 13:57:06] Scanning: /var/www/vhosts/thewayministries.org/html/wp-admin/css/deprecated-media-rtl.min.css (Mem:35.0M)
    [Mar 09 13:57:06] Scanning: /var/www/vhosts/thewayministries.org/html/wp-admin/css/deprecated-media.css (Mem:35.0M)
    [Mar 09 13:57:06] Scanning: /var/www/vhosts/thewayministries.org/html/wp-admin/css/deprecated-media.min.css (Mem:35.0M)
    [Mar 09 13:57:06] Scanning: /var/www/vhosts/thewayministries.org/html/wp-admin/css/edit-rtl.css (Mem:35.0M)
    [Mar 09 13:57:06] Scanning: /var/www/vhosts/thewayministries.org/html/wp-admin/css/edit-rtl.min.css (Mem:35.0M)
    [Mar 09 13:57:06] Scanning: /var/www/vhosts/thewayministries.org/html/wp-admin/css/edit.css (Mem:35.0M)
    [Mar 09 13:57:06] Scanning: /var/www/vhosts/thewayministries.org/html/wp-admin/css/edit.min.css (Mem:35.0M)
    [Mar 09 13:57:06] Scanning: /var/www/vhosts/thewayministries.org/html/wp-admin/css/farbtastic-rtl.css (Mem:35.0M)
    [Mar 09 13:57:06] Scanning: /var/www/vhosts/thewayministries.org/html/wp-admin/css/farbtastic-rtl.min.css (Mem:35.0M)
    [Mar 09 13:57:06] Scanning: /var/www/vhosts/thewayministries.org/html/wp-admin/css/farbtastic.css (Mem:35.0M)
    [Mar 09 13:57:07] -------------------
    [Mar 09 13:57:07] Scan interrupted. Scanned 331126 files, 18 plugins, 5 themes, 0 posts, 0 comments and 0 URLs in 3 hours 6 seconds.
    [Mar 09 13:57:07] Calling Wordfence API v2.26:https://noc1.wordfence.com/v2.26/?k=84cedd39bb6e8146e60018261479fd406e8db63fd5526a7b26b3b818562ea9ad1384b61df75d1d1b05004757d5e032f55f535c8635d4f8a736efcb7e83b297272b37d6a5372633f80e64730275d1c4a6&s=eyJ3cCI6IjUuOS4xIiwid2YiOiI3LjUuOCIsIm1zIjpmYWxzZSwiaCI6Imh0dHBzOlwvXC93d3cudGhld2F5bWluaXN0cmllcy5vcmciLCJzc2x2IjoyNjg0NDM4MzksInB2IjoiNy40LjI2IiwicHQiOiJhcGFjaGUyaGFuZGxlciIsImN2IjoiNy4yOS4wIiwiY3MiOiJOU1NcLzMuNTMuMSIsInN2IjoiQXBhY2hlXC8yLjQuNiAoQ2VudE9TKSBQSFBcLzcuNC4yNiIsImR2IjoiOC4wLjIzIiwibGFuZyI6IiJ9&betaFeed=0&action=record_scan_metrics
    [Mar 09 13:57:11] Wordfence used 82.57 MB of memory for scan. Server peak memory usage was: 101.57 MB
    [Mar 09 13:57:11] Scan terminated with error: The scan time limit of 3 hours has been exceeded and the scan will be terminated. This limit can be customized on the options page.
    Thread Starter KratosGemini

    (@kratosgemini)

    So this has been solved now. We got the database permissions that were missing on that site, and the infinite loop is gone. The scan now completes in about 5 minutes.

    It seems that a lack of certain database permissions causes Wordfence to go into an infinite loop on scans, which is interesting.

    Plugin Support wfpeter

    (@wfpeter)

    Thank-you @kratosgemini for the update. The scan will open, write and delete during the scan phase so it’s important for the database permissions that appear on the Wordfence > Tools > Diagnostics page to be present. I expect the loop occurred because Wordfence wasn’t able to reference back to files it’d already checked so just kept going.

    I haven’t seen them failing in a diagnostic before, and having the site as just one experiencing issues from multiple sites running on the same server does seem strange but glad you were able to overcome the issue by opening up the permissions.

    Thanks,

    Peter.

Viewing 6 replies - 1 through 6 (of 6 total)
  • The topic ‘Scan Stuck In Infinite Loop’ is closed to new replies.