Fetching newer nodes before older ones are available

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:

  1. a player thread A try to join a game (create a token, say 0x100)
  2. a player thread B try to join the same game (create a token, say 0X101)
  3. B query the game, and see only one token (0x101), its own token, so B thinks it succeeded in joining the game
  4. 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
  5. 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?

I updated the description, more clear I hope.

No clue why that can happen?

Note: I’m using only one dGraph server, and that can happen when I run 30 to 50 goroutines, each of them iterating over game creation and game picking.

I have not particularly seen myself in this situation. It would need a more detailed analysis, closely.
At most what I can recommend is you evaluate the resources intended for the Alphas instances, review your configs (Dgraph Alpha, Clients and so on). And upgrade the Dgraph to a latest version.

https://docs.dgraph.io/deploy#upgrade-database

I really do not know what to say about your case. Do you have confidence in your design?

Please, share more details about your configs.

Upgrading to 1.0.10 causes me a bug, so I’ll wait for a fix before upgrading.

My Alpha setup is very basic, one zero, one server, no special options.
My data are generated each time from scratch as I encounter this bug with my testing database.
My design seems fine and has many tests, but I’m not fluent in go yet.

I’ll try again when 1.0.10 will work with my code.

1 Like

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.