Creating new node entity during presave of another node entity causes SQL Exception sometimes

We have a Donation Record Content type and a Donor content type for a Blood Bank management drupal application. A donor can have any number of donation record.

The system does not explicitly require creating a donor record prior to creating a donation record. It creates a donor record during presave of donation record if the donor reference is not provided in the URL. The system gets the reference from the created donor during presave and updates it in the donation record. Hence we now have a donor with a donation record while the user is saving a donation record.

The problem is that new donor record does not get created all the time. We get SQL Exception: SQLSTATE[42000]: Syntax error or access violation: 1305 SAVEPOINT savepoint_1 does not exist.

Is there any other way to create the donor so that this problem does not occur or am I doing something wrong.

Drupal 7.61 MySQL 5.7.24 OS: Ubuntu 16.04.5 LTS

Trace: 0 /srv/www/ PDOStatement->execute(Array) 1/srv/www/ DatabaseStatementBase->execute(Array, Array) 2/srv/www/ DatabaseConnection->query(‘ROLLBACK TO SAV…’) 3/srv/www/ DatabaseConnection->rollback(‘savepoint_1’) 4 /srv/www/ DatabaseTransaction->rollback() 5/srv/www/ node_save(Object(stdClass)) 6/srv/www/…(885): entity_save(‘node’, Object(stdClass)) 7 /srv/www/…(114): EntityDrupalWrapper->save() 8/srv/www/…(226): DonorEntity::createNewDonorFromDonationRecord(Object(EntityDrupalWrapper))