Back

Concurrency issue?

  • 0
  • Self Hosted
  • Auth
Meister der Magie | Martin
28 Nov, 2024, 17:23

I have this server side code (.NET SDK):

TypeScript
//no label is set, but also no exception is thrown

Task<User> updateLabelTask = users.UpdateLabels(studentId, new List<string> { "student" });
Task<Membership> joinStudentsTask = teams.CreateMembership(AppwriteSettings.StudentsTeamId, new List<string>(), null, user.Id);
Task<Membership> joinSchoolTask = teams.CreateMembership(schoolId, new List<string>() {"student"}, null, user.Id);
Task<Membership> joinGroupTask = teams.CreateMembership(group.Id, new List<string>() {"student"}, null, user.Id);
Task<User> verifyTask = users.UpdateEmailVerification(user.Id, true);

await Task.WhenAll(updateLabelTask, joinStudentsTask, joinSchoolTask, joinGroupTask, verifyTask);

This works fine, except for updating the label. If instead I await the updating and only then continue with the other tasks, it works. Why could that happen? Is this an Appwrite issue?

TypeScript
//label is set to "student"

Task<User> updateLabelTask = users.UpdateLabels(studentId, new List<string> { "student" });

await updateLabelTask;

Task<Membership> joinStudentsTask = teams.CreateMembership(AppwriteSettings.StudentsTeamId, new List<string>(), null, user.Id);
Task<Membership> joinSchoolTask = teams.CreateMembership(schoolId, new List<string>() {"student"}, null, user.Id);
Task<Membership> joinGroupTask = teams.CreateMembership(group.Id, new List<string>() {"student"}, null, user.Id);
Task<User> verifyTask = users.UpdateEmailVerification(user.Id, true);

await Task.WhenAll(joinStudentsTask, joinSchoolTask, joinGroupTask, verifyTask);
TL;DR
Developers experiencing concurrency issues when trying to update a label in a .NET SDK code. A workaround is to update the label separately before moving on to other tasks to avoid the issue. This may not be an Appwrite problem.
Meister der Magie | Martin
28 Nov, 2024, 17:29

Update: It only happens most of the time. Sometimes it works.

Reply

Reply to this thread by joining our Discord

Reply on Discord

Need support?

Join our Discord

Get community support by joining our Discord server.

Join Discord

Get premium support

Join Appwrite Pro and get email support from our team.

Learn more