I am issuing a post request to a XDATA server usingTXDataClient. The log follows:
INSERT INTO extimgimg (
id, img)
VALUES (
:p1, :p2)
p1=292 p2=傉䝎ਚ
SELECT A.id AS A_id, A.img AS A_img
FROM extimgimg A
WHERE A.id = :p_0
p_0=292
[Value: POST /url/extimgimg 201 - 67,02 ms]
HttpApiException: HTTP Server API Error.
An operation was attempted on a nonexistent network connection
Questions:
Why a SELECT sql query runs after the insert?
Why it gives an exception in the end as printed by the following code:
XdataMod.Events.OnModuleException.Subscribe(
procedure(Args: TModuleExceptionArgs)
begin
memo1.Lines.Add(args.ErrorCode+': '+args.ErrorMessage);
end );
Why the above inside an CreateAnonymousThread gives "out of system resources"?
The out of system resources is probably not Xdata related and happens with Ttask too. I do not know why a thread or task has limited resources.
If no autofilled column exist and all fields are provided, Is there a reason to issue an sql select query after an insert?
The (EHttpApiException) HTTP Server API Error above does not create an exception in the TXDataClient client side. I read that could be caused by a closed connection from the client and I increased the timeout:
ilocal.HttpClient.OnSendingRequest:=procedure(Req: THttpRequest)
begin
req.timeout:=20000;
end;
The message continues and now the time reported is ~4358,94 ms for A4 pages saved as images with size that it is less than 1MB.
FireDAC providing DB connections has a ReadTimeout/WriteTimeout for Mysql that is 20 minutes and I have seen a maximum of 6399,30 ms with this error
Being more curious now, I have noticed that in other insert-post requests too (eg for 31ms), this message is reported by the TLoggingMiddleware and XdataMod.Events.OnModuleException with no exception in the client side, having autonumber columns and receiving correctly the select query data in case of autonumbering columns
Because the endpoint returns a JSON with the fully inserted object. Some objects might have been modified by the database server, and the endpoint then returns the final object state.
This is a normal exception that can be ignored. It simply indicates that the client is not available anymore to receive the response. Indeed, if the client request timed out, the client is gone, and the server can't send the response back to the client, thus the error.