Trying to invite removed member but getting "This person is already a team member."

https://mattermost.atlassian.net/browse/MM-24573

Mattermost Version: 5.26.0

Database Schema Version: 5.26.0

Database: postgres

Running with docker-compose.

PostgreSQL logs:

LOG:  database system was interrupted; last known up at 2021-04-12 23:03:49 UTC
LOG:  database system was not properly shut down; automatic recovery in progress
LOG:  redo starts at 0/3F5C0A70
LOG:  record with zero length at 0/3F5C1360
LOG:  redo done at 0/3F5C1330
LOG:  last completed transaction was at log time 2021-04-12 23:04:45.920694+00
LOG:  MultiXact member wraparound protections are now enabled
LOG:  database system is ready to accept connections
LOG:  autovacuum launcher started
ERROR:  relation "idx_teams_description" does not exist
STATEMENT:  SELECT $1::regclass
ERROR:  duplicate key value violates unique constraint "users_username_key"
DETAIL:  Key (username)=(surveybot) already exists.
STATEMENT:  insert into "users" ("id","createat","updateat","deleteat","username","password","authdata","authservice","email","emailverified","nickname","firstname","lastname","position","roles","allowmarketing","props","notifyprops","lastpasswordupdate","lastpictureupdate","failedattempts","locale","timezone","mfaactive","mfasecret") values ($1,$2,$3,$4,$5,$6,$7,$8,$9,$10,$11,$12,$13,$14,$15,$16,$17,$18,$19,$20,$21,$22,$23,$24,$25);
ERROR:  operator does not exist: boolean = integer at character 67
HINT:  No operator matches the given name and argument type(s). You might need to add explicit type casts.
STATEMENT:  SELECT COUNT(*) FROM Teams WHERE DeleteAt = 0 AND AllowOpenInvite = 1
ERROR:  operator does not exist: boolean = integer at character 67
HINT:  No operator matches the given name and argument type(s). You might need to add explicit type casts.
STATEMENT:  SELECT COUNT(*) FROM Teams WHERE DeleteAt = 0 AND AllowOpenInvite = 1
ERROR:  operator does not exist: boolean = integer at character 67
HINT:  No operator matches the given name and argument type(s). You might need to add explicit type casts.
STATEMENT:  SELECT COUNT(*) FROM Teams WHERE DeleteAt = 0 AND AllowOpenInvite = 1

I previously accidentally removed the wrong member from the team, so I tried to add this member back. The member is obviously missing completely from the Team, yet, when I try to invite this member back into the team, Mattermost is telling me, that the member supposedly is already part of the team.

As can be seen in the log, there is a type problem in the database.

Restarting the Mattermost instance and its database seems to have solved my problem. Still, the unintended behaviour is still an issue.

Hello, @Akito

I would recommend you to consider backing up and upgrading your Mattermost instance to see if the behavior is still reproducible since [MM-24573] The schema for the scheme* columns should be booleans, not smallints - Mattermost is an old bug.

We can then determine if the bug should be reopened and reinvestigated again to ensure that it is resolved for good.