Ask Your Question

what's the role of slave_connection in neutron.conf

asked 2014-01-07 06:13:11 -0500

leileiz gravatar image

In neutron.conf, for section [database], there's two connection as below: ===================[database]================================ [database]

This line MUST be changed to actually run the plugin.


connection = mysql://root:pass@

Replace above with the IP address of the database used by the

main neutron server. (Leave it as is if the database runs on this host.)

connection = sqlite://

The SQLAlchemy connection string used to connect to the slave database

# slave_connection =

What's the role of slave_connection ?

edit retag flag offensive close merge delete

4 answers

Sort by ยป oldest newest most voted

answered 2014-01-08 03:29:37 -0500

aji-zqfan gravatar image

you can read this wiki to get a general knowledge: (

the sql connection/slave_connection config opt is used by oslo sqlalchemy session module[0], not neutron directly, for now, I didn't find code in neutron using slave db feature. (If I'm wrong, please let me know, thanks)

some code may use slave db to reduce the master's load, for i.e. nova periodic task[1][2], they are read operations and can accept a little lag, but operator should ensure the lag is not too high.

[0] ( [1] ( (#631, for i.e.) [2] (

edit flag offensive delete link more

answered 2014-01-08 05:05:28 -0500

leileiz gravatar image

I don't see any neutron function using slave. But in neutron, there's method for get_session in (

That's why I got confused here.

From your reference[0], other projects should get session from oslo get_session(), right? I looked at cinder,nova and neutron, all of them define and consume their own get_session function instead of oslo's. This is potential code refactor work here?

Thanks for explanation!

edit flag offensive delete link more

answered 2014-01-09 02:37:32 -0500

aji-zqfan gravatar image

oslo is a common code project (and it is a bit strict to sync upstream code from oslo to each project.), the link you provided in neutron is exactly oslo code. you can read for more detail.

some projects will define their own get_session, but just a simple wrapper to oslo's get_session, or maybe some special case cannot be met in specific low level driver so particular code should handle that. usually, openstack projects use oslo get_session directly, for i.e., nova, keystone, cinder, glance.

Neutron has written a simple helper function get_session, which just changes the default value of parameter sqlite_fk(which means SqliteForeignKeys) in oslo get_session, you can dig deeper to figure out why it does that, and I think this is another question.

-------------------details can be ignored--------------------- zqfan@openstack-dev:~/openstack/nova/nova$ grep -n 'def get_session' ./ -r ./openstack/common/db/sqlalchemy/ get_session(autocommit=True, expire_on_commit=False, ./tests/virt/xenapi/ get_session(): ./virt/hyperv/ def get_session_id_from_mounted_disk(self, physical_drive_path): ./virt/baremetal/db/sqlalchemy/ get_session(autocommit=True, expire_on_commit=False): ./virt/xenapi/client/ def get_session_id(self):

zqfan@openstack-dev:~/openstack/cinder/cinder$ grep -n 'def get_session' ./ -r ./openstack/common/db/sqlalchemy/ get_session(autocommit=True, expire_on_commit=False, ./volume/drivers/xenapi/ def get_session(self):

zqfan@openstack-dev:~/openstack/neutron/neutron$ grep -n 'def get_session' ./ -r./openstack/common/db/sqlalchemy/ get_session(autocommit=True, expire_on_commit=False, ./db/ get_session(autocommit=True, expire_on_commit=False):

edit flag offensive delete link more

answered 2014-01-09 02:59:14 -0500

leileiz gravatar image

Thanks ZhiQiang Fan, that solved my question.

edit flag offensive delete link more

Get to know Ask OpenStack

Resources for moderators

Question Tools

1 follower


Asked: 2014-01-07 06:13:11 -0500

Seen: 270 times

Last updated: Jan 09 '14