topcoder-platform / forums

0 stars 0 forks source link

[$100] Duplicate accounts created on prod #277

Closed jmgasper closed 3 years ago

jmgasper commented 3 years ago

@atelomycterus - We had some duplicate accounts created on prod, with the same email and username. Any reason why this would happen? Is there any way to detect them and fix them? These seem to cause problems with the challenge forum processor when adding folks to the groups when they register for a challenge.

Screen_Shot_2020-12-08_at_7_32_36_am
jmgasper commented 3 years ago

Contest https://www.topcoder.com/challenges/30156326 has been created for this ticket.

This is an automated message for ghostar via Topcoder X

jmgasper commented 3 years ago

Contest https://www.topcoder.com/challenges/30156326 has been updated - it has been assigned to obog.

This is an automated message for ghostar via Topcoder X

atelomycterus commented 3 years ago

@jmgasper Is PROD configured with Memcached? What branch is deployed on PROD?

There can be one account created by a challenge processor and the other by Topcoder plugin. But I'm not sure. Checks 'if $username and $email are already in use by another member' is done in UserModel only. I've checked User table, there are no unique constraints in DB.

  1. How many duplicate accounts created on prod? select count(*) c, u.Email from GDN_User u group by u.Email having c > 1 order by u.Email

  2. How many duplicate accounts created on prod? select count(*) c, u.Name from GDN_User u group by u.Name having c > 1 order by u.Name

  3. Could we check challenge forum processor logs from 17 November?

    • Execute this query select u.UserID from GDN_User u where u.Name='Dylan_Liu'

How many records found? If no records or only one then one or both records are created by Topcoder plugin.

  1. How many groups does he participate in? select ug.GroupID, g.Name, u.UserID, u.Name from GDN_UserGroup ug left join GDN_Group g on ug.GroupID = g.GroupID left join GDN_User u on ug.UserID = u.UserID where u.Name = 'Dylan_Liu'
jmgasper commented 3 years ago

@atelomycterus - Prod is not currently using memcached (we haven't deployed that update yet), and it's running the master branch of the forums. It hasn't been deployed in a couple weeks.

I'm working on running the SQL, thanks.

jmgasper commented 3 years ago

@atelomycterus:

  1. select count(*) c, u.Email from GDN_User u group by u.Email having c > 1 order by u.Email

    2   ajinkyakolekar.p@gmail.com
    2   dylanliuofficial@gmail.com
  2. select count(*) c, u.Name from GDN_User u group by u.Name having c > 1 order by u.Name

    2   Dylan_Liu
    2   koleum
  3. select ug.GroupID, g.Name, u.UserID, u.Name from GDN_UserGroup ug left join GDN_Group g on ug.GroupID = g.GroupID left join GDN_User u on ug.UserID = u.UserID where u.Name = 'Dylan_Liu'

    7   Topcoder Challenge API - Improve testing coverage   44  Dylan_Liu
    8   Topcoder Resources API - Improve testing coverage   44  Dylan_Liu
    7   Topcoder Challenge API - Improve testing coverage   45  Dylan_Liu
atelomycterus commented 3 years ago

@jmgasper I've reviewed code + tested different cases, but I can't reproduce it. If an issue still exists, in order to avoid duplicate accounts, we need to add unique constraints to email and name on User table. But first we need to decide how to fix the existing duplicates.

Option 1. Using Vanilla 'Delete User'

Click on 'Delete'. There are 3 options. image 'Delete the user' means removing user'details. Need to fix Name because after deleting records 'Name' column have duplicates +deploy it to PROD. Deleted Users are not displayed. image

Option 2. Write sql script and update tables

Write sql script, use min UserID of duplicated account and update data:

Option 3. Write simple sql script and update user records

The same as Option1 but using sql script

Add unique indexes on User Table

Replace indexes with unique indexes on User Table

DROP index FK_User_Name ON GDN_User;
DROP index IX_User_Email ON GDN_User;
CREATE UNIQUE index UX_User_Name ON GDN_User (Name);
CREATE UNIQUE index UX_User_Email ON GDN_User (Email);

DEV

I've checked DEV env. Two duplicated accounts (admin, tc_admin). They were created in February and September. No duplicate accounts since September. image

image

jmgasper commented 3 years ago

@atelomycterus - Ok, thanks. I'll go through and clean this up. It only happened twice, so we'll keep an eye on it and try to see if it happens again, otherwise I'll just chalk it up to a fluke.

jmgasper commented 3 years ago

Payment task has been updated: https://software.topcoder.com/review/actions/ViewProjectDetails?pid=30156326

This is an automated message for ghostar via Topcoder X