enhancement
major
minor
defect
critical
major
minor
major
#29847
Scripted test TestTransactionMonitor-01_RevertRevision fails when a scheduled task commits concurrently
Problem
The scripted test test/com/top_logic/demo/scripted/monitor/TestTransactionMonitor-01_RevertRevision.script.xml failed in the nightly build TL7 #798:
Resolving ValueNamingScheme 'com.top_logic.layout.scripting.recorder.ref.ChangeSetValueNaming' failed!
Local object not found: {revision=r4114}; Options: 'ChangeSet [rev=4111, ... DELETED ... TestRevertRevision]', ...
Analysis
The script stores the revision of its own commits in global variables using LastRevisionNamingScheme, which resolves to the last revision of the knowledge base (HistoryManager.getLastRevision()). It then selects that revision in the transaction monitor.
In the failing run the deletion of TestRevertRevision was committed as r4111 at 07:30:00.515. At 07:30:00.55 the scheduler started the half-hourly tasks (CleanImageTmpDir, MailServerDaemon, RefreshUsersTask, SchedulerClusterCleanupTask), whose task logs were committed as system revisions r4112–r4114. The variable Deleted TestRevertRevision was assigned r4114, a system change the transaction monitor hides (UpdateChangeSetTreeCommand shows only revisions authored by a person). So the lookup failed.
Every use of LastRevisionNamingScheme means "the revision of the script's own last change" and is exposed to the same race: the scripts TestComments-01_EditWithReadRight, TestShowHistoricObject-01_DeletedAttribute, TestHistoricObjectsWithScriptAttributes, TestUndo, TestRevisionAccess, TestRestoringDeletedObjectsWithDocuments, TestZipDownload-01_HistoricObject, TestDemo-72, TestDemo-73, TestComparison-00 (partly through the template Variable/Action-Variable-Revision merken.xml), and actions recorded with StoreCurrentRevisionCommand.
The session revision of the script's sub-session cannot be used instead: LiveActionExecutor.processAtomic() calls MainLayout.globallyValidateModel() after each action, which updates the session revision to the last revision of the knowledge base before the next action runs.
Change
LastRevisionNamingScheme resolves to the last revision committed by the user executing the script: the last revision whose author is the context ID of the action context's sub-session (the context ID a commit of that sub-session records as author). Revisions committed concurrently by the system or by other users are skipped.
TestComments-01_EditWithReadRight stores the revision of a comment created by the user testEditComment; the variable assignment is now executed by that user (user-id="testEditComment").
Migration
A script that assigns LastRevisionNamingScheme after a commit of another user than the one executing the assignment must execute the assignment as the committing user (user-id of the SetGlobalVariableOp).