I’m creating a app that runs in the XOJO Cloud, 11.3.2-MariaDB (MariaDB Server). The app spins up at least two instances, so the logic executing in app is executing in duplicate - which isn’t a bad thing, but something I’m not exactly clear on how to address in respect to colliding on database transactions.
Below is a simplified version of an update, where I’m changing the status of a record from ‘0’ (unprocessed) to ‘1’, to stage it for the next sweep of logic.
Question: If the 1st app instance is in the midst of this update, and the 2nd instance tries to perform the same routine, what happens? Is there a moment when the records will be locked, and the 2nd instance will be thrown a DatabaseException?
And, I’m not sure what current practices are - but is it best to still use .CommitTransaction and .RollbackTransaction methods? I’m in the dark as to what happens when ExecuteSQL() is called, and what happens when it fails.
Thanks for any advice for having multiple apps play well together with a single dbase.
Var xFNdbase As MySQLCommunityServer = new_FNdbase_connection()
Var stmt As MySQLPreparedStatement
Try
If Not xFNdbase.Connect() Then Return
stmt = MySQLPreparedStatement(xFNdbase.Prepare("UPDATE dbase.tablename SET RECORD_STATUS = ? WHERE (ID = ?);"))
stmt.BindType(0, MySQLPreparedStatement.MYSQL_TYPE_SHORT)
stmt.Bind(0, new_status)
stmt.BindType(1, MySQLPreparedStatement.MYSQL_TYPE_SHORT)
stmt.Bind(1, record_ID)
stmt.ExecuteSQL()
'xFNdbase.CommitTransaction
xFNdbase.Close
Catch error As DatabaseException
'xFNdbase.RollbackTransaction
xFNdbase.Close
// massive error handling goes here
End Try
1 post - 1 participant