Cloud service not updating?

Discussion about using Moai Cloud - post questions, bugs and issues here.

Cloud service not updating?

Postby rapidfirestudio » Tue Jul 24, 2012 9:23 pm

I've been testing out a multiplayer prototype using the cloud. I've noticed that it sometimes takes minutes (a guess, maybe 5 or more) for the could to update after uploading new code OR updating the database. That is, I can change an entry in the database from the cloud (which I can verify from the db admin) but still pull old data to my client for an extended period.


Any idea what's going on here?
User avatar
rapidfirestudio
 
Posts: 11
Joined: Fri Jul 06, 2012 5:01 am

Re: Cloud service not updating?

Postby rob » Tue Jul 24, 2012 9:52 pm

Within Moai Cloud our database is deployed as a replica set. By default writes are sent to the primary, but reads can go to either the primary or the secondary. If new data was written to the primary but not yet replicated then the read from the slave will not see it. You can change the default either by calling get_last_error to force a flush of data (I think the luamongo driver may need to be updated for that) or by passing 0 into the options parameter when you issue a query. That will disable reads from the slave.

I haven't heard of an issue loading code before. If you can send more details on that I can look into it. We always load user code from the primary so replication delay would not affect that. We have deployed a code cache to a single server for tests, but the cache should be invalidated whenever new code is updated.
rob
 
Posts: 116
Joined: Wed Sep 21, 2011 2:34 pm

Re: Cloud service not updating?

Postby rapidfirestudio » Wed Jul 25, 2012 12:51 am

I just checked the luamongo docs and I don't see how to pass options with a query. The mongo docs say I can pass something like {'slaveOk':0} with a query, though that's for find() and not query() -- assuming one's not a simple alias for the other, as it doesn't appear to be. But it also says that slaveOk is disabled by default.

Assuming that's what you're doing, is there any reason slaveOk is enabled by default? I read some of the rationale for doing so but it seems like eventual consistency is not what most people would want/expect for most uses.

Can you please provide a working example of how to force a primary read?

I can't replicate the code loading issue to understand it better. I'm using a custom loader that I wrote and it doesn't parse the response for error messages (not sure you send any anyway). It may just be failing periodically. I did see that you're using git for deploys now -- I'll probably switch to that at some point.
User avatar
rapidfirestudio
 
Posts: 11
Joined: Fri Jul 06, 2012 5:01 am

Re: Cloud service not updating?

Postby rob » Wed Jul 25, 2012 9:00 am

The mongo query method is defined like this:

Code: Select all
  1. function mongodb:query(query, limit, skip, return_fields, options, batch_size)



To disable reads from a slave you would issue a call like this

Code: Select all
  1. mongo:query({_id=x}, nil, nil, nil, 0, nil)



You probably could create a wrapper to make the interface cleaner so you could have the default query and a master_query.
rob
 
Posts: 116
Joined: Wed Sep 21, 2011 2:34 pm

Re: Cloud service not updating?

Postby rapidfirestudio » Wed Jul 25, 2012 8:11 pm

Great. Thank you.
User avatar
rapidfirestudio
 
Posts: 11
Joined: Fri Jul 06, 2012 5:01 am


Return to Moai Cloud

Who is online

Users browsing this forum: No registered users and 0 guests

x