I have been experimenting with the old fashioned server deployment in production where I have 3 instances of Trytond server running behind a Nginx proxy doing load balance. Having this setup running for a while, I noticed some strange behaviors, almost “race-condition” like in SAO. I don’t know if this is a bug or a limitation, hence I am commenting this over here.
The strange behavior happens as follows:
1- I have two companies created in the same DB.
2- While working on company A, I switch to the company B by opening the preference dialog box and changing the “current company” to B.
3- Upon clicking on the button “Save”, the interface should refresh and change the company label from A to B, but A is displayed. However, internally all information displayed from the modules: sales, accounts, stock, etc are from company B (just as expected). It is like it the label and the internal company switching are not in sync.
However this behavior does not occur for either of the following conditions:
a- A login dialog is requested, i.e. a password must be entered to switch to company B
b- Multiple Trytond server is disabled ( i.e. only one instance is running ) or use a load balancer that uses ip_hash to ensure a particular client is always handled by the same server instance.
From my humble opinion, I think the problem may be a limitation or a race-condition between Trytond server instances, where the XHR happen faster than the server instances could stay in sync. In other words, when the first XHR res.user.set_preferences call is handled by server instance X to set the current company from A to B has not finished storing the newly selected company into the DB, the browser has issued another XHR res.user.get_preferences call to server instance Y (due to the load balancer) and it returns a cached or “not-yet-updated” current company A value from DB.
I would like to know if anyone has experienced this problem before? And more important how to solve this problem?