[User-login] Restoring Jira 8.22 (and newer) backup to Cloud

Still need help?

The Atlassian Community is here for you.

Ask the community

Resources

JRASERVER-70690 - Getting issue details... STATUS

User-login JIRA stats logs

[User-login] Restoring old Jira backup to 8.22.0 and newer

Restoring Jira 8.22 (and newer) backup to Cloud

In Data Center’s UpgradeTask_Build822000 we modify indexes on cwd_membership table.

Server and DC < 8.22 and current Cloud mandates uniqueness of (parentId, childId, membershipType), while DC >=8.22 mandates uniqueness of (lowerParentName, lowerChildName, membershipType, directoryId).

Since DC >=8.22 ignores parentId and childId, there might be some incorrect values in those columns, violating uniqueness of the cloud index.

We cannot fix those ids in this upgrade task, though, because the order of operations is:

  1. Load DB schema from entitymodel.xml, including the unique indexes.

  2. Load data from backup

  3. Run downgrade/upgrade tasks.

Operation #2 fails if the imported data violates the index constraints. Hence, we need to fix the data before exporting from Server.

  1. Create a backup of the database

  2. Remove blocking (inconsistent) user from cwd_membership and consequently update cwd_user:

DROP INDEX UK_MEM_PARENT_CHILD_TYPE;

update cwd_membership
set child_id = U.id
from cwd_user U
where cwd_membership.lower_child_name = U.lower_user_name
and cwd_membership.directory_id = U.directory_id
and cwd_membership.membership_type = 'GROUP_USER'
and child_id != U.id;

update cwd_membership
set child_id = G.id
from cwd_group G
where cwd_membership.lower_child_name = G.lower_group_name
and cwd_membership.directory_id = G.directory_id
and cwd_membership.membership_type = 'GROUP_GROUP'
and child_id != G.id;

update cwd_membership
set parent_id = G.id
from cwd_group G
where cwd_membership.lower_parent_name = G.lower_group_name
and cwd_membership.directory_id = G.directory_id
and parent_id != G.id;

delete from cwd_membership 
where lower_child_name not in
(
  select lower_user_name 
  from cwd_user
)
and membership_type = 'GROUP_USER';

delete from cwd_membership 
where lower_child_name not in
(
  select lower_group_name
  from cwd_group
)
and membership_type = 'GROUP_GROUP';

delete from cwd_membership 
where lower_parent_name not in 
(
  select lower_group_name
  from cwd_group
);

create unique index uk_mem_parent_child_type
on public.cwd_membership 
using
btree (parent_id, child_id, membership_type)


3. A cold restart is needed to rebuilt the cache with the correct data.

Last modified on Jan 24, 2022

Was this helpful?

Yes
No
Provide feedback about this article
Powered by Confluence and Scroll Viewport.