ArangoDb: Time from save() to availability through AQL - waitForSync? - arangodb

In my NodeJS backed REST API, using the ArangoJS library, I'm calling the await save(...) on a document in a collection. Note I'm not using using the waitForSync option.
Right after the await on the save, I'll send a SSE event to the client, which then immediately calls another REST API method, which uses AQL to query the very same collection. Unfortunately I get the previous (old/unchanged) data back. Waiting a sec then AQL-querying gives me the fresh data though.
Is waitForSync the solution? Most documentation states that this option waits for data to sync to the disk, but as I understand ArangoDB keep most data in memory, so it shouldn't affect the following query, which should query against memory?
Anyone care to explain?
Update
see my own answer

Just to mark this as answered:
As expected, there is nothing wrong with ArangoDb. Thanks to the comment/confirmation that await should be enough, I investigated further around my setup. Found that the problem was with caching, and adding a Cache-Control header with 'no-cache' resolved the issue.
Funny thing is that when developer console was open in Chrome, I never had problems. Found that the checkbox 'disable cache' in development mode had hidden the issue during development. Issue being a lot of 304 Not Changed responses.

Related

Incomplete retrieving just after loading documents in CouchDB

I access CouchDB (3.3.2 on Windows) from a Node application (written in typescript) through the application API.
It works perfectly when I load the db in batch and then, after some time, I search and retrieve the documents.
But for testing I create two documents in db through the application API, then try to retrieve them. Sometimes they are returned, sometimes only the first or second one are retrieved.
I tried to put a delay between creation and retrieval, but seems it does not help (or maybe I have waited too little). Or maybe the indices are not updated yet for the search and retrieval, or I don't know.
Is there any way to wait till or to known when the creation finished? It is needed only for testing.
Thanks in advance!
mario

Syncing Problems with Xamarin Forms and Azure Easy Tables

I've been working on a Xamarin.Forms application in Visual Studio using Azure for the backend for a while now, and I've come across a really strange issue.
Please note, that I am following the methods mentioned in this blog
For some strange reason the PullAsync() method seems to have some bizarre problems. Any data that I create and sync will only be pulled by PullAsync() from that solution. What I mean by that is that if I create another solution that accesses the exact same backend, it can perform it's own create/sync data, but will not bring over the data generated by the other solution, even though they both seem to have the exact same access. This appears to be some kind of a security feature/issue, but I can't quite make sense of it.
Has anyone else encountered this at all? Was there a work-around at all? This could potentially cause problems down the road if I were to ever want to create another solution that accesses the same system/data for whatever reason.
For some strange reason the PullAsync() method seems to have some bizarre problems. Any data that I create and sync will only be pulled by PullAsync() from that solution.
According to your provided tutorial, I found that the related PullAsync is using Incremental Sync.
await coffeeTable.PullAsync("allCoffees", coffeeTable.CreateQuery());
Incremental Sync:
the first parameter to the pull operation is a query name that is used only on the client. If you use a non-null query name, the Azure Mobile SDK performs an incremental sync. Each time a pull operation returns a set of results, the latest updatedAt timestamp from that result set is stored in the SDK local system tables. Subsequent pull operations retrieve only records after that timestamp.
Here is my test, you could refer to it for a better understanding of Incremental Sync:
Client : await todoTable.PullAsync("todoItems-02", todoTable.CreateQuery());
The client SDK would check if there has a record with the id equals deltaToken|{table-name}|{query-id} from the __config table of your SQLite local store.
If there has no record, then the SDK would send a request as following for pulling your records:
https://{your-mobileapp-name}.azurewebsites.net/tables/TodoItem?$filter=(updatedAt%20ge%20datetimeoffset'1970-01-01T00%3A00%3A00.0000000%2B00%3A00')&$orderby=updatedAt&$skip=0&$top=50&__includeDeleted=true
Note: the $filter would be set as (updatedAt ge datetimeoffset'1970-01-01T00:00:00.0000000+00:00')
While there has a record, then the SDK would pick up the value as the latest updatedAt timestamp and send the request as follows:
https://{your-mobileapp-name}.azurewebsites.net/tables/TodoItem?$filter=(updatedAt%20ge%20datetimeoffset'2017-06-26T02%3A44%3A25.3940000%2B00%3A00')&$orderby=updatedAt&$skip=0&$top=50&__includeDeleted=true
Per my understanding, if you handle the same logical query with the same query id (non-null) in different mobile client, you need to make sure the local db is newly created by each client. Also, if you want to opt out of incremental sync, pass null as the query ID. In this case, all records are retrieved on every call to PullAsync, which is potentially inefficient. For more details, you could refer to How offline synchronization works.
Additionally, you could leverage fiddler for capturing the network traces when you invoke the PullAsync, in order to troubleshoot your issue.

GET request sent to REST API only first time in IE10

I've recently started using Restangular for making cross domain requests to a RESTful service, and so far everything works great.
But with IE10 when a make a GET request only for the first time it gets data from the Server, and for subsequent calls it does not hit the server, and returns probably cached data. I need to get the data refreshed from the Server. I tried setting defaultHttpFields cache to false, but no luck. Please help!
Thanks,
Lakshmi
I'm the creator of Restangular.
Could you please post an example? If you didn't set the cache to true in defaultHttpfields, Restangular shouldn't cache this at all.
Have you chcked if the requests are going out in the Network tab of the developers console? Does it work in other browsers? Check in restangular Library for RestangularResource to see if it's doing $http call.
Hope it helps!
I just hit this one too. Seems that IE10 is particularly keen on caching results from RESTful calls.
One workaround I used was to just provide some unique value as a parameter to each request and then IE10 seems happy not to cache it. I used the current timestamp in ms since I've seen jQuery use similar workarounds in the past.
var postsApi = Restangular.all("posts");
$scope.allPosts = postsApi.getList({ nocache : new Date().getTime() });
Works for now.

Is there a way to run custom code on Azure Cache expiration? (where last cached value is accessible)

What I mean is a kind of event or callback which is called when some cached value is expiring. Supposedly this callback should be given the currenlty cached value, for example, to store it somewhere else apart from caching.
To find such a way, I have reviewed Notifications option, but they look like they are applicable for explicit actions with cache like adding or removing, whereas expiration is a kind of thing that occurs implicitly. I found out that none of these callbacks is not called many minutes after cache value has expired and has become null, while it is called normally within polling interval if I call DataCache.Remove explicitly (wrong, see update below).
I find this behavior strange as ASP.Net has such callback. You can even find an explanation how to utilize it here on SO.
Also, I tried DataCache Events. It is writtent in MSDN that literally
This API supports the .NET Framework infrastructure and is not intended to be used directly from your code.
Nevertheless I created a handler for these event to see if I can test its args like CacheOperationStartedEventArgs.OperationType == CacheOperationType.ClearCache but it seemed to be in vain.
At the moment, I started to think about workarounds of this issue of the lack of required callback. So suggestions how to implement them are welcome too.
UPDATE. After more attentive and patient testing I found out that notification with DataCacheOperations.ReplaceItem is sent after expiration. Regrettably, I did not find the way to get the value that was cached before the expiration had occurred.

Domino Data Access response hangs for PATCH

I am using the Domino Data Access (via RESTClient) to update docs in a database. I'm using PATCH and PUT. In both cases (PATCH is a header override) I don't get a response back from the Domino server. RESTClient gives me a "processing data" and that's it. If I abort, I can see the replace or update has been done. So DDA is working, except I'm not getting a 200 or other response back. Default and Anonymous can create/edit (database is still in testing), and I've tried with and without the form and computewithform parameters. I'm not seeing anything in the server log.
Could someone give me a pointer of where to look? It seems that something is keeping the complete acknowledgment from being sent, but I don't know what that would be. Other testing, for GET, respond fine.
Thanks,
Brian
urns out this was a problem with RESTClient, not DDA/DDS. Thanks to Fotios Hatzis who figured it out. I tried with a Chrome extension, and the response displays as exected. –

Resources