Persistence Service database locking issue when it ends ungracefully

Note: Applies to RTI Connext DDS 5.3.x

If Persistence Service closes ungracefully (via  Ctrl-C or the kill -9 command), a new Persistence Service instance will not be able to run. It will show the following error message:

Database is already in use by another RTI Persistence Service or was ungracefully terminated.
Delete all the entries in the PERSISTENCE_SERVICE table before restarting the service
main:!start persistence service

This error message is part of a new feature since 5.3.0 that controls access to the database by multiple Persistence Service instances. This feature uses a locking mechanism to prevent the database from getting corrupted and unusable when two Persistence Services are started, and they are configured to use the same database. The error message is shown when a Persistence Service instance attempts to access a locked database. 

The locking mechanism works as follows:

  • When the first Persistence Service instance starts, it locks the database by writing specific content in the PERSISTENCE_SERVICE table.
  • If another Persistence Service instance starts, it will read the content in the PERSISTENCE_SERVICE table and the specified error above will be displayed.
  • When the first Persistence Service finishes gracefully, the lock will be released, deleting the content of the PERSISTENCE_SERVICE table. 

If, for any reason, the first Persistence Service instance finishes ungracefully, the lock will not be released. This will prevent new Persistence Service instances from accessing the database.

The  -disableDatabaseLocking option will cause Persistence Service to ignore the lock. We added this feature to allow Persistence Service to behave as in previous versions. Using this option would only cause problems when you run more than one Persistence Service instance within the same database.

In order to release a locked database, you can go through the following steps::

  • Run Persistence Service with -disableDatabaseLocking.
  • Finish Persistence Service gracefully.
  • This will unlock access to the database: the content of the PERSISTENCE_SERVICE table will be deleted even if the table was previously locked by another Persistence Service instance.