Skip to main content

Hello !

We have this error message while trying to do the merge . We have digged a little bit in the task_execute_merge_session procedure ,but we can not figure out where the problem is coming from.

error msg

How can we fix this problem in order to proceed with finalizing the merge?

Very much appreciated! 

Kind regards,

Ema 

Hi,

It depends a bit, is this a regular Origin to Branch or Branch to Origin merge session, or is this a revert to a prior moment in time?

Nevertheless, it seems that there's an Update taking place and it tries to use a User_id (dbo.tsf_user()) that does not exist in the Usr table. Depending on who is running the process, that user should be present in the Usr table. If that is actually the case, please update the RDBMS user field to be equal to the result of dbo.tsf_user().


It is a Branch to Origin merge session.We have compared the RDBMS user and dbo.user() are the same ,so it didn’t fix the issue.


We tried again with the debugger open, and received this exception:

The UPDATE statement conflicted with the FOREIGN KEY constraint "ref_usr_control_proc_developed". The conflict occurred in database "STARCODE_SF", table "dbo.usr", column 'usr_id'.

Line number: 27

Procedure: execute_action_revert_update_control_proc

task_execute_merge_session
merge_session_id = 69
scheduled_merge = False
archive_branch = True

Gr Bart 


Hi,

Doing a Revert will revert the state of all branch related objects, such as Control procedures. At the moment in time you want to revert to, a particular User is used that is no longer present in the Software Factory (table Usr).

To find out which user is the problem, you can use this query on the SF database. Please fill in the model and branch you are attempting to revert. Also fill in the moment in time you want to revert to, e.g. '2023-08-17 07:00:00’ - Note this is UTC time:

-- Change to your model and branch
declare @model_id model_id = '',
@branch_id branch_id = ''
declare @moment_in_time datetime2 = '' -- Fill in the time to revert to

select developer_id, *
from control_proc for system_time as of @moment_in_time c
where c.model_id = @model_id
and c.branch_id = @branch_id
and c.developer_id not in (select usr_id from usr)

-- Add the user again
insert into usr
(
usr_id,
usr_name
)
select
developer_id,
developer_id
from control_proc for system_time as of @moment_in_time c
where c.model_id = @model_id
and c.branch_id = @branch_id
and c.developer_id not in (select usr_id from usr)

Sidenote, are you trying to revert to a moment in time before a Origin to Branch merge occurred? E.g. MAIN to DEVELOP? 


Thank you for the support ! We were able to fix it in the end .