Verify that the lock is still held and refuse the write otherwise.
We have to guarantee that we dont write to an unlocked record.
If we write to a record after it has been released, the record may have
already migrated off the node, in which case we get a DMASTER split brain for this record. (These application bugs are incredibly hard to track down)
int ctdb_writerecord(struct ctdb_lock *lock, TDB_DATA data)
{
+ if (!lock->held) {
+ errno = EBADF;
+ DEBUG(lock->ctdb_db->ctdb, LOG_ERR,
+ "ctdb_writerecord: Can not write. Lock has been released.");
+ return -1;
+ }
+
if (lock->ctdb_db->persistent) {
errno = EINVAL;
DEBUG(lock->ctdb_db->ctdb, LOG_ERR,