ILIAS icon indicating copy to clipboard operation
ILIAS copied to clipboard

IRSS: Add micro optimizations for revision database repository

Open mjansenDatabay opened this issue 6 months ago • 0 comments

If approved, this should (at least) be picked to all "upper" ILIAS versions/branches.

This PR suggests changing the approach used to persist resource information in \ILIAS\ResourceStorage\Revision\Repository\RevisionDBRepository::store.

Issues:

  1. Round-trips: 1 × SELECT + (1 × UPDATE or 1 × INSERT)
  2. Potential race condition (unlikely in the IRSS context): Time goes by between the SELECT and (UPDATE or INSERT)
    • And specifically: Handling this in the application would have a lot of drawbacks (restriction of concurrency, slow, complexity depending on the approach) / Update: It seems to be already handled by the table names provided via \ILIAS\ResourceStorage\Lock\LockingRepository::getNamesForLocking

In both cases, for INSERT and UPDATE, we currently persist values for all database fields in il_resource_revision. Furthermore, the primary of table il_resource_revision is a combined key: rid and version_number.

So to address the problems I mentioned above, I hereby suggest using \ilDBInterface::replace (I know, if a row does exist, REPLACE deletes it and inserts the new data, in one atomic step, which should not be a problem IMO) instead, which is (IMO) also more readable.

To debate on: Alternatively, we could use an INSERT INTO ... ON DUPLICATE KEY UPDATE ....

mjansenDatabay avatar Jun 25 '25 12:06 mjansenDatabay