Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Maximum execution time of 30 seconds exceeded #80

Open
tom-honeymoon-production opened this issue Feb 16, 2024 · 15 comments
Open

Maximum execution time of 30 seconds exceeded #80

tom-honeymoon-production opened this issue Feb 16, 2024 · 15 comments
Assignees
Labels
bug Something isn't working invalid This doesn't seem right

Comments

@tom-honeymoon-production

Describe the bug

I created an search index including PDF content to be indexed and a search instance.

Then I added a PDF file to the WordPress Media Library (s. attachment, 4MB) and after 30 seconds I get this error message:
"PHP Fatal error: Maximum execution time of 30 seconds exceeded in [...]/wp-content/plugins/ajax-search-pro/includes/classes/Index/Tokenizer.php on line 248"

To Reproduce

Steps to reproduce the behavior:

  1. Go to WordPress Media Library
  2. Upload PDF File

Expected behavior

The PDF content shall be indexed or if maximum execution time is exceeded a fatal error shall be avoided

Screenshots

n/a

Environment checklist

  • [ x] This bug happens with only Ajax Search Pro plugin active
  • [ x] This bug happens with a default WordPress theme active
  • [x ] I can reproduce this bug consistently

Desktop (please complete the following information):

  • OS: Windows 10
  • Browser Chrome
  • Plugin Version 4.26.2

Smartphone (please complete the following information):

n/a

Additional context

n/a
TestTomHaushalt2023.pdf

@tom-honeymoon-production tom-honeymoon-production added the bug Something isn't working label Feb 16, 2024
@ernestmarcinko
Copy link
Contributor

Thanks for the details.

The file is simply too lengthy for your local server to process. Consider using the media service feature instead.

@ernestmarcinko ernestmarcinko added the invalid This doesn't seem right label Feb 16, 2024
@ernestmarcinko ernestmarcinko self-assigned this Feb 16, 2024
@tom-honeymoon-production
Copy link
Author

Hi Ernesto,
I have used the media service feature - please refer to attached screen shot.
When I delete and add the PDF again - the same error is shown after 30 seconds.
When I rebuild the search index with acrtivated media service feature (free license) after some seconds I get the success message but with 0 keywords added to the search index. And the counter for number of indexed files in the current period remains unchanged to 37/10000.
Do you have any ideas what I could have configured in the wrong way?
Kind regards
Thomas
media service feature

@ernestmarcinko
Copy link
Contributor

0 new keywords can be just an missing count from the query report, the keywords are very likely still there. I checked the remote server, the document was parsed correctly and it's there. The counter may not move as it was probably cached from me trying to index it earlier and it did not count towards your usage.

My only guess here is a possible firewall, not allowing the connection, so make sure that these domains and IP are not blocked.

mediaservices.ajaxsearchpro.com
207.154.228.114

Also, the file has a lot of text, over 300 pages as far as I can see, so make sure your PHP memory limit is plenty large in php.ini, I recommend at least 512MB:

; Maximum amount of memory a script may consume
; https://php.net/memory-limit
memory_limit = 512M

Increase the max execution time as well temporarily, I can see this time out on the server side:

; Maximum execution time of each script, in seconds
; https://php.net/max-execution-time
; Note: This directive is hardcoded to 0 for the CLI SAPI
max_execution_time = 120

On my end it's working fine on both a remote and local server, I see the parsed text as well on the media file window when I upload the file.
image

@tom-honeymoon-production
Copy link
Author

Hi Ernesto,
thanks for your very fast response. I also see content parsed by Ajax Search Pro Media Service. But searching for special word in that content the search result doesn't include that document. How can I check the index to verify the words are included in the index?
Many thanks in advance
Thomas

@ernestmarcinko
Copy link
Contributor

If you don'tr get any results for anything in the file content, then it's not indexed for sure.

That means that the indexing process fails. That could be just a simple server or process performance issue, it is quite a lengthy file, I can imagine the PHP process failing if the server can't handle it. The error message confirms that as well.

I suggest the PHP ini changes I mentioned above, longer time and a bit more memory will very likely do the trick.

@tom-honeymoon-production
Copy link
Author

Hi Ernesto,
I changed the server limits PHP memory limit was already 1024M - but I changed 'max_execution_time' from 30 to 240.
The File gets uploaded and the content as parsed by the AJAX media service is available.
After about 1 Minute I get an 500 server error.
When I checked the search - I don't get a result.
See attached infos.
Kind regards
Thomas
mex_execution 240

@ernestmarcinko
Copy link
Contributor

Okay, at least there is an error message, which leads somewhere.

Error 500 means an internal server error, which will write a log and will lead to the solution here.
Can you please check the PHP error log?

Usually the easiest way to find the related error in the PHP error log is to replicate the issue, then check the log immediately. You can upload it as well after triggering the error, I can probably find it.

@tom-honeymoon-production
Copy link
Author

hmmm, I didn't get an error logged to the WordPress error log file. I even inserted a plugin to generate some fatal errors and warnings to see if I have configured error log handling correctly. Then I deactivated that 'plugin' again and loaded the big file again. I get an 500 error but no entry in the wordpress error log file
no error logged

@ernestmarcinko
Copy link
Contributor

Check if the error logging is enabled, error 500 will trigger a log, as it's due to a fatal error.

Check the php.ini configuration for the log file location. Usually it's in /var/log foldel on the server.

@tom-honeymoon-production
Copy link
Author

There is no path in the php.ini but only the ERROR_LOG WordPress constants defined in wp_config.
The Error File is located in /wp-content/debug.log
path_to_log_file

@ernestmarcinko
Copy link
Contributor

Well, that error seems to be unrelated, as far as I can tell.

Unless the log file can be found somewhere, I can't do much. You may have to consult with the host to see where PHP is actually logging (not by WP configuration), and if the error reporting is enabled with that configuration.
It differs for every system, but that is out of the scope of this issue.

@tom-honeymoon-production
Copy link
Author

I'm a little bit frustrated - I asked my webhoster and added the error log configuration to the php.ini. When I create a 500 Server error with another plugin - the 500 error is logged but not when I upload that file.
500 not logged

@ernestmarcinko
Copy link
Contributor

Try a different error log location, that is the same as it's defined in the wordpress config, so you can't be sure if it's coming from the PHP ini or the config. Note that there are multiple php.ini-s on most servers, one for the CLI and one for the Apache or FPM handler. I suggest only adding the definie('WP_DEBUG', true); to the wp-config.php and nothing else related to logging, so they don't conflict and it uses the default PHP log file. The direct the error log somewhere else in the php.ini to make sure it's actually working.

Either way, this is now not plugin related, but I will still try to help if I can. If there is an error 500 reported, that is triggered by a fatal error in the PHP and it has to exist or logged somewhere. PHP fatal errors don't just vanish.

@tom-honeymoon-production
Copy link
Author

Many thanks for your patience!!!
" I suggest only adding the definie('WP_DEBUG', true); to the wp-config.php and nothing else related to logging, so they don't conflict and it uses the default PHP log file. The direct the error log somewhere else in the php.ini to make sure it's actually working."
I have done this ;-) Same result :-(
What I'm wondering: the max_execution_time is set to 240 seconds but the 500 error occurs after about 1 minute.
500 not logged error after 1 minute

@ernestmarcinko
Copy link
Contributor

Well, only thing left is then to direct the error log to a different file in the php.ini to see if that actually directs the log there. Also, might be worth checking the Apache access logs to see if there is something valuable. I honestly don't know what is wrong here.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working invalid This doesn't seem right
Projects
None yet
Development

No branches or pull requests

2 participants