Hello,
I’m in an odd situation where while doing high concurrency testing, I can sometimes end up in a situation where I fetch a node and its neighbors but some older neighbors are not yet returned by the query.
In my app, I have players who play games, so a player create a game, and the first other player who ask to join will play the game. Other players are rejected.
My data is made of :
- nodes representing: games, players and tokens
- predicates for: (game) join and (token) own.
A node game is created by a first player, then some of the parallel threads (representing players) create a token connected to the game node (token-[join]->game), and connected to himself (player-[own]->token). Then each of these threads query for the game and all connected tokens and see if their token UID is lower than the others. The lowest token UID join the game, other are rejected and will look for another game.
It works great most of the time but when increasing concurrency (with 50 players/threads playing 50 games each), sometimes:
- a player thread A try to join a game (create a token, say 0x100)
- a player thread B try to join the same game (create a token, say 0X101)
- B query the game, and see only one token (0x101), its own token, so B thinks it succeeded in joining the game
- A query the game and see both tokens (0x100 and 0x101) but its own one has a lower UID, so A also thinks it succeeded in joining the game
- but later when A or B actually start the game, they fetch it again and realize there are too many players!
So it seems to me the dGraph sometimes allow fetching newer data before older data is available to get.
Is it normal?
Is there a way to ask for some kind of synchronization of dGraph data before querying?