Closed dominikfeininger closed 9 months ago
Hello @dominikfeininger ,
If possible, can you provide a reproducible sample or at least share with us parts of your code, which lead to a different than expected behavior?
Regards, Iliana
Hi, I will try to provide an example, but this will be quite complicated due to the need of a backend service.
If the issue appears in a SAP system, you might create an SAP support incident so the developers can have a look at your system.
Hello @dominikfeininger ,
If possible, can you provide a reproducible sample or at least share with us parts of your code, which lead to a different than expected behavior?
Regards, Iliana
Hi, you can find a basic example here: https://github.com/dominikfeininger/OdataV2BatchIssue. Even though the northwind service does not accept the POST you can see the duplicate batching in the network tab if you press the add Item
button more often.
Hi @dominikfeininger, thanks for the sample. I have created an internal incident DINC0028400. The responsible team will analyze your issue and post any further updates here in github.
Hi @dominikfeininger,
We have analyzed the problem you have described and come to the following result:
Unfortunately, the sample application of you is not a valid example of the described problem because the northwind service does not accept the POST request due to the following error: "id-1704358929641-45' is not a valid value for the 'Content-ID' header. In batch requests, the 'Content-ID' header must be an integer value." At this point, however, the northwind service does not behave in accordance with specifications, see: https://help.sap.com/doc/5890d27be418427993fafa6722cdc03b/Cloud/en-US/OdataV2.pdf, 2.2.7.6.1.1 Referencing Requests in a Change Set https://www.rfc-editor.org/rfc/inline-errata/rfc2045.html,
As it looks to me, in your case v2.ODataModel.submitChanges is called for the second time, while the first v2.ODataModel.submitChanges has not yet been processed. This leads to the error you described. One way to avoid this problem may be to disable the "save" button which triggers v2.ODataModel.submitChanges until the submitChanges from a former click on this button has been processed. This could be done, for example, using the success or error handler of v2.ODataModel.submitChanges. However, this is the responsibility of the application.
To further analyze the error reason, you can try the following. Set a breakpoint in v2.ODataModel.submitChanges and see where the second call comes from in the event of an error.
I experience a strange race condition issue with oDataModel V2 and $batch requests.
The app saves new entries of an entity by user input or automatically. Technically the model sends multiple CREATE requests using
createEntry
andsubmitChanges
consecutively. This works most of the time fine.Sometimes a second $batch request containing the latest and the previous (still ongoing) CREATE is send due the last call was not finished yet. Since it is a create the SAP BE returns an duplicate IDs error.
OpenUI5 version: 1.102.17
What is the expected result?
What happens instead?