Forum BigDB BigDB index

Discussion and help relating to the PlayerIO database solution, BigDB.

BigDB index

Postby wbsaputra » April 3rd, 2011, 12:57 am

i have this property on player object table
player1
online.roomid = 11001
online.status = true
player2
(online property removed)

then i created index ByRoomId which had property online.roomid
when i try to load in admin panel bigDb and specify value 11001 for this index i had this result
player1
online.roomid = 11001
online.status = true
player2

why player2 is still showing even online status property removed?? any idea for this case??
wbsaputra
Paid Member
 
Posts: 150
Joined: June 29th, 2010, 4:38 pm

Re: BigDB index

Postby Henrik » May 18th, 2011, 7:39 pm

Hey, sorry for the late reply, but I think I've figured this one out now.

When you read an object, BigDB first tries our cache, and if it fails, it tries to read it from the backing distributed datastore. And when you create an index on an existing table, it builds the index by first reading all objects in bulk, but the objects are not read from the cache, only from the datastore.

But since the datastore is distributed, it means that it takes a little while for a write to propagate to all servers. But if your table is changing rapidly, there was a chance that the index builder would read older versions of the objects that changed most recently, and then you would get the results you got, a corrupted index.

We've implemented changes recently in how data is stored and read in bulk from the backing datastore, so this problem should not occur anymore. You can force your index to be rebuilt by changing it. The quickest way should be to change the order by for Online.RoomId to Descending, hit Save Changes, change back to Ascending, and Save Changes again.
Henrik
.IO
 
Posts: 1880
Joined: January 4th, 2010, 1:53 pm

Re: BigDB index

Postby wbsaputra » May 19th, 2011, 11:31 am

I see, ok i will try.
i neel little help about bigdb preload player object.
with preload player object player can connect room twice with same stat.
then when player leaves room player object save will going to race condition.
example In room 1 player score is 500, in room2 player score is 1000.
so if player leave room2 first, player score 1000 saved to bigdb,then if player leave room2 score will be back to 500.
Any advice to avoid this?
Now i change my code to not use preload player object but use player.getplayerobject(delegate) method to save score.
wbsaputra
Paid Member
 
Posts: 150
Joined: June 29th, 2010, 4:38 pm

Re: BigDB index

Postby Henrik » May 19th, 2011, 11:33 am

You can use optimistic locking, then you will get an error if you try to save an object that has been modified by some other thread since you last loaded it in your current thread:

http://playerio.com/documentation/bigdb/advanced
Henrik
.IO
 
Posts: 1880
Joined: January 4th, 2010, 1:53 pm

Re: BigDB index

Postby Henrik » May 19th, 2011, 2:17 pm

I can see that you tried to rebuild the index twice now, but there was an error during the process that's not handled properly, so your index won't be accurate just yet.

I'm fixing this issue now, and I'll post an update when it's fixed and released.
Henrik
.IO
 
Posts: 1880
Joined: January 4th, 2010, 1:53 pm

Re: BigDB index

Postby Henrik » May 19th, 2011, 4:37 pm

There, fixed and released.

Try rebuilding that index now, and it should contain all matching objects.
Henrik
.IO
 
Posts: 1880
Joined: January 4th, 2010, 1:53 pm

Re: BigDB index

Postby wbsaputra » May 20th, 2011, 6:43 am

Henrik wrote:There, fixed and released.

Try rebuilding that index now, and it should contain all matching objects.


Yeap, thanks
wbsaputra
Paid Member
 
Posts: 150
Joined: June 29th, 2010, 4:38 pm


Return to BigDB



cron