Locking of database records

I have the following question regarding the locking mechanism on the Postgres Database. I have multiple users who can login and access the same customers. How does the platform prevent me from making changes to a customer account when another users is editing a customer account? Han Pieter
3 answers

Hi Han

I have seen no evidence of any platform based record locking mechanism to prevent one user overwriting another's changes if they are editing simultaneously - perhaps someone from Mx can confirm?

However, in the past I have added this sort of functionality through workflow. Basically, write to a linked lock record table when a record is opened, and clean up the lock record when closing a form. Then when a user tries to open a form, check for an existing linked lock record, and if it exists open a read-only view of the data with a warning giving the name of the user who is currently editing the record. HTH


Maybe it can be solved in the community commons package in a generic way, I posted an proposal here:



On another platform (BMC Remedy ARS) this is solved in the following way:

  • Each record has a changedDateTime
  • The changedDateTime on retrieve is remembered
  • On save/commit the changedDateTime as remembered is compared to the changedDateTime in the database
  • If database changedDateTime > remembered changedDateTime than a message is given that somebody updated this record and the save/commit is canceled.

Off course this still needs locking during the transaction with some kind of SELECT FOR UPDATE, but it shortens the overlaptime dramatically from users having records open for minutes (or longer) to the sub-second level.

I have an enhancement request issued at Mendix for this function, allthough to be precise, I've asked for a function IsModifiedByOtherUser(), so I can determine myself what should happen.