cloudstack-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Alena Prokharchyk <>
Subject Re: EntityExistsException on management server startup (createDefaultNetworks)
Date Fri, 02 Nov 2012 17:29:08 GMT

This code - default network creation - is initiated only when the Global
config value "init" is false, as a part of persisting the default
cloudStack values. Init is false at the very first management server
startup, and it's reset to true after the default values are persisted.

Looks like in  your setup init process was interrupted in the middle of
the execution, so init was never reset to true, but some default values
were persisted and we never rolled them back. There are 2 bugs to be fixed
in this area:

1) ConfigurationServerImpl, persistDefaultValues method

Wrap all the DB updates in "if (init == null || init.equals("false")) {}"
in the single transaction. So we don't up with partially updated DB.

2) We should remove call to createDefaultNetworks from
persistDefaultValues(). This call was added long ago to support the
scenario when:

* developer manually inserts zone entry to the cloud.data_center table
before the very first management server startup. We used to have the dev
helper script that read data center and other config info from
server-setup.xml file, and did DB update.
* so when the management server starts up initially, the code finds the
zone, and creates the default networks for it.

As cloudStack customers and most of the cloudStack developers create the
zone using API after the management server startup (and not by using
manual db update prior to startup), the call to "createDefaultNetworks"
should become obsolete.

To fix it on your setup, you can either re-deploy the DB - safer solution
as we don't know which default values were persisted, and what was
dropped; or set init=true and restart management server. Also if you
re-deploy the DB, check if you see any exceptions in the log while
cloudStack persisting the default values (the log snippet should begin
with "ConfigurationServer is saving default values to the database")


On 11/2/12 1:26 AM, "Dave Cahill" <> wrote:

>Over the past few days, I've run into EntityExistsException several times
>when I shut down and restart my management server:
>ERROR [cloud.servlet.CloudStartupServlet] (main:) Exception starting
>management server
>javax.persistence.EntityExistsException: Entity already exists:
>This generally requires a drop database, redeploy etc - very time
>I dug into the error a little, and the code behavior seems a little
>line 1085:
>long id = 1;
>And line 1141:
>_networkDao.persist(network, false,
>The code is trying to insert rows into the networks table, with "id"s
>starting at 1. However, the existing values in the networks table also
>start at 1, giving a primary key exception and causing the management
>server not to start successfully.
>Is the networks table supposed to always be empty at startup so that these
>inserts will always succeed even though they are setting id to 1 blindly?
>Or is the code wrong to be starting IDs at 1 and failing on duplicate key
>*Info on my setup:*
>Running CloudStack from master (4.1.0-SNAPSHOT).
>Setup process for the management server was:
>Grab latest from git repo, then:
>mvn install
>mvn -P developer -pl developer -Ddeploydb
>export MAVEN_OPTS="-Xmx1024m -Xdebug
>mvn -pl :cloud-client-ui jetty:run

View raw message