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

[Enhancement]: Rework matchmaking #33

Open
1 task done
DaniElectra opened this issue Jun 2, 2024 · 2 comments · May be fixed by #35
Open
1 task done

[Enhancement]: Rework matchmaking #33

DaniElectra opened this issue Jun 2, 2024 · 2 comments · May be fixed by #35
Assignees
Labels
approved The topic is approved by a developer enhancement An update to an existing part of the codebase

Comments

@DaniElectra
Copy link
Member

Checked Existing

  • I have checked the repository for duplicate issues.

What enhancement would you like to see?

Current issues

The current matchmaking implementation has many issues, including the following:

  • It is very prone to race conditions, since the Sessions map doesn't use any mutexes
  • We currently store the participants based on the connection ID, but this is inaccurate since Nintendo uses the PID instead. We need to change this in order to support multiple players from one console such as on Mario Kart 8
  • This model of storing the session data in memory is kinda flawed. While it works for games that only use MatchmakeSession, it doesn't work for games that use other gathering types. For example, Mario Kart 7 communities use PersistentGathering which uses the same gathering ID count as MatchmakeSession and must be always preserved between server reboots/crashes, but both MatchmakeSession and PersistentGathering use UnregisterGathering to delete them (which would require various hacks to handle on the current model). This model is also problematic for tracking, since we don't keep records of previous sessions

Proposal

PR #28 fixes the race conditions issue and it could be expanded to fix the second one, but as explained above this isn't enough. We will have to redo matchmaking from scratch. On Discord it has been proposed to store everything on an SQL database (since it's what Nintendo does) which would be managed by the common protocols implementation, while giving the liberty to the servers to choose a specific SQL database.

On this new implementation we still need to take into account race conditions and avoid them along the way, and we would also store connections based on the PID. This new model would also solve the session tracking issues since we are keeping records of all previous sessions

Any other details to share? (OPTIONAL)

As a nice to have, it would be great to design the new matchmaking model in a way that could support any Gathering type and not be limited to only MatchmakeSession and PersistentGathering. I think this could be reasonably done but we will have to see until it gets implemented.

Since we intend to use SQL, this issue partially depends on PretendoNetwork/nex-go#56 since the current NEX primitive types limit us on how we use them as native types.

On this new implementation we would also like to allow any SQL database, but we currently have a big dependency on Postgres and the pq.Array function (among possibly other Postgres-specific queries) across our different servers. While it may be doable, we would require some assistance from people that would be interested on this and would like to use other SQL databases.

@DaniElectra DaniElectra added enhancement An update to an existing part of the codebase awaiting-approval Topic has not been approved or denied labels Jun 2, 2024
@jonbarrow jonbarrow added approved The topic is approved by a developer and removed awaiting-approval Topic has not been approved or denied labels Jun 2, 2024
@jonbarrow
Copy link
Member

About the database concerns: I think for now we should probably just be opinionated on using Postgres here. I do agree that we should try to be more database-agnostic about it in the future, but that comes with some overhead that I'm not sure we should spend time investing in right now.

@DaniElectra DaniElectra self-assigned this Jun 24, 2024
@DaniElectra DaniElectra linked a pull request Jun 28, 2024 that will close this issue
4 tasks
@ItsPancho8
Copy link

I have issues with matchmaking on pretendo network from both Wii U and CemU, but I have open NAT type and I can perfectly do matchmaking on other services such as Wiimmfi, WiiLink, Nintendo Switch. But not on any pretendo modified games I own like Splatoon and Mario Kart 8. I get error code 118-0516 and sometimes error code 118-0519

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
approved The topic is approved by a developer enhancement An update to an existing part of the codebase
Projects
Status: In Progress
Development

Successfully merging a pull request may close this issue.

3 participants