Closed wezell closed 2 years ago
To QA - make sure the /api/vtl
endpoint still works as expected - perhaps try hitting a get.vtl
with ab
I was NOT able to generate a Thread Dump with a similar trace for the test Scripting API Endpoint I created. However, these are the steps I followed in my local dotCMS instance:
Employee
with the following text fields:
1.1. First Name.
1.2. Last Name.
1.3. Email.
1.4. Phone.Employee
./application/apivtl/test/
and added a get.vtl
file with this code:
#set($employeeList = $dotcontent.pull("+structureName:Employee +(conhost:$!{host.identifier} conhost:SYSTEM_HOST)",0,"Employee.lastName"))
#set($person = {})
$person.put("firstName", $employee.firstName)
$person.put("lastName", $employee.lastName)
$person.put("email", $employee.email)
$person.put("phone", $employee.phone)
$person.put("identifier", $employee.identifier)
$resultList.add($person);
$dotJSON.put("employees", $resultList)
4. Checked that the endpoint is correctly returning all 10 contentlets I created: http://localhost:8080/api/vtl/test
5. Used Apache Benchmark to try to simulate the situation found with the Thread Dump with the following command: `ab -n 10000 -c 10 http://localhost:8080/api/vtl/test `. However, I never got to see a similar trace.
It's very likely that this situation is only reproducible in live customer instances, which take a lot of traffic and execute more complex Velocity code. This would make this issue very hard, if not impossible to test in a local environment.
I also created example Endpoints for POST
, PUT
, PATCH
and DELETE
based on my previous scenario and our official documentation: https://www.dotcms.com/docs/latest/scripting-api . The Scripting API seems to be working as expected.
We have a customer that is calling the
/api/vtl
for content with every site hit, which is fine, except we are seeing a bunch of threads - like 50 of them - hung up in this code:Looking at that code, it seems that we are never calling close on the reader that we use to read the velocity file. We should close the reader with a try/close with resources.