Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

bugfix: fix internalserverError while connecting mongoDB with clustering uri #20

Merged
merged 2 commits into from
Mar 13, 2024

Conversation

wu0h961738
Copy link
Contributor

@wu0h961738 wu0h961738 commented Mar 5, 2024


🔍 What type of PR is this?

bug

👀 What this PR does / why we need it:

  • My pull request adheres to the code style of this project
  • My code requires changes to the documentation
  • I have updated the documentation as required
  • All the tests have passed

🅰 Which issue(s) this PR fixes:

Fixes openimsdk/open-im-server#1627

📝 Special notes for your reviewer:

  • root cause: context management in Golang.

    In the m.tx code block within the initialization function, misusing the ctx parameter as the parameter for end session and Transaction function calls actually captures a context that does not exist in the init function. Therefore, it causes the first user registration to succeed in a clustering architecture (because at this point the ctx is the same as the actual execution context of the function). However, the second execution fails (since the ctx within m.tx is garbage-collected at the end of the first task).

🎯 Describe how to verify it

With config of monogdb changed from address to clustering uri format (mongo+srv://XX), sending request multiple times to the API /user/user_register won't show the internal server error again.
While at the same time, the test of the origin scenario in which the standalone mongoDB serve as the database is still successful functioning as well. 

📑 Additional documentation e.g., RFC, notion, Google docs, usage docs, etc.:

@FGadvancer FGadvancer merged commit ff9351b into openimsdk:main Mar 13, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants