AnswerBun.com

Managing Database Calls For Every Socket Message Spring Boot

Stack Overflow Asked by KAD on November 26, 2020

I have a spring boot application web-socket server up and running as a WEBRTC signaling server.

This server has to log some data to the database, based on the messages rotated from/to the server, via different client sockets.

While trying a conference call from client side using more than 2 peers, and running the signaling as debugger with breakpoints, the scenario was successfully completed and the database was updated as expected and the conference call took place.

But, if I run the server without debug and breakpoints, I get an sql error

Batch update returned unexpected row count from update [0]; actual row count: 0; expected: 1; statement executed: [email protected] wrapping com.mysql.cj.jdbc.ClientPreparedStatement: 

delete from my_table where my_table_id='601cbe2b-6af2-4e82-a69c-52b92d30686c'; nested exception is org.hibernate.StaleStateException: Batch update returned unexpected row count from update [0]; actual row count: 0; expected: 1; statement executed: [email protected] wrapping com.mysql.cj.jdbc.ClientPreparedStatement: 

delete from my_table where my_table_id='601cbe2b-6af2-4e82-a69c-52b92d30686c'

I am using Spring JPA and calling the save function on every message received by the web-socket after populating the entity data and all its nested lists and relational entity object, in order to keep data of the call flow.

conferenceRepository.save(conference);

I think the error is because of queries running concurrently on the database, in random order, while the data is still not there in the database to act upon.

As in debug mode, I am taking time to move from one breakpoint to another, and this is assuring the data persistence.

But I am not totally sure of the problem.

Is there an optimal way to apply concurrent database calls and updates and make sure the data is preserved and persisted properly in the database for concurrent web-socket related messages?

Add your own answers!

Related Questions

how to count number of file with a matching pattern using python

2  Asked on February 16, 2021 by suryansh-mathur

 

R First Row By Group When Condition Is Met

4  Asked on February 16, 2021 by bvowe

   

C++ program won’t print anything with vectors?

2  Asked on February 16, 2021 by luckylone-official

 

What is damping for?

3  Asked on February 16, 2021 by lix

       

Spring 5 MVC not finding mapping to controller returning JSON

2  Asked on February 16, 2021 by gary-kephart

   

Pointer value in c

3  Asked on February 15, 2021 by gsoap

 

Memory allocation of map[int]interface{} vs map[int]struct{}

2  Asked on February 15, 2021 by gabriel-gonzalez

   

Does the “leftmost prefix rule” of Index applies to SQL Server?

2  Asked on February 15, 2021 by drillfreak100

   

How to add ArrayList to JsonObject in Kotlin

2  Asked on February 15, 2021 by rajitha-perera

   

How to get data from axios request?

1  Asked on February 15, 2021 by theyaxxe

   

Ask a Question

Get help from others!

© 2022 AnswerBun.com. All rights reserved. Sites we Love: PCI Database, MenuIva, UKBizDB, Menu Kuliner, Sharing RPP, SolveDir