Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.

Bug 457646

Summary: [client] two POST requests to create workspaces for a new user
Product: [ECD] Orion Reporter: Anthony Hunter <ahunter.eclipse>
Component: ClientAssignee: Silenio Quarti <Silenio_Quarti>
Status: RESOLVED FIXED QA Contact:
Severity: normal    
Priority: P3 CC: Silenio_Quarti
Version: unspecified   
Target Milestone: 9.0   
Hardware: PC   
OS: Linux   
Whiteboard:

Description Anthony Hunter CLA 2015-01-15 17:18:23 EST
It is currently the Orion clients responsibility to submit a create workspace request when creating a new account. There are multiple calls being made to the workspace servlet sometimes resulting in a second POST call to create a workspace in the case of a new user account. (i.e. the navigator, the project, etc, each query the workspace to get a list of projects.)

There is protection code on the server to prevent a second workspace from being created and a message is logged as:

INFO  org.eclipse.orion.server.config - SimpleMetaStore.createWorkspace: workspace conflict: cannot create a second workspace for user id: sheldon, existing workspace is being used: sheldon-OrionContent

Since the log message is annoying we need to debug where the problem on the client side is.
Comment 1 Anthony Hunter CLA 2015-01-15 17:21:34 EST
The following commit will resolve the issue:
http://git.eclipse.org/c/orion/org.eclipse.orion.client.git/commit/?id=35a7d3f239f4c776f2e36c99dd574a33cc82a948
Comment 2 Anthony Hunter CLA 2015-01-21 14:34:28 EST
(In reply to Anthony Hunter from comment #1)
> The following commit will resolve the issue:
> http://git.eclipse.org/c/orion/org.eclipse.orion.client.git/commit/
> ?id=35a7d3f239f4c776f2e36c99dd574a33cc82a948

This change causes a UI issue so I have undone this commit for now.
Comment 3 Anthony Hunter CLA 2015-01-21 14:43:57 EST
(In reply to Anthony Hunter from comment #0)
> It is currently the Orion clients responsibility to submit a create
> workspace request when creating a new account. There are multiple calls
> being made to the workspace servlet sometimes resulting in a second POST
> call to create a workspace in the case of a new user account. (i.e. the
> navigator, the project, etc, each query the workspace to get a list of
> projects.)
> 
> There is protection code on the server to prevent a second workspace from
> being created and a message is logged as:
> 
> INFO  org.eclipse.orion.server.config - SimpleMetaStore.createWorkspace:
> workspace conflict: cannot create a second workspace for user id: sheldon,
> existing workspace is being used: sheldon-OrionContent
> 
> Since the log message is annoying we need to debug where the problem on the
> client side is.

The underlying problem is that there are two deferred requests on the client to this.fileClient.loadWorkspace() . In the case of the new user, the workspace does not exist so two POST requests are being made on the server.

This is because both the left and right panels call the workspace API. We need to fix so that one of the panels calls the workspace API first, or be smart and have both panels share the results of one request.
Comment 4 John Arthorne CLA 2015-02-27 14:56:50 EST
Moving all open bugs with 8.0 target to next release. Please update or close if this is not correct.
Comment 5 Anthony Hunter CLA 2015-03-05 17:00:20 EST
(In reply to Anthony Hunter from comment #3)
> The underlying problem is that there are two deferred requests on the client
> to this.fileClient.loadWorkspace() . In the case of the new user, the
> workspace does not exist so two POST requests are being made on the server.
> 
> This is because both the left and right panels call the workspace API. We
> need to fix so that one of the panels calls the workspace API first, or be
> smart and have both panels share the results of one request.

My notes for trying to fix this issue on the client.

Silenio suggested adding a fileClient.loadWorkspace() call to setup.js, exactly like git-repository.js is doing. Then the workspace result in setup.js need to be passed into the various sections in the page, rather than each section calling /workspace on their own.

the inputManager.js setInput being called with no location calls _setNoInput with loadRoot == true which calls loadWorkspace() . This code should be removed.

The explorer-table.js loadResourceList with force = true also calls loadWorkspace /file

Once we have the workspace in setup.js, these can be fed into inputManager.js and explorer-table.js.

This code gets a little messy since setup.js also has has some code to check fix the hash to lastEditedFile. Silenio did mention that this code needs to be fixed due to the "flickering' issue during page loads of the editor.
Comment 6 Anthony Hunter CLA 2015-03-05 19:34:39 EST
snippet from setup.js

var workspaceLocation;
function loadWorkspace() {
	return progressService.progress(fileClient.loadWorkspace("/file"), messages["Loading default workspace"]); //$NON-NLS-0$
}
	
loadWorkspace().then(function(workspace){
	workspaceLocation = workspace.Location;
});
Comment 7 Anthony Hunter CLA 2015-03-16 14:39:38 EDT
Silenio
Comment 8 Anthony Hunter CLA 2015-03-16 14:45:58 EDT
Silenio has made some changes to the client to make this issue better.

However on my local war based test server, the latency is still such that the two GET /workspace calls still result in them both thinking there is no workspace, and two POST are still sent.

Since the two POST requests are further apart, the second one now gets the error: 

2015-03-16 14:36:02.759 [http-nio-8080-exec-6] INFO  org.eclipse.orion.server.config - SimpleMetaStore.createWorkspace: workspace conflict: while creating a workspace for user id: ahunter, found existing workspace json, will not overwrite: /ibm/apache-tomcat-8.0.12/serverworkspace/ah/ahunter/ahunter-OrionContent.json


A further more concerning issue is that the normal login path now results in three requests to:
GET /code/workspace
GET /code/workspace/ahunter-OrionContent

I was sure before we only had two requests.

We need to reduce this to one request and share the metadata. If you have many projects in your workspace the over head of doing the same request three times is bad.
Comment 9 Anthony Hunter CLA 2015-03-18 11:22:39 EDT
Looks like Silenio may have this resolved with commit:
http://git.eclipse.org/c/orion/org.eclipse.orion.client.git/commit/?id=067257f94b49d4b8dc2f41cda4afe92ed131b816

I am not getting the extra POST on user creation:

2015-03-18 11:11:51.508 [http-nio-8080-exec-9] DEBUG o.e.o.server.servlets.OrionServlet - GET /code/workspace
2015-03-18 11:11:51.519 [http-nio-8080-exec-7] DEBUG o.e.o.server.servlets.OrionServlet - POST /code/workspace
2015-03-18 11:11:51.579 [http-nio-8080-exec-10] DEBUG o.e.o.server.servlets.OrionServlet - GET /code/workspace
2015-03-18 11:11:51.590 [http-nio-8080-exec-6] DEBUG o.e.o.server.servlets.OrionServlet - GET /code/workspace/ahunter-OrionContent
2015-03-18 11:11:51.611 [http-nio-8080-exec-2] DEBUG o.e.o.server.servlets.OrionServlet - GET /code/workspace
2015-03-18 11:11:51.619 [http-nio-8080-exec-4] DEBUG o.e.o.server.servlets.OrionServlet - GET /code/workspace/ahunter-OrionContent
Comment 10 Anthony Hunter CLA 2015-03-18 12:05:02 EDT
I thought this may be fixed but I hit the error again in comment 8.
Comment 11 Anthony Hunter CLA 2015-03-19 11:16:11 EDT
I only see one POST request with the latest client.