nova launch an instance failed ,error about libvirt - libvirt

I use virsh (version 1.2.12) to create 1 controller node(hostname:HCP2-CTL-NODE-1),3 compute node(HCP2-CPT-NODE-1,2,3),the OS of these nodes is Centos7.
Then I follow Openstack Newton Installation Doc for Red Hat Enterprise Linux 7 and CentOS 7 to deploy openstack on these 4 nodes.
However,when I want to launch an instance as the doc above show,it always return error state with the command
openstack server show provider-instance0' return fault'Build of instance 3fcd26fb-da04-412b-9970-65901354292b aborted: Connection to the hypervisor is broken on host: HCP2-CPT-NODE-2'
Then I read the log
/var/log/nova/nova-compute.log' on the host HCP2-CPT-NODE-2,
as followed:
<pre>
2017-07-25 10:38:30.650 1010 INFO nova.compute.claims [req-37c22c56-598b-46f1-9e48-621b4c05fa23 57b1e00d821a450f8147033b4cf91544 c7ee1b57d11f4b5ca173381dbfa6fb90 - - -] [instance: 8d48b549-bd08-4e1f-8905-77e427036436] Attempting claim: memory 64 MB, disk 1 GB, vcpus 1 CPU
2017-07-25 10:38:30.651 1010 INFO nova.compute.claims [req-37c22c56-598b-46f1-9e48-621b4c05fa23 57b1e00d821a450f8147033b4cf91544 c7ee1b57d11f4b5ca173381dbfa6fb90 - - -] [instance: 8d48b549-bd08-4e1f-8905-77e427036436] Total memory: 8191 MB, used: 512.00 MB
2017-07-25 10:38:30.651 1010 INFO nova.compute.claims [req-37c22c56-598b-46f1-9e48-621b4c05fa23 57b1e00d821a450f8147033b4cf91544 c7ee1b57d11f4b5ca173381dbfa6fb90 - - -] [instance: 8d48b549-bd08-4e1f-8905-77e427036436] memory limit: 12286.50 MB, free: 11774.50 MB
2017-07-25 10:38:30.652 1010 INFO nova.compute.claims [req-37c22c56-598b-46f1-9e48-621b4c05fa23 57b1e00d821a450f8147033b4cf91544 c7ee1b57d11f4b5ca173381dbfa6fb90 - - -] [instance: 8d48b549-bd08-4e1f-8905-77e427036436] Total disk: 191 GB, used: 0.00 GB
2017-07-25 10:38:30.652 1010 INFO nova.compute.claims [req-37c22c56-598b-46f1-9e48-621b4c05fa23 57b1e00d821a450f8147033b4cf91544 c7ee1b57d11f4b5ca173381dbfa6fb90 - - -] [instance: 8d48b549-bd08-4e1f-8905-77e427036436] disk limit: 191.00 GB, free: 191.00 GB
2017-07-25 10:38:30.653 1010 INFO nova.compute.claims [req-37c22c56-598b-46f1-9e48-621b4c05fa23 57b1e00d821a450f8147033b4cf91544 c7ee1b57d11f4b5ca173381dbfa6fb90 - - -] [instance: 8d48b549-bd08-4e1f-8905-77e427036436] Total vcpu: 4 VCPU, used: 0.00 VCPU
2017-07-25 10:38:30.653 1010 INFO nova.compute.claims [req-37c22c56-598b-46f1-9e48-621b4c05fa23 57b1e00d821a450f8147033b4cf91544 c7ee1b57d11f4b5ca173381dbfa6fb90 - - -] [instance: 8d48b549-bd08-4e1f-8905-77e427036436] vcpu limit not specified, defaulting to unlimited
2017-07-25 10:38:30.655 1010 INFO nova.compute.claims [req-37c22c56-598b-46f1-9e48-621b4c05fa23 57b1e00d821a450f8147033b4cf91544 c7ee1b57d11f4b5ca173381dbfa6fb90 - - -] [instance: 8d48b549-bd08-4e1f-8905-77e427036436] Claim successful
2017-07-25 10:38:30.980 1010 WARNING nova.scheduler.client.report [req-37c22c56-598b-46f1-9e48-621b4c05fa23 57b1e00d821a450f8147033b4cf91544 c7ee1b57d11f4b5ca173381dbfa6fb90 - - -] Unable to refresh my resource provider record
2017-07-25 10:38:32.088 1010 INFO nova.network.neutronv2.api [req-37c22c56-598b-46f1-9e48-621b4c05fa23 57b1e00d821a450f8147033b4cf91544 c7ee1b57d11f4b5ca173381dbfa6fb90 - - -] [instance: 8d48b549-bd08-4e1f-8905-77e427036436] Updating port 04aa7f73-eeb8-49b5-a8aa-f90a50ad4715 with attributes {'binding:host_id': u'HCP2-CPT-NODE-1'}
2017-07-25 10:38:33.506 1010 WARNING nova.virt.osinfo [req-37c22c56-598b-46f1-9e48-621b4c05fa23 57b1e00d821a450f8147033b4cf91544 c7ee1b57d11f4b5ca173381dbfa6fb90 - - -] Cannot find OS information - Reason: (No configuration information found for operating system Empty)
2017-07-25 10:38:33.928 1010 WARNING nova.virt.osinfo [req-37c22c56-598b-46f1-9e48-621b4c05fa23 57b1e00d821a450f8147033b4cf91544 c7ee1b57d11f4b5ca173381dbfa6fb90 - - -] Cannot find OS information - Reason: (No configuration information found for operating system Empty)
2017-07-25 10:38:33.930 1010 INFO nova.virt.libvirt.driver [req-37c22c56-598b-46f1-9e48-621b4c05fa23 57b1e00d821a450f8147033b4cf91544 c7ee1b57d11f4b5ca173381dbfa6fb90 - - -] [instance: 8d48b549-bd08-4e1f-8905-77e427036436] Creating image
2017-07-25 10:38:37.227 1010 WARNING nova.virt.osinfo [req-37c22c56-598b-46f1-9e48-621b4c05fa23 57b1e00d821a450f8147033b4cf91544 c7ee1b57d11f4b5ca173381dbfa6fb90 - - -] Cannot find OS information - Reason: (No configuration information found for operating system Empty)
2017-07-25 10:38:37.238 1010 INFO os_vif [req-37c22c56-598b-46f1-9e48-621b4c05fa23 57b1e00d821a450f8147033b4cf91544 c7ee1b57d11f4b5ca173381dbfa6fb90 - - -] Successfully plugged vif VIFBridge(active=False,address=fa:16:3e:fa:22:ed,bridge_name='brq0ca57d3a-50',has_traffic_filtering=True,id=04aa7f73-eeb8-49b5-a8aa-f90a50ad4715,network=Network(0ca57d3a-50a6-446a-ab58-35aecbda0854),plugin='linux_bridge',port_profile=<?>,preserve_on_delete=False,vif_name='tap04aa7f73-ee')
2017-07-25 10:38:37.718 1010 INFO nova.virt.libvirt.driver [req-28838e00-d4b5-4378-ad64-7a31156d3ce6 - - - - -] Connection event '0' reason 'Connection to libvirt lost: 0'
2017-07-25 10:38:37.723 1010 ERROR root [req-37c22c56-598b-46f1-9e48-621b4c05fa23 57b1e00d821a450f8147033b4cf91544 c7ee1b57d11f4b5ca173381dbfa6fb90 - - -] Original exception being dropped: ['Traceback (most recent call last):\n', ' File "/usr/lib/python2.7/site-packages/nova/virt/libvirt/guest.py", line 139, in launch\n return self._domain.createWithFlags(flags)\n', ' File "/usr/lib/python2.7/site-packages/eventlet/tpool.py", line 186, in doit\n result = proxy_call(self._autowrap, f, *args, **kwargs)\n', ' File "/usr/lib/python2.7/site-packages/eventlet/tpool.py", line 144, in proxy_call\n rv = execute(f, *args, **kwargs)\n', ' File "/usr/lib/python2.7/site-packages/eventlet/tpool.py", line 125, in execute\n six.reraise(c, e, tb)\n', ' File "/usr/lib/python2.7/site-packages/eventlet/tpool.py", line 83, in tworker\n rv = meth(*args, **kwargs)\n', ' File "/usr/lib64/python2.7/site-packages/libvirt.py", line 1065, in createWithFlags\n if ret == -1: raise libvirtError (\'virDomainCreateWithFlags() failed\', dom=self)\n', 'libvirtError: End of file while reading data: Input/output error\n']
2017-07-25 10:38:37.724 1010 ERROR nova.virt.libvirt.driver [req-37c22c56-598b-46f1-9e48-621b4c05fa23 57b1e00d821a450f8147033b4cf91544 c7ee1b57d11f4b5ca173381dbfa6fb90 - - -] [instance: 8d48b549-bd08-4e1f-8905-77e427036436] Failed to start libvirt guest
2017-07-25 10:38:37.725 1010 INFO os_vif [req-37c22c56-598b-46f1-9e48-621b4c05fa23 57b1e00d821a450f8147033b4cf91544 c7ee1b57d11f4b5ca173381dbfa6fb90 - - -] Successfully unplugged vif VIFBridge(active=False,address=fa:16:3e:fa:22:ed,bridge_name='brq0ca57d3a-50',has_traffic_filtering=True,id=04aa7f73-eeb8-49b5-a8aa-f90a50ad4715,network=Network(0ca57d3a-50a6-446a-ab58-35aecbda0854),plugin='linux_bridge',port_profile=<?>,preserve_on_delete=False,vif_name='tap04aa7f73-ee')
2017-07-25 10:38:37.772 1010 INFO nova.virt.libvirt.driver [req-37c22c56-598b-46f1-9e48-621b4c05fa23 57b1e00d821a450f8147033b4cf91544 c7ee1b57d11f4b5ca173381dbfa6fb90 - - -] [instance: 8d48b549-bd08-4e1f-8905-77e427036436] Deleting instance files /var/lib/nova/instances/8d48b549-bd08-4e1f-8905-77e427036436_del
2017-07-25 10:38:37.773 1010 INFO nova.virt.libvirt.driver [req-37c22c56-598b-46f1-9e48-621b4c05fa23 57b1e00d821a450f8147033b4cf91544 c7ee1b57d11f4b5ca173381dbfa6fb90 - - -] [instance: 8d48b549-bd08-4e1f-8905-77e427036436] Deletion of /var/lib/nova/instances/8d48b549-bd08-4e1f-8905-77e427036436_del complete
2017-07-25 10:38:37.950 1010 INFO nova.virt.libvirt.driver [req-37c22c56-598b-46f1-9e48-621b4c05fa23 57b1e00d821a450f8147033b4cf91544 c7ee1b57d11f4b5ca173381dbfa6fb90 - - -] Connection event '0' reason 'Failed to connect to libvirt'
2017-07-25 10:38:37.970 1010 ERROR nova.virt.libvirt.host [req-37c22c56-598b-46f1-9e48-621b4c05fa23 57b1e00d821a450f8147033b4cf91544 c7ee1b57d11f4b5ca173381dbfa6fb90 - - -] Connection to libvirt failed: Failed to connect socket to '/var/run/libvirt/libvirt-sock': Connection refused
2017-07-25 10:38:37.970 1010 ERROR nova.virt.libvirt.host Traceback (most recent call last):
2017-07-25 10:38:37.970 1010 ERROR nova.virt.libvirt.host File "/usr/lib/python2.7/site-packages/nova/virt/libvirt/host.py", line 411, in get_connection
2017-07-25 10:38:37.970 1010 ERROR nova.virt.libvirt.host conn = self._get_connection()
2017-07-25 10:38:37.970 1010 ERROR nova.virt.libvirt.host File "/usr/lib/python2.7/site-packages/nova/virt/libvirt/host.py", line 398, in _get_connection
2017-07-25 10:38:37.970 1010 ERROR nova.virt.libvirt.host wrapped_conn = self._get_new_connection()
2017-07-25 10:38:37.970 1010 ERROR nova.virt.libvirt.host File "/usr/lib/python2.7/site-packages/nova/virt/libvirt/host.py", line 350, in _get_new_connection
2017-07-25 10:38:37.970 1010 ERROR nova.virt.libvirt.host wrapped_conn = self._connect(self._uri, self._read_only)
2017-07-25 10:38:37.970 1010 ERROR nova.virt.libvirt.host File "/usr/lib/python2.7/site-packages/nova/virt/libvirt/host.py", line 204, in _connect
2017-07-25 10:38:37.970 1010 ERROR nova.virt.libvirt.host libvirt.openAuth, uri, auth, flags)
2017-07-25 10:38:37.970 1010 ERROR nova.virt.libvirt.host File "/usr/lib/python2.7/site-packages/eventlet/tpool.py", line 144, in proxy_call
2017-07-25 10:38:37.970 1010 ERROR nova.virt.libvirt.host rv = execute(f, *args, **kwargs)
2017-07-25 10:38:37.970 1010 ERROR nova.virt.libvirt.host File "/usr/lib/python2.7/site-packages/eventlet/tpool.py", line 125, in execute
2017-07-25 10:38:37.970 1010 ERROR nova.virt.libvirt.host six.reraise(c, e, tb)
2017-07-25 10:38:37.970 1010 ERROR nova.virt.libvirt.host File "/usr/lib/python2.7/site-packages/eventlet/tpool.py", line 83, in tworker
2017-07-25 10:38:37.970 1010 ERROR nova.virt.libvirt.host rv = meth(*args, **kwargs)
2017-07-25 10:38:37.970 1010 ERROR nova.virt.libvirt.host File "/usr/lib64/python2.7/site-packages/libvirt.py", line 105, in openAuth
2017-07-25 10:38:37.970 1010 ERROR nova.virt.libvirt.host if ret is None:raise libvirtError('virConnectOpenAuth() failed')
2017-07-25 10:38:37.970 1010 ERROR nova.virt.libvirt.host libvirtError: Failed to connect socket to '/var/run/libvirt/libvirt-sock': Connection refused
2017-07-25 10:38:37.970 1010 ERROR nova.virt.libvirt.host
2017-07-25 10:38:37.973 1010 ERROR root [req-37c22c56-598b-46f1-9e48-621b4c05fa23 57b1e00d821a450f8147033b4cf91544 c7ee1b57d11f4b5ca173381dbfa6fb90 - - -] Original exception being dropped: ['Traceback (most recent call last):\n', ' File "/usr/lib/python2.7/site-packages/nova/virt/libvirt/driver.py", line 4899, in _create_domain_and_network\n post_xml_callback=post_xml_callback)\n', ' File "/usr/lib/python2.7/site-packages/nova/virt/libvirt/driver.py", line 4817, in _create_domain\n guest.launch(pause=pause)\n', ' File "/usr/lib/python2.7/site-packages/nova/virt/libvirt/guest.py", line 144, in launch\n self._encoded_xml, errors=\'ignore\')\n', ' File "/usr/lib/python2.7/site-packages/nova/virt/libvirt/guest.py", line 111, in _encoded_xml\n return encodeutils.safe_decode(self._domain.XMLDesc(0))\n', ' File "/usr/lib/python2.7/site-packages/eventlet/tpool.py", line 186, in doit\n result = proxy_call(self._autowrap, f, *args, **kwargs)\n', ' File "/usr/lib/python2.7/site-packages/eventlet/tpool.py", line 144, in proxy_call\n rv = execute(f, *args, **kwargs)\n', ' File "/usr/lib/python2.7/site-packages/eventlet/tpool.py", line 125, in execute\n six.reraise(c, e, tb)\n', ' File "/usr/lib/python2.7/site-packages/eventlet/tpool.py", line 83, in tworker\n rv = meth(*args, **kwargs)\n', ' File "/usr/lib64/python2.7/site-packages/libvirt.py", line 492, in XMLDesc\n if ret is None: raise libvirtError (\'virDomainGetXMLDesc() failed\', dom=self)\n', 'libvirtError: internal error: client socket is closed\n']
2017-07-25 10:38:37.973 1010 ERROR nova.compute.manager [req-37c22c56-598b-46f1-9e48-621b4c05fa23 57b1e00d821a450f8147033b4cf91544 c7ee1b57d11f4b5ca173381dbfa6fb90 - - -] [instance: 8d48b549-bd08-4e1f-8905-77e427036436] Instance failed to spawn
2017-07-25 10:38:37.973 1010 ERROR nova.compute.manager [instance: 8d48b549-bd08-4e1f-8905-77e427036436] Traceback (most recent call last):
2017-07-25 10:38:37.973 1010 ERROR nova.compute.manager [instance: 8d48b549-bd08-4e1f-8905-77e427036436] File "/usr/lib/python2.7/site-packages/nova/compute/manager.py", line 2083, in _build_resources
2017-07-25 10:38:37.973 1010 ERROR nova.compute.manager [instance: 8d48b549-bd08-4e1f-8905-77e427036436] yield resources
2017-07-25 10:38:37.973 1010 ERROR nova.compute.manager [instance: 8d48b549-bd08-4e1f-8905-77e427036436] File "/usr/lib/python2.7/site-packages/nova/compute/manager.py", line 1924, in _build_and_run_instance
2017-07-25 10:38:37.973 1010 ERROR nova.compute.manager [instance: 8d48b549-bd08-4e1f-8905-77e427036436] block_device_info=block_device_info)
2017-07-25 10:38:37.973 1010 ERROR nova.compute.manager [instance: 8d48b549-bd08-4e1f-8905-77e427036436] File "/usr/lib/python2.7/site-packages/nova/virt/libvirt/driver.py", line 2618, in spawn
2017-07-25 10:38:37.973 1010 ERROR nova.compute.manager [instance: 8d48b549-bd08-4e1f-8905-77e427036436] destroy_disks_on_failure=True)
2017-07-25 10:38:37.973 1010 ERROR nova.compute.manager [instance: 8d48b549-bd08-4e1f-8905-77e427036436] File "/usr/lib/python2.7/site-packages/nova/virt/libvirt/driver.py", line 4927, in _create_domain_and_network
2017-07-25 10:38:37.973 1010 ERROR nova.compute.manager [instance: 8d48b549-bd08-4e1f-8905-77e427036436] destroy_disks_on_failure)
2017-07-25 10:38:37.973 1010 ERROR nova.compute.manager [instance: 8d48b549-bd08-4e1f-8905-77e427036436] File "/usr/lib/python2.7/site-packages/nova/virt/libvirt/driver.py", line 4849, in _cleanup_failed_start
2017-07-25 10:38:37.973 1010 ERROR nova.compute.manager [instance: 8d48b549-bd08-4e1f-8905-77e427036436] destroy_disks=destroy_disks)
2017-07-25 10:38:37.973 1010 ERROR nova.compute.manager [instance: 8d48b549-bd08-4e1f-8905-77e427036436] File "/usr/lib/python2.7/site-packages/nova/virt/libvirt/driver.py", line 977, in cleanup
2017-07-25 10:38:37.973 1010 ERROR nova.compute.manager [instance: 8d48b549-bd08-4e1f-8905-77e427036436] self._undefine_domain(instance)
2017-07-25 10:38:37.973 1010 ERROR nova.compute.manager [instance: 8d48b549-bd08-4e1f-8905-77e427036436] File "/usr/lib/python2.7/site-packages/nova/virt/libvirt/driver.py", line 866, in _undefine_domain
2017-07-25 10:38:37.973 1010 ERROR nova.compute.manager [instance: 8d48b549-bd08-4e1f-8905-77e427036436] guest = self._host.get_guest(instance)
2017-07-25 10:38:37.973 1010 ERROR nova.compute.manager [instance: 8d48b549-bd08-4e1f-8905-77e427036436] File "/usr/lib/python2.7/site-packages/nova/virt/libvirt/host.py", line 500, in get_guest
2017-07-25 10:38:37.973 1010 ERROR nova.compute.manager [instance: 8d48b549-bd08-4e1f-8905-77e427036436] self.get_domain(instance))
2017-07-25 10:38:37.973 1010 ERROR nova.compute.manager [instance: 8d48b549-bd08-4e1f-8905-77e427036436] File "/usr/lib/python2.7/site-packages/nova/virt/libvirt/host.py", line 490, in get_domain
2017-07-25 10:38:37.973 1010 ERROR nova.compute.manager [instance: 8d48b549-bd08-4e1f-8905-77e427036436] return self._get_domain_by_name(instance.name)
2017-07-25 10:38:37.973 1010 ERROR nova.compute.manager [instance: 8d48b549-bd08-4e1f-8905-77e427036436] File "/usr/lib/python2.7/site-packages/nova/virt/libvirt/host.py", line 532, in _get_domain_by_name
2017-07-25 10:38:37.973 1010 ERROR nova.compute.manager [instance: 8d48b549-bd08-4e1f-8905-77e427036436] conn = self.get_connection()
2017-07-25 10:38:37.973 1010 ERROR nova.compute.manager [instance: 8d48b549-bd08-4e1f-8905-77e427036436] File "/usr/lib/python2.7/site-packages/nova/virt/libvirt/host.py", line 420, in get_connection
2017-07-25 10:38:37.973 1010 ERROR nova.compute.manager [instance: 8d48b549-bd08-4e1f-8905-77e427036436] raise exception.HypervisorUnavailable(host=CONF.host)
2017-07-25 10:38:37.973 1010 ERROR nova.compute.manager [instance: 8d48b549-bd08-4e1f-8905-77e427036436] HypervisorUnavailable: Connection to the hypervisor is broken on host: HCP2-CPT-NODE-1
2017-07-25 10:38:37.973 1010 ERROR nova.compute.manager [instance: 8d48b549-bd08-4e1f-8905-77e427036436]
2017-07-25 10:38:37.975 1010 INFO nova.compute.manager [req-37c22c56-598b-46f1-9e48-621b4c05fa23 57b1e00d821a450f8147033b4cf91544 c7ee1b57d11f4b5ca173381dbfa6fb90 - - -] [instance: 8d48b549-bd08-4e1f-8905-77e427036436] Terminating instance
2017-07-25 10:38:37.979 1010 INFO nova.virt.libvirt.driver [req-37c22c56-598b-46f1-9e48-621b4c05fa23 57b1e00d821a450f8147033b4cf91544 c7ee1b57d11f4b5ca173381dbfa6fb90 - - -] Connection event '0' reason 'Failed to connect to libvirt'
2017-07-25 10:38:38.000 1010 ERROR nova.virt.libvirt.host [req-37c22c56-598b-46f1-9e48-621b4c05fa23 57b1e00d821a450f8147033b4cf91544 c7ee1b57d11f4b5ca173381dbfa6fb90 - - -] Connection to libvirt failed: Failed to connect socket to '/var/run/libvirt/libvirt-sock': Connection refused
2017-07-25 10:38:38.000 1010 ERROR nova.virt.libvirt.host Traceback (most recent call last):
2017-07-25 10:38:38.000 1010 ERROR nova.virt.libvirt.host File "/usr/lib/python2.7/site-packages/nova/virt/libvirt/host.py", line 411, in get_connection
2017-07-25 10:38:38.000 1010 ERROR nova.virt.libvirt.host conn = self._get_connection()
2017-07-25 10:38:38.000 1010 ERROR nova.virt.libvirt.host File "/usr/lib/python2.7/site-packages/nova/virt/libvirt/host.py", line 398, in _get_connection
2017-07-25 10:38:38.000 1010 ERROR nova.virt.libvirt.host wrapped_conn = self._get_new_connection()
2017-07-25 10:38:38.000 1010 ERROR nova.virt.libvirt.host File "/usr/lib/python2.7/site-packages/nova/virt/libvirt/host.py", line 350, in _get_new_connection
2017-07-25 10:38:38.000 1010 ERROR nova.virt.libvirt.host wrapped_conn = self._connect(self._uri, self._read_only)
2017-07-25 10:38:38.000 1010 ERROR nova.virt.libvirt.host File "/usr/lib/python2.7/site-packages/nova/virt/libvirt/host.py", line 204, in _connect
2017-07-25 10:38:38.000 1010 ERROR nova.virt.libvirt.host libvirt.openAuth, uri, auth, flags)
2017-07-25 10:38:38.000 1010 ERROR nova.virt.libvirt.host File "/usr/lib/python2.7/site-packages/eventlet/tpool.py", line 144, in proxy_call
2017-07-25 10:38:38.000 1010 ERROR nova.virt.libvirt.host rv = execute(f, *args, **kwargs)
2017-07-25 10:38:38.000 1010 ERROR nova.virt.libvirt.host File "/usr/lib/python2.7/site-packages/eventlet/tpool.py", line 125, in execute
2017-07-25 10:38:38.000 1010 ERROR nova.virt.libvirt.host six.reraise(c, e, tb)
2017-07-25 10:38:38.000 1010 ERROR nova.virt.libvirt.host File "/usr/lib/python2.7/site-packages/eventlet/tpool.py", line 83, in tworker
2017-07-25 10:38:38.000 1010 ERROR nova.virt.libvirt.host rv = meth(*args, **kwargs)
2017-07-25 10:38:38.000 1010 ERROR nova.virt.libvirt.host File "/usr/lib64/python2.7/site-packages/libvirt.py", line 105, in openAuth
2017-07-25 10:38:38.000 1010 ERROR nova.virt.libvirt.host if ret is None:raise libvirtError('virConnectOpenAuth() failed')
2017-07-25 10:38:38.000 1010 ERROR nova.virt.libvirt.host libvirtError: Failed to connect socket to '/var/run/libvirt/libvirt-sock': Connection refused
2017-07-25 10:38:38.000 1010 ERROR nova.virt.libvirt.host
2017-07-25 10:38:38.002 1010 WARNING nova.compute.manager [req-37c22c56-598b-46f1-9e48-621b4c05fa23 57b1e00d821a450f8147033b4cf91544 c7ee1b57d11f4b5ca173381dbfa6fb90 - - -] Could not clean up failed build, not rescheduling. Error: Connection to the hypervisor is broken on host: HCP2-CPT-NODE-1
2017-07-25 10:38:38.220 1010 WARNING nova.scheduler.client.report [req-37c22c56-598b-46f1-9e48-621b4c05fa23 57b1e00d821a450f8147033b4cf91544 c7ee1b57d11f4b5ca173381dbfa6fb90 - - -] Unable to refresh my resource provider record
2017-07-25 10:38:38.223 1010 ERROR nova.compute.manager [req-37c22c56-598b-46f1-9e48-621b4c05fa23 57b1e00d821a450f8147033b4cf91544 c7ee1b57d11f4b5ca173381dbfa6fb90 - - -] [instance: 8d48b549-bd08-4e1f-8905-77e427036436] Build of instance 8d48b549-bd08-4e1f-8905-77e427036436 aborted: Connection to the hypervisor is broken on host: HCP2-CPT-NODE-1
2017-07-25 10:38:38.223 1010 ERROR nova.compute.manager [instance: 8d48b549-bd08-4e1f-8905-77e427036436] Traceback (most recent call last):
2017-07-25 10:38:38.223 1010 ERROR nova.compute.manager [instance: 8d48b549-bd08-4e1f-8905-77e427036436] File "/usr/lib/python2.7/site-packages/nova/compute/manager.py", line 1783, in _do_build_and_run_instance
2017-07-25 10:38:38.223 1010 ERROR nova.compute.manager [instance: 8d48b549-bd08-4e1f-8905-77e427036436] filter_properties)
2017-07-25 10:38:38.223 1010 ERROR nova.compute.manager [instance: 8d48b549-bd08-4e1f-8905-77e427036436] File "/usr/lib/python2.7/site-packages/nova/compute/manager.py", line 1943, in _build_and_run_instance
2017-07-25 10:38:38.223 1010 ERROR nova.compute.manager [instance: 8d48b549-bd08-4e1f-8905-77e427036436] 'create.error', fault=e)
2017-07-25 10:38:38.223 1010 ERROR nova.compute.manager [instance: 8d48b549-bd08-4e1f-8905-77e427036436] File "/usr/lib/python2.7/site-packages/oslo_utils/excutils.py", line 220, in __exit__
2017-07-25 10:38:38.223 1010 ERROR nova.compute.manager [instance: 8d48b549-bd08-4e1f-8905-77e427036436] self.force_reraise()
2017-07-25 10:38:38.223 1010 ERROR nova.compute.manager [instance: 8d48b549-bd08-4e1f-8905-77e427036436] File "/usr/lib/python2.7/site-packages/oslo_utils/excutils.py", line 196, in force_reraise
2017-07-25 10:38:38.223 1010 ERROR nova.compute.manager [instance: 8d48b549-bd08-4e1f-8905-77e427036436] six.reraise(self.type_, self.value, self.tb)
2017-07-25 10:38:38.223 1010 ERROR nova.compute.manager [instance: 8d48b549-bd08-4e1f-8905-77e427036436] File "/usr/lib/python2.7/site-packages/nova/compute/manager.py", line 1927, in _build_and_run_instance
2017-07-25 10:38:38.223 1010 ERROR nova.compute.manager [instance: 8d48b549-bd08-4e1f-8905-77e427036436] instance=instance)
2017-07-25 10:38:38.223 1010 ERROR nova.compute.manager [instance: 8d48b549-bd08-4e1f-8905-77e427036436] File "/usr/lib64/python2.7/contextlib.py", line 35, in __exit__
2017-07-25 10:38:38.223 1010 ERROR nova.compute.manager [instance: 8d48b549-bd08-4e1f-8905-77e427036436] self.gen.throw(type, value, traceback)
2017-07-25 10:38:38.223 1010 ERROR nova.compute.manager [instance: 8d48b549-bd08-4e1f-8905-77e427036436] File "/usr/lib/python2.7/site-packages/nova/compute/manager.py", line 2110, in _build_resources
2017-07-25 10:38:38.223 1010 ERROR nova.compute.manager [instance: 8d48b549-bd08-4e1f-8905-77e427036436] reason=six.text_type(exc))
2017-07-25 10:38:38.223 1010 ERROR nova.compute.manager [instance: 8d48b549-bd08-4e1f-8905-77e427036436] BuildAbortException: Build of instance 8d48b549-bd08-4e1f-8905-77e427036436 aborted: Connection to the hypervisor is broken on host: HCP2-CPT-NODE-1
2017-07-25 10:38:38.223 1010 ERROR nova.compute.manager [instance: 8d48b549-bd08-4e1f-8905-77e427036436]
2017-07-25 10:38:39.261 1010 INFO nova.compute.manager [req-37c22c56-598b-46f1-9e48-621b4c05fa23 57b1e00d821a450f8147033b4cf91544 c7ee1b57d11f4b5ca173381dbfa6fb90 - - -] [instance: 8d48b549-bd08-4e1f-8905-77e427036436] Took 1.04 seconds to deallocate network for instance.
2017-07-25 10:39:01.040 1010 INFO nova.virt.libvirt.driver [req-285dc2e1-1716-4b98-b844-ee0ee120b34f - - - - -] Connection event '1' reason 'None'
2017-07-25 10:39:01.133 1010 INFO nova.compute.resource_tracker [req-285dc2e1-1716-4b98-b844-ee0ee120b34f - - - - -] Auditing locally available compute resources for node HCP2-CPT-NODE-1
2017-07-25 10:39:01.355 1010 WARNING nova.scheduler.client.report [req-285dc2e1-1716-4b98-b844-ee0ee120b34f - - - - -] No authentication information found for placement API. Placement is optional in Newton, but required in Ocata. Please enable the placement service before upgrading.
2017-07-25 10:39:01.355 1010 WARNING nova.scheduler.client.report [req-285dc2e1-1716-4b98-b844-ee0ee120b34f - - - - -] Unable to refresh my resource provider record
2017-07-25 10:39:01.625 1010 INFO nova.compute.resource_tracker [req-285dc2e1-1716-4b98-b844-ee0ee120b34f - - - - -] Total usable vcpus: 4, total allocated vcpus: 0
2017-07-25 10:39:01.626 1010 INFO nova.compute.resource_tracker [req-285dc2e1-1716-4b98-b844-ee0ee120b34f - - - - -] Final resource view: name=HCP2-CPT-NODE-1 phys_ram=8191MB used_ram=512MB phys_disk=191GB used_disk=0GB total_vcpus=4 used_vcpus=0 pci_stats=[]
2017-07-25 10:39:01.692 1010 WARNING nova.scheduler.client.report [req-285dc2e1-1716-4b98-b844-ee0ee120b34f - - - - -] Unable to refresh my resource provider record
2017-07-25 10:39:01.692 1010 INFO nova.compute.resource_tracker [req-285dc2e1-1716-4b98-b844-ee0ee120b34f - - - - -] Compute_service record updated for HCP2-CPT-NODE-1:HCP2-CPT-NODE-1
</pre>
In addition,when i print the user groups on 3 compute node,it print:
<pre>
...
kvm:x:36:qemu
qemu:x:107:nova
cgred:x:993:
libvirt:x:992:
rpcuser:x:29:
nfsnobody:x:65534:
nova:x:162:
neutron:x:991:
</pre>
And the command "id nova" print :
<pre>
uid=162(nova) gid=162(nova) groups=162(nova),99(nobody),107(qemu)
</pre>
How to solve the problems? thanks

if you run nova compute in vm, you should change "virt_type = qemu" in nova.conf.

Related

Snowflake sqlalchemy python cant connect because of getaddrinfo failed inside virtual machine of company network

I need to read and write some data to a snowflake databse. I have the credentials and everything is working fine on my local pc. But in the virtual machine of the company I am doing this I get this
I think its a proxy problem but i dont know what to do and how to fix. On the virtual machine i can access the snowflake urls flawlessly and everything works in google chrome for example. but why is this request not working in python??
Why?
How can i fix it?
please help :(
error message `Traceback (most recent call last):
File "snowflake\connector\vendored\urllib3\connection.py", line 174, in _new_conn
File "snowflake\connector\vendored\urllib3\util\connection.py", line 72, in create_connection
File "socket.py", line 954, in getaddrinfo
socket.gaierror: [Errno 11002] getaddrinfo failed
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "snowflake\connector\vendored\urllib3\connectionpool.py", line 703, in urlopen
File "snowflake\connector\vendored\urllib3\connectionpool.py", line 386, in _make_request
File "snowflake\connector\vendored\urllib3\connectionpool.py", line 1042, in _validate_conn
File "snowflake\connector\vendored\urllib3\connection.py", line 358, in connect
File "snowflake\connector\vendored\urllib3\connection.py", line 186, in _new_conn
snowflake.connector.vendored.urllib3.exceptions.NewConnectionError: <snowflake.connector.vendored.urllib3.connection.HTTPSConnection object at 0x000002073B6C6C10>: Failed to establish a new connection: [Errno 11002] getaddrinfo failed
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "snowflake\connector\vendored\requests\adapters.py", line 489, in send
File "snowflake\connector\vendored\urllib3\connectionpool.py", line 815, in urlopen
File "snowflake\connector\vendored\urllib3\connectionpool.py", line 787, in urlopen
File "snowflake\connector\vendored\urllib3\util\retry.py", line 592, in increment
snowflake.connector.vendored.urllib3.exceptions.MaxRetryError: HTTPSConnectionPool(host='kzhwbsi-gb82213.snowflakecomputing.com', port=443): Max retries exceeded with url: /session/v1/login-request?request_id=d395ab35-5f2a-4fb2-a83b-48458979f2c9&databaseName=project_database&schemaName=project_schema&request_guid=19c8e3a5-33ad-48c2-8124-fc69a1fa2af9 (Caused by NewConnectionError('<snowflake.connector.vendored.urllib3.connection.HTTPSConnection object at 0x000002073B6C6C10>: Failed to establish a new connection: [Errno 11002] getaddrinfo failed'))
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "snowflake\connector\network.py", line 1018, in _request_exec
File "snowflake\connector\vendored\requests\sessions.py", line 587, in request
File "snowflake\connector\vendored\requests\sessions.py", line 701, in send
File "snowflake\connector\vendored\requests\adapters.py", line 565, in send
snowflake.connector.vendored.requests.exceptions.ConnectionError: HTTPSConnectionPool(host='kzhwbsi-gb82213.snowflakecomputing.com', port=443): Max retries exceeded with url: /session/v1/login-request?request_id=d395ab35-5f2a-4fb2-a83b-48458979f2c9&databaseName=project_database&schemaName=project_schema&request_guid=19c8e3a5-33ad-48c2-8124-fc69a1fa2af9 (Caused by NewConnectionError('<snowflake.connector.vendored.urllib3.connection.HTTPSConnection object at 0x000002073B6C6C10>: Failed to establish a new connection: [Errno 11002] getaddrinfo failed'))
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "snowflake\connector\connection.py", line 1072, in __authenticate
File "snowflake\connector\auth.py", line 257, in authenticate
File "snowflake\connector\network.py", line 704, in _post_request
File "snowflake\connector\network.py", line 794, in fetch
File "snowflake\connector\network.py", line 917, in _request_exec_wrapper
File "snowflake\connector\network.py", line 837, in _request_exec_wrapper
File "snowflake\connector\network.py", line 1095, in _request_exec
snowflake.connector.errors.OperationalError: 251011: 251011: ConnectionTimeout occurred. Will be handled by authenticator
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "sqlalchemy\engine\base.py", line 3361, in _wrap_pool_connect
File "sqlalchemy\pool\base.py", line 327, in connect
File "sqlalchemy\pool\base.py", line 894, in _checkout
File "sqlalchemy\pool\base.py", line 493, in checkout
File "sqlalchemy\pool\impl.py", line 146, in _do_get
File "sqlalchemy\util\langhelpers.py", line 70, in __exit__
File "sqlalchemy\util\compat.py", line 211, in raise_
File "sqlalchemy\pool\impl.py", line 143, in _do_get
File "sqlalchemy\pool\base.py", line 273, in _create_connection
File "sqlalchemy\pool\base.py", line 388, in __init__
File "sqlalchemy\pool\base.py", line 691, in __connect
File "sqlalchemy\util\langhelpers.py", line 70, in __exit__
File "sqlalchemy\util\compat.py", line 211, in raise_
File "sqlalchemy\pool\base.py", line 686, in __connect
File "sqlalchemy\engine\create.py", line 578, in connect
File "sqlalchemy\engine\default.py", line 598, in connect
File "snowflake\connector\__init__.py", line 51, in Connect
File "snowflake\connector\connection.py", line 297, in __init__
File "snowflake\connector\connection.py", line 550, in connect
File "snowflake\connector\connection.py", line 789, in __open_connection
File "snowflake\connector\connection.py", line 1052, in _authenticate
File "snowflake\connector\connection.py", line 1117, in __authenticate
File "snowflake\connector\connection.py", line 1094, in __authenticate
File "snowflake\connector\auth_by_plugin.py", line 117, in handle_timeout
snowflake.connector.errors.OperationalError: 250001: 250001: Could not connect to Snowflake backend after 0 attempt(s).Aborting
The above exception was the direct cause of the following exception:
Traceback (most recent call last):
File "src\snowflakesqlalchemy.py", line 19, in <module>
File "sqlalchemy\engine\base.py", line 3315, in connect
File "sqlalchemy\engine\base.py", line 96, in __init__
File "sqlalchemy\engine\base.py", line 3394, in raw_connection
File "sqlalchemy\engine\base.py", line 3364, in _wrap_pool_connect
File "sqlalchemy\engine\base.py", line 2198, in _handle_dbapi_exception_noconnection
File "sqlalchemy\util\compat.py", line 211, in raise_
File "sqlalchemy\engine\base.py", line 3361, in _wrap_pool_connect
File "sqlalchemy\pool\base.py", line 327, in connect
File "sqlalchemy\pool\base.py", line 894, in _checkout
File "sqlalchemy\pool\base.py", line 493, in checkout
File "sqlalchemy\pool\impl.py", line 146, in _do_get
File "sqlalchemy\util\langhelpers.py", line 70, in __exit__
File "sqlalchemy\util\compat.py", line 211, in raise_
File "sqlalchemy\pool\impl.py", line 143, in _do_get
File "sqlalchemy\pool\base.py", line 273, in _create_connection
File "sqlalchemy\pool\base.py", line 388, in __init__
File "sqlalchemy\pool\base.py", line 691, in __connect
File "sqlalchemy\util\langhelpers.py", line 70, in __exit__
File "sqlalchemy\util\compat.py", line 211, in raise_
File "sqlalchemy\pool\base.py", line 686, in __connect
File "sqlalchemy\engine\create.py", line 578, in connect
File "sqlalchemy\engine\default.py", line 598, in connect
File "snowflake\connector\__init__.py", line 51, in Connect
File "snowflake\connector\connection.py", line 297, in __init__
File "snowflake\connector\connection.py", line 550, in connect
File "snowflake\connector\connection.py", line 789, in __open_connection
File "snowflake\connector\connection.py", line 1052, in _authenticate
File "snowflake\connector\connection.py", line 1117, in __authenticate
File "snowflake\connector\connection.py", line 1094, in __authenticate
File "snowflake\connector\auth_by_plugin.py", line 117, in handle_timeout
sqlalchemy.exc.OperationalError: (snowflake.connector.errors.OperationalError) 250001: 250001: Could not connect to Snowflake backend after 0 attempt(s).Aborting
(Background on this error at: https://sqlalche.me/e/14/e3q8)
[44952] Failed to execute script 'snowflakesqlalchemy' due to unhandled exception!`
I also printed these logs:
`2023-01-10 11:17:18,250 - MainThread connection.py:275 - __init__() - INFO - Snowflake Connector for Python Version: 2.8.3, Python Version: 3.9.13, Platform: Windows-10-10.0.17763-SP0
2023-01-10 11:17:18,250 - MainThread connection.py:520 - connect() - DEBUG - connect
2023-01-10 11:17:18,250 - MainThread connection.py:810 - __config() - DEBUG - __config
2023-01-10 11:17:18,250 - MainThread connection.py:934 - __config() - INFO - This connection is in OCSP Fail Open Mode. TLS Certificates would be checked for validity and revocation status. Any other Certificate Revocation related exceptions or OCSP Responder failures would be disregarded in favor of connectivity.
2023-01-10 11:17:18,251 - MainThread connection.py:952 - __config() - INFO - Setting use_openssl_only mode to False
2023-01-10 11:17:18,251 - MainThread converter.py:145 - __init__() - DEBUG - use_numpy: False
2023-01-10 11:17:18,251 - MainThread converter_issue23517.py:27 - __init__() - DEBUG - initialized
2023-01-10 11:17:18,251 - MainThread connection.py:713 - __open_connection() - DEBUG - REST API object was created: kzhwbsi-gb82213.snowflakecomputing.com:443
2023-01-10 11:17:18,252 - MainThread auth.py:170 - authenticate() - DEBUG - authenticate
2023-01-10 11:17:18,252 - MainThread auth.py:200 - authenticate() - DEBUG - assertion content: *********
2023-01-10 11:17:18,252 - MainThread auth.py:203 - authenticate() - DEBUG - account=kzhwbsi-gb82213, user=karlpd4c, database=project_database, schema=project_schema, warehouse=None, role=None, request_id=10256208-cea8-4269-a480-820a1c55e4a3
2023-01-10 11:17:18,252 - MainThread auth.py:236 - authenticate() - DEBUG - body['data']: {'CLIENT_APP_ID': 'PythonConnector', 'CLIENT_APP_VERSION': '2.8.3', 'SVN_REVISION': None, 'ACCOUNT_NAME': 'kzhwbsi-gb82213', 'LOGIN_NAME': 'karlpd4c', 'CLIENT_ENVIRONMENT': {'APPLICATION': 'PythonConnector', 'OS': 'Windows', 'OS_VERSION': 'Windows-10-10.0.17763-SP0', 'PYTHON_VERSION': '3.9.13', 'PYTHON_RUNTIME': 'CPython', 'PYTHON_COMPILER': 'MSC v.1929 64 bit (AMD64)', 'OCSP_MODE': 'FAIL_OPEN', 'TRACING': 10, 'LOGIN_TIMEOUT': 120, 'NETWORK_TIMEOUT': None}, 'SESSION_PARAMETERS': {'AUTOCOMMIT': False, 'CLIENT_PREFETCH_THREADS': 4}}
2023-01-10 11:17:18,252 - MainThread auth.py:254 - authenticate() - DEBUG - Timeout set to 120
2023-01-10 11:17:18,253 - MainThread retry.py:351 - from_int() - DEBUG - Converted retries value: 1 -> Retry(total=1, connect=None, read=None, redirect=None, status=None)
2023-01-10 11:17:18,253 - MainThread retry.py:351 - from_int() - DEBUG - Converted retries value: 1 -> Retry(total=1, connect=None, read=None, redirect=None, status=None)
2023-01-10 11:17:18,253 - MainThread network.py:1147 - _use_requests_session() - DEBUG - Session status for SessionPool 'kzhwbsi-gb82213.snowflakecomputing.com', SessionPool 1/1 active sessions
2023-01-10 11:17:18,253 - MainThread network.py:827 - _request_exec_wrapper() - DEBUG - remaining request timeout: 120, retry cnt: 1
2023-01-10 11:17:18,254 - MainThread network.py:808 - add_request_guid() - DEBUG - Request guid: 3bcec6fe-8f7d-4c05-9203-626636c975ea
2023-01-10 11:17:18,254 - MainThread network.py:1006 - _request_exec() - DEBUG - socket timeout: 60
2023-01-10 11:17:18,257 - MainThread connectionpool.py:1003 - _new_conn() - DEBUG - Starting new HTTPS connection (1): kzhwbsi-gb82213.snowflakecomputing.com:443
2023-01-10 11:17:19,295 - MainThread retry.py:594 - increment() - DEBUG - Incremented Retry for (url='/session/v1/login-request?request_id=10256208-cea8-4269-a480-820a1c55e4a3&databaseName=project_database&schemaName=project_schema&request_guid=3bcec6fe-8f7d-4c05-9203-626636c975ea'): Retry(total=0, connect=None, read=None, redirect=None, status=None)
2023-01-10 11:17:19,295 - MainThread connectionpool.py:812 - urlopen() - WARNING - Retrying (Retry(total=0, connect=None, read=None, redirect=None, status=None)) after connection broken by 'NewConnectionError('<snowflake.connector.vendored.urllib3.connection.HTTPSConnection object at 0x00000299937F9A30>: Failed to establish a new connection: [Errno 11002] getaddrinfo failed')': /session/v1/login-request?request_id=10256208-cea8-4269-a480-820a1c55e4a3&databaseName=project_database&schemaName=project_schema&request_guid=3bcec6fe-8f7d-4c05-9203-626636c975ea
2023-01-10 11:17:19,296 - MainThread connectionpool.py:1003 - _new_conn() - DEBUG - Starting new HTTPS connection (2): kzhwbsi-gb82213.snowflakecomputing.com:443
2023-01-10 11:17:19,297 - MainThread network.py:1090 - _request_exec() - DEBUG - Hit a timeout error while logging in. Will be handled by authenticator. Ignore the following. Error stack: HTTPSConnectionPool(host='kzhwbsi-gb82213.snowflakecomputing.com', port=443): Max retries exceeded with url: /session/v1/login-request?request_id=10256208-cea8-4269-a480-820a1c55e4a3&databaseName=project_database&schemaName=project_schema&request_guid=3bcec6fe-8f7d-4c05-9203-626636c975ea (Caused by NewConnectionError('<snowflake.connector.vendored.urllib3.connection.HTTPSConnection object at 0x00000299937F9BE0>: Failed to establish a new connection: [Errno 11002] getaddrinfo failed'))
Traceback (most recent call last):
File "snowflake\connector\vendored\urllib3\connection.py", line 174, in _new_conn
File "snowflake\connector\vendored\urllib3\util\connection.py", line 72, in create_connection
File "socket.py", line 954, in getaddrinfo
socket.gaierror: [Errno 11002] getaddrinfo failed
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "snowflake\connector\vendored\urllib3\connectionpool.py", line 703, in urlopen
File "snowflake\connector\vendored\urllib3\connectionpool.py", line 386, in _make_request
File "snowflake\connector\vendored\urllib3\connectionpool.py", line 1042, in _validate_conn
File "snowflake\connector\vendored\urllib3\connection.py", line 358, in connect
File "snowflake\connector\vendored\urllib3\connection.py", line 186, in _new_conn
snowflake.connector.vendored.urllib3.exceptions.NewConnectionError: <snowflake.connector.vendored.urllib3.connection.HTTPSConnection object at 0x00000299937F9BE0>: Failed to establish a new connection: [Errno 11002] getaddrinfo failed
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "snowflake\connector\vendored\requests\adapters.py", line 489, in send
File "snowflake\connector\vendored\urllib3\connectionpool.py", line 815, in urlopen
File "snowflake\connector\vendored\urllib3\connectionpool.py", line 787, in urlopen
File "snowflake\connector\vendored\urllib3\util\retry.py", line 592, in increment
snowflake.connector.vendored.urllib3.exceptions.MaxRetryError: HTTPSConnectionPool(host='kzhwbsi-gb82213.snowflakecomputing.com', port=443): Max retries exceeded with url: /session/v1/login-request?request_id=10256208-cea8-4269-a480-820a1c55e4a3&databaseName=project_database&schemaName=project_schema&request_guid=3bcec6fe-8f7d-4c05-9203-626636c975ea (Caused by NewConnectionError('<snowflake.connector.vendored.urllib3.connection.HTTPSConnection object at 0x00000299937F9BE0>: Failed to establish a new connection: [Errno 11002] getaddrinfo failed'))
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "snowflake\connector\network.py", line 1018, in _request_exec
File "snowflake\connector\vendored\requests\sessions.py", line 587, in request
File "snowflake\connector\vendored\requests\sessions.py", line 701, in send
File "snowflake\connector\vendored\requests\adapters.py", line 565, in send
snowflake.connector.vendored.requests.exceptions.ConnectionError: HTTPSConnectionPool(host='kzhwbsi-gb82213.snowflakecomputing.com', port=443): Max retries exceeded with url: /session/v1/login-request?request_id=10256208-cea8-4269-a480-820a1c55e4a3&databaseName=project_database&schemaName=project_schema&request_guid=3bcec6fe-8f7d-4c05-9203-626636c975ea (Caused by NewConnectionError('<snowflake.connector.vendored.urllib3.connection.HTTPSConnection object at 0x00000299937F9BE0>: Failed to establish a new connection: [Errno 11002] getaddrinfo failed'))
2023-01-10 11:17:19,305 - MainThread network.py:1152 - _use_requests_session() - DEBUG - Session status for SessionPool 'kzhwbsi-gb82213.snowflakecomputing.com', SessionPool 0/1 active sessions
2023-01-10 11:17:19,305 - MainThread connection.py:1087 - __authenticate() - DEBUG - Operational Error raised at authenticationfor authenticator: AuthByDefault
2023-01-10 11:17:19,305 - MainThread auth_by_plugin.py:114 - handle_timeout() - DEBUG - Default timeout handler invoked for authenticator
2023-01-10 11:17:19,305 - MainThread auth_by_plugin.py:123 - handle_timeout() - DEBUG - Hit connection timeout, attempt number 0. Will retry in a bit...
2023-01-10 11:17:19,305 - MainThread auth_by_plugin.py:56 - next_sleep_duration() - DEBUG - Sleeping for 2 seconds
2023-01-10 11:17:21,306 - MainThread auth.py:170 - authenticate() - DEBUG - authenticate
2023-01-10 11:17:21,306 - MainThread auth.py:200 - authenticate() - DEBUG - assertion content: *********
2023-01-10 11:17:21,306 - MainThread auth.py:203 - authenticate() - DEBUG - account=kzhwbsi-gb82213, user=karlpd4c, database=project_database, schema=project_schema, warehouse=None, role=None, request_id=f8210470-5260-46c4-b7a5-1458f5dc318a
2023-01-10 11:17:21,306 - MainThread auth.py:236 - authenticate() - DEBUG - body['data']: {'CLIENT_APP_ID': 'PythonConnector', 'CLIENT_APP_VERSION': '2.8.3', 'SVN_REVISION': None, 'ACCOUNT_NAME': 'kzhwbsi-gb82213', 'LOGIN_NAME': 'karlpd4c', 'CLIENT_ENVIRONMENT': {'APPLICATION': 'PythonConnector', 'OS': 'Windows', 'OS_VERSION': 'Windows-10-10.0.17763-SP0', 'PYTHON_VERSION': '3.9.13', 'PYTHON_RUNTIME': 'CPython', 'PYTHON_COMPILER': 'MSC v.1929 64 bit (AMD64)', 'OCSP_MODE': 'FAIL_OPEN', 'TRACING': 10, 'LOGIN_TIMEOUT': 120, 'NETWORK_TIMEOUT': None}, 'SESSION_PARAMETERS': {'AUTOCOMMIT': False, 'CLIENT_PREFETCH_THREADS': 4}}
2023-01-10 11:17:21,307 - MainThread auth.py:254 - authenticate() - DEBUG - Timeout set to 120
2023-01-10 11:17:21,307 - MainThread network.py:1147 - _use_requests_session() - DEBUG - Session status for SessionPool 'kzhwbsi-gb82213.snowflakecomputing.com', SessionPool 1/1 active sessions
2023-01-10 11:17:21,307 - MainThread network.py:827 - _request_exec_wrapper() - DEBUG - remaining request timeout: 120, retry cnt: 1
2023-01-10 11:17:21,307 - MainThread network.py:808 - add_request_guid() - DEBUG - Request guid: dbe010e1-6776-46ed-bc5a-9979d617bee4
2023-01-10 11:17:21,307 - MainThread network.py:1006 - _request_exec() - DEBUG - socket timeout: 60
2023-01-10 11:17:21,311 - MainThread connectionpool.py:1003 - _new_conn() - DEBUG - Starting new HTTPS connection (3): kzhwbsi-gb82213.snowflakecomputing.com:443
2023-01-10 11:17:21,312 - MainThread retry.py:594 - increment() - DEBUG - Incremented Retry for (url='/session/v1/login-request?request_id=f8210470-5260-46c4-b7a5-1458f5dc318a&databaseName=project_database&schemaName=project_schema&request_guid=dbe010e1-6776-46ed-bc5a-9979d617bee4'): Retry(total=0, connect=None, read=None, redirect=None, status=None)
2023-01-10 11:17:21,312 - MainThread connectionpool.py:812 - urlopen() - WARNING - Retrying (Retry(total=0, connect=None, read=None, redirect=None, status=None)) after connection broken by 'NewConnectionError('<snowflake.connector.vendored.urllib3.connection.HTTPSConnection object at 0x000002999382B790>: Failed to establish a new connection: [Errno 11002] getaddrinfo failed')': /session/v1/login-request?request_id=f8210470-5260-46c4-b7a5-1458f5dc318a&databaseName=project_database&schemaName=project_schema&request_guid=dbe010e1-6776-46ed-bc5a-9979d617bee4
2023-01-10 11:17:21,312 - MainThread connectionpool.py:1003 - _new_conn() - DEBUG - Starting new HTTPS connection (4): kzhwbsi-gb82213.snowflakecomputing.com:443
2023-01-10 11:17:21,314 - MainThread network.py:1090 - _request_exec() - DEBUG - Hit a timeout error while logging in. Will be handled by authenticator. Ignore the following. Error stack: HTTPSConnectionPool(host='kzhwbsi-gb82213.snowflakecomputing.com', port=443): Max retries exceeded with url: /session/v1/login-request?request_id=f8210470-5260-46c4-b7a5-1458f5dc318a&databaseName=project_database&schemaName=project_schema&request_guid=dbe010e1-6776-46ed-bc5a-9979d617bee4 (Caused by NewConnectionError('<snowflake.connector.vendored.urllib3.connection.HTTPSConnection object at 0x000002999382BA00>: Failed to establish a new connection: [Errno 11002] getaddrinfo failed'))
Traceback (most recent call last):
File "snowflake\connector\vendored\urllib3\connection.py", line 174, in _new_conn
File "snowflake\connector\vendored\urllib3\util\connection.py", line 72, in create_connection
File "socket.py", line 954, in getaddrinfo
socket.gaierror: [Errno 11002] getaddrinfo failed
During handling of the above exception, another exception occurred:
...
This is my python code:
#!/usr/bin/env python
from snowflake.sqlalchemy import URL
from sqlalchemy import create_engine
import pandas as pd
import logging
import os
engine = create_engine('snowflake://user:password#myaccount(e.g.asdfhjk-jh45567)/project_database/project_schema')
os.environ['NO_PROXY'] = 'snowflakecomputing.com'
path = input('logpath:\n')
for logger_name in ['snowflake','botocore']:
logger = logging.getLogger(logger_name)
logger.setLevel(logging.DEBUG)
ch = logging.FileHandler(path+'python_connector.log')
ch.setLevel(logging.DEBUG)
ch.setFormatter(logging.Formatter('%(asctime)s - %(threadName)s %(filename)s:%(lineno)d - %(funcName)s() - %(levelname)s - %(message)s'))
logger.addHandler(ch)
try:
connection = engine.connect()
sql = "SELECT * FROM project_comments"
df = pd.read_sql_query(sql,connection)
print(df)
df.to_csv("./snowflakedata.csv",index=False)
finally:
engine.dispose()
connection.close()
Besides working with sqlalchemy i tried the snowflake connector:
import pandas as pd
import snowflake.connector
import sys
import os
us = input("user: \n")
pw = input("password: \n")
acc = input("account: \n")
cnn = snowflake.connector.connect(
user=us,
password=pw,
account=acc,
)
cs = cnn.cursor()
wh = input("warehouse: \n")
db = input("database: \n")
schema = input("schema: \n")
table = input("table: \n")
path = input("output directory: \n").replace("\\", "/")
try:
sql = "USE WAREHOUSE " + wh
cs.execute(sql)
sql = "USE DATABASE "+ db
cs.execute(sql)
sql = "USE SCHEMA " + schema
cs.execute(sql)
sql = "SELECT * FROM " + table
df = pd.read_sql_query(sql,cnn)
print(df)
df.to_csv(path + "snowflakedata.csv",index=False)
input("snowflake has been read, press any key to close")
finally:
cs.close()
cnn.close()
same problem occurs. On local pc its working fine and on the virtual machine in the on premise network it does not work.
and i tried to deactivate proxy in windows with:
set NO_PROXY=snowflakecomputing.com
Do I need the ip of the snowflake db? How do I get it? Is there something wrong with the dns configuration in sqlalchemy? how do i fix it? do i need another connector or database engine?
I figured out the answer:
If you are behind a coorperate proxy, you need to configure the proxy one in the environment variables as new variable then add these two:
HTTP_PROXY
http://companyuser:companypw#proxy.companydomain.companyname.com:8080
and
HTTPS_PROXY
http://companyuser:companypw#proxy.companydomain.companyname.com:8080
.Then you also need to configre those http and https proxy at application level, meaning in your python program at the beginning:
os.environ["http_proxy"] = "http://companyuser:companypw#proxy.companydomain.companyname.com:8080"
os.environ["https_proxy"] ="http://companyuser:companypw#proxy.companydomain.companyname.com:8080"
in my case the companyuser is the user from my windows machine.

peewee.OperationalError - MySQL connection refused

I'm using peewee for a Python ORM to a MySQL database and Flask to serve a web site from my local desktop running Ubuntu. I can connect to the database from the command line (mysql test -u user -p), but am getting a connection refused error when trying from Python. This code has worked on my previous Ubuntu PC, and I dumped the database from there, imported into the new PC and granted permissions, so I'm really not sure why it's giving me this.
Model.py:
from peewee import MySQLDatabase, Model, AutoField, CharField, IntegerField, \
ForeignKeyField, BooleanField, TextField, DateTimeField
from flask_security import UserMixin, RoleMixin
class BaseModel(Model):
"""
Base model for the model classes; prevents having to define Meta class with the
database for each Model class. Must call BaseModel._meta.database.init() before
connecting - should be able to just call once on BaseModel before
using derived model classes.
"""
class Meta:
database = MySQLDatabase(None) #init before calling connect()
#Additional code to define various tables
Trying to connect in Python command line:
import Model as mmm
db = mmm.BaseModel._meta.database
db.init('test', host = 'localhost', user = 'mike', passwd = password, port = 3306)
db.connect()
Error stack trace:
Traceback (most recent call last):
File "/home/mike/.local/lib/python3.8/site-packages/pymysql/connections.py", line 569, in connect
sock = socket.create_connection(
File "/usr/lib/python3.8/socket.py", line 808, in create_connection
raise err
File "/usr/lib/python3.8/socket.py", line 796, in create_connection
sock.connect(sa)
ConnectionRefusedError: [Errno 111] Connection refused
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "/home/mike/.local/lib/python3.8/site-packages/peewee.py", line 3035, in connect
self._state.set_connection(self._connect())
File "/home/mike/.local/lib/python3.8/site-packages/peewee.py", line 3933, in _connect
conn = mysql.connect(db=self.database, **self.connect_params)
File "/home/mike/.local/lib/python3.8/site-packages/pymysql/__init__.py", line 94, in Connect
return Connection(*args, **kwargs)
File "/home/mike/.local/lib/python3.8/site-packages/pymysql/connections.py", line 327, in __init__
self.connect()
File "/home/mike/.local/lib/python3.8/site-packages/pymysql/connections.py", line 619, in connect
raise exc
pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'aspire' ([Errno 111] Connection refused)")
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/home/mike/.local/lib/python3.8/site-packages/peewee.py", line 3038, in connect
self._initialize_connection(self._state.conn)
File "/home/mike/.local/lib/python3.8/site-packages/peewee.py", line 2873, in __exit__
reraise(new_type, new_type(exc_value, *exc_args), traceback)
File "/home/mike/.local/lib/python3.8/site-packages/peewee.py", line 183, in reraise
raise value.with_traceback(tb)
File "/home/mike/.local/lib/python3.8/site-packages/peewee.py", line 3035, in connect
self._state.set_connection(self._connect())
File "/home/mike/.local/lib/python3.8/site-packages/peewee.py", line 3933, in _connect
conn = mysql.connect(db=self.database, **self.connect_params)
File "/home/mike/.local/lib/python3.8/site-packages/pymysql/__init__.py", line 94, in Connect
return Connection(*args, **kwargs)
File "/home/mike/.local/lib/python3.8/site-packages/pymysql/connections.py", line 327, in __init__
self.connect()
File "/home/mike/.local/lib/python3.8/site-packages/pymysql/connections.py", line 619, in connect
raise exc
peewee.OperationalError: (2003, "Can't connect to MySQL server on 'aspire' ([Errno 111] Connection refused)")

Chrome failed to start in GitHub Actions

This is the error message I get from GitHub workflows:
/opt/hostedtoolcache/Python/3.9.6/x64/lib/python3.9/site-packages/selenium/webdriver/chrome/webdriver.py:76: in __init__ 47 RemoteWebDriver.__init__( 48 /opt/hostedtoolcache/Python/3.9.6/x64/lib/python3.9/site-packages/selenium/webdriver/remote/webdriver.py:157: in __init__ 49 self.start_session(capabilities, browser_profile) 50 /opt/hostedtoolcache/Python/3.9.6/x64/lib/python3.9/site-packages/selenium/webdriver/remote/webdriver.py:252: in start_session 51 response = self.execute(Command.NEW_SESSION, parameters) 52 /opt/hostedtoolcache/Python/3.9.6/x64/lib/python3.9/site-packages/selenium/webdriver/remote/webdriver.py:321: in execute 53 self.error_handler.check_response(response)
response = {'status': 500, 'value': '{"value":{"error":"unknown error","message":"unknown error: Chrome failed to start: exited a...wn>\\n#14 0x563a8d1c9e58 \\u003Cunknown>\\n#15 0x563a8d1e3dfd \\u003Cunknown>\\n#16 0x7f9599f6f609 start_thread\\n"}}'}
Note: I am using webdriver manager to install chrome driver.

Django MySQL server has gone away

I have a django site the was using sqlite for the backend, recently we upgraded to MySQL and now are receiving intermittent errors:
'MySQL server has gone away'
After starting the site it loads fine, clicking around to change pages will result in the error usually after viewing 1 to 6 pages. The page it occurs on appears to be irrelevant, the same page may load fine the first time but throw the error the 2nd time.
Here's my environment:
Nginx running on host machine as reverse proxy
Docker container running Nginx inside, Django 1.8, uwsgi, and Python 3.4.
Django is using the mysqlclient db driver.
Google Cloud MySQL, 2nd generation
I've tried using a local MySQL server rather than the Google Cloud MySQL, it didn't make a difference. I also tried using the MySQL Connector/Python DB driver instead of mysqlclient. It produced a different (but similar) error message and traceback.
If I go back to SQLite, it works fine. Running under the django development server rather than nginx also works fine.
I've seen posts for this error stating that the django CONN_MAX_AGE should be less than the MySQL wait_timeout, but I'm using the default CONN_MAX_AGE setting of 0. According to the django docs, setting this to 0 (default) causes django to create a new database connection for each request. A value greater than 0 will define how long the connection remains open so it can be reused by another request. If I set it to a value greater than 0 the error goes away, but I'm concerned that I'm just deferring the error until later after the persistent connection expires. Also the django development web server creates a new connection for each request (similar to CONN_MAX_AGE=0), but I don't get the error using the dev server. Django versions prior to 1.6 did not support persistent connections, so it seems like I should be able to keep the default CONN_MAX_AGE=0 setting.
I had to enable logging for uwsgi, it's error log shows the following:
*** Starting uWSGI 2.0.13.1 (64bit) on [Fri Nov 18 22:15:33 2016] ***
compiled with version: 4.8.4 on 18 May 2016 17:48:05
os: Linux-4.4.0-45-generic #66-Ubuntu SMP Wed Oct 19 14:12:37 UTC 2016
nodename: 083c33814e43
machine: x86_64
clock source: unix
detected number of CPU cores: 8
current working directory: /
detected binary path: /usr/local/bin/uwsgi
!!! no internal routing support, rebuild with pcre support !!!
uWSGI running as root, you can use --uid/--gid/--chroot options
*** WARNING: you are running uWSGI as root !!! (use the --uid flag) ***
chdir() to /srv/ftc
your memory page size is 4096 bytes
detected max file descriptor number: 65536
lock engine: pthread robust mutexes
thunder lock: disabled (you can enable it with --thunder-lock)
uwsgi socket 0 bound to UNIX address /srv/ftc/ftc.sock fd 3
Python version: 3.4.3 (default, Oct 14 2015, 20:31:36) [GCC 4.8.4]
Set PythonHome to /srv/env/ftc
*** Python threads support is disabled. You can enable it with --enable-threads ***
Python main interpreter initialized at 0x22a73d0
your server socket listen backlog is limited to 100 connections
your mercy for graceful operations on workers is 60 seconds
mapped 1476189 bytes (1441 KB) for 10 cores
*** Operational MODE: preforking ***
Loading configuration from /srv/ftc/data/settings_local.py
WSGI app 0 (mountpoint='') ready in 2 seconds on interpreter 0x22a73d0 pid: 9 (default app)
*** uWSGI is running in multiple interpreter mode ***
spawned uWSGI master process (pid: 9)
spawned uWSGI worker 1 (pid: 17, cores: 1)
spawned uWSGI worker 2 (pid: 18, cores: 1)
spawned uWSGI worker 3 (pid: 19, cores: 1)
spawned uWSGI worker 4 (pid: 20, cores: 1)
spawned uWSGI worker 5 (pid: 21, cores: 1)
spawned uWSGI worker 6 (pid: 22, cores: 1)
spawned uWSGI worker 7 (pid: 23, cores: 1)
spawned uWSGI worker 8 (pid: 24, cores: 1)
spawned uWSGI worker 9 (pid: 25, cores: 1)
spawned uWSGI worker 10 (pid: 26, cores: 1)
[pid: 21|app: 0|req: 1/1] 192.168.1.15 () {38 vars in 637 bytes} [Fri Nov 18 17:15:39 2016] GET /faq/ => generated 13018 bytes in 3021 msecs (HTTP/1.1 200) 8 headers in 412 bytes (1 switches on core 0)
[pid: 21|app: 0|req: 2/2] 192.168.1.15 () {40 vars in 707 bytes} [Fri Nov 18 17:16:20 2016] GET /find-local-food/ => generated 20480 bytes in 1510 msecs (HTTP/1.1 200) 7 headers in 290 bytes (2 switches on core 0)
[pid: 21|app: 0|req: 3/3] 192.168.1.15 () {40 vars in 711 bytes} [Fri Nov 18 17:16:23 2016] GET /my-programs/ => generated 9297 bytes in 1454 msecs (HTTP/1.1 200) 7 headers in 290 bytes (2 switches on core 0)
[pid: 21|app: 0|req: 4/4] 192.168.1.15 () {40 vars in 683 bytes} [Fri Nov 18 17:16:26 2016] GET / => generated 13562 bytes in 3037 msecs (HTTP/1.1 200) 8 headers in 412 bytes (2 switches on core 0)
[pid: 21|app: 0|req: 5/5] 192.168.1.15 () {40 vars in 683 bytes} [Fri Nov 18 17:16:30 2016] GET /about/ => generated 10064 bytes in 1586 msecs (HTTP/1.1 200) 7 headers in 290 bytes (2 switches on core 0)
[pid: 21|app: 0|req: 6/6] 192.168.1.15 () {40 vars in 685 bytes} [Fri Nov 18 17:16:33 2016] GET /faq/ => generated 13018 bytes in 1145 msecs (HTTP/1.1 200) 8 headers in 412 bytes (2 switches on core 0)
[pid: 21|app: 0|req: 7/7] 192.168.1.15 () {40 vars in 691 bytes} [Fri Nov 18 17:16:35 2016] GET /contact/ => generated 8734 bytes in 1352 msecs (HTTP/1.1 200) 7 headers in 290 bytes (2 switches on core 0)
[pid: 21|app: 0|req: 8/8] 192.168.1.15 () {40 vars in 711 bytes} [Fri Nov 18 17:16:38 2016] GET /find-local-food/ => generated 20480 bytes in 1484 msecs (HTTP/1.1 200) 7 headers in 290 bytes (2 switches on core 0)
[pid: 21|app: 0|req: 9/9] 192.168.1.15 () {40 vars in 699 bytes} [Fri Nov 18 17:16:41 2016] GET /about/ => generated 10064 bytes in 1723 msecs (HTTP/1.1 200) 7 headers in 290 bytes (2 switches on core 0)
Traceback (most recent call last):
File "/srv/env/ftc/lib/python3.4/site-packages/django/core/urlresolvers.py", line 393, in urlconf_module
return self._urlconf_module
AttributeError: 'RegexURLResolver' object has no attribute '_urlconf_module'
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "/srv/env/ftc/lib/python3.4/site-packages/django/db/backends/utils.py", line 64, in execute
return self.cursor.execute(sql, params)
File "/srv/env/ftc/lib/python3.4/site-packages/django/db/backends/mysql/base.py", line 124, in execute
return self.cursor.execute(query, args)
File "/srv/env/ftc/lib/python3.4/site-packages/MySQLdb/cursors.py", line 250, in execute
self.errorhandler(self, exc, value)
File "/srv/env/ftc/lib/python3.4/site-packages/MySQLdb/connections.py", line 42, in defaulterrorhandler
raise errorvalue
File "/srv/env/ftc/lib/python3.4/site-packages/MySQLdb/cursors.py", line 247, in execute
res = self._query(query)
File "/srv/env/ftc/lib/python3.4/site-packages/MySQLdb/cursors.py", line 411, in _query
rowcount = self._do_query(q)
File "/srv/env/ftc/lib/python3.4/site-packages/MySQLdb/cursors.py", line 374, in _do_query
db.query(q)
File "/srv/env/ftc/lib/python3.4/site-packages/MySQLdb/connections.py", line 270, in query
_mysql.connection.query(self, query)
_mysql_exceptions.OperationalError: (2006, 'MySQL server has gone away')
The above exception was the direct cause of the following exception:
Traceback (most recent call last):
File "/srv/env/ftc/lib/python3.4/site-packages/django/core/handlers/wsgi.py", line 170, in __call__
self.load_middleware()
File "/srv/env/ftc/lib/python3.4/site-packages/django/core/handlers/base.py", line 52, in load_middleware
mw_instance = mw_class()
File "/srv/env/ftc/lib/python3.4/site-packages/django/middleware/locale.py", line 24, in __init__
for url_pattern in get_resolver(None).url_patterns:
File "/srv/env/ftc/lib/python3.4/site-packages/django/core/urlresolvers.py", line 401, in url_patterns
patterns = getattr(self.urlconf_module, "urlpatterns", self.urlconf_module)
File "/srv/env/ftc/lib/python3.4/site-packages/django/core/urlresolvers.py", line 395, in urlconf_module
self._urlconf_module = import_module(self.urlconf_name)
File "/srv/env/ftc/lib/python3.4/importlib/__init__.py", line 109, in import_module
return _bootstrap._gcd_import(name[level:], package, level)
File "<frozen importlib._bootstrap>", line 2254, in _gcd_import
File "<frozen importlib._bootstrap>", line 2237, in _find_and_load
File "<frozen importlib._bootstrap>", line 2226, in _find_and_load_unlocked
File "<frozen importlib._bootstrap>", line 1200, in _load_unlocked
File "<frozen importlib._bootstrap>", line 1129, in _exec
File "<frozen importlib._bootstrap>", line 1471, in exec_module
File "<frozen importlib._bootstrap>", line 321, in _call_with_frames_removed
File "./ftc/urls.py", line 23, in <module>
url(r'^', include('areas.public.urls')),
File "/srv/env/ftc/lib/python3.4/site-packages/django/conf/urls/__init__.py", line 33, in include
urlconf_module = import_module(urlconf_module)
File "/srv/env/ftc/lib/python3.4/importlib/__init__.py", line 109, in import_module
return _bootstrap._gcd_import(name[level:], package, level)
File "<frozen importlib._bootstrap>", line 2254, in _gcd_import
File "<frozen importlib._bootstrap>", line 2237, in _find_and_load
File "<frozen importlib._bootstrap>", line 2226, in _find_and_load_unlocked
File "<frozen importlib._bootstrap>", line 1200, in _load_unlocked
File "<frozen importlib._bootstrap>", line 1129, in _exec
File "<frozen importlib._bootstrap>", line 1471, in exec_module
File "<frozen importlib._bootstrap>", line 321, in _call_with_frames_removed
File "./areas/public/urls.py", line 36, in <module>
url(r'^paypal/', include('areas.public.paypal.urls')),
File "/srv/env/ftc/lib/python3.4/site-packages/django/conf/urls/__init__.py", line 33, in include
urlconf_module = import_module(urlconf_module)
File "/srv/env/ftc/lib/python3.4/importlib/__init__.py", line 109, in import_module
return _bootstrap._gcd_import(name[level:], package, level)
File "<frozen importlib._bootstrap>", line 2254, in _gcd_import
File "<frozen importlib._bootstrap>", line 2237, in _find_and_load
File "<frozen importlib._bootstrap>", line 2226, in _find_and_load_unlocked
File "<frozen importlib._bootstrap>", line 1200, in _load_unlocked
File "<frozen importlib._bootstrap>", line 1129, in _exec
File "<frozen importlib._bootstrap>", line 1471, in exec_module
File "<frozen importlib._bootstrap>", line 321, in _call_with_frames_removed
File "./areas/public/paypal/urls.py", line 5, in <module>
from . import payment_complete
File "./areas/public/paypal/payment_complete.py", line 9, in <module>
PublicCommon = PublicCommon()
File "./areas/public/common/__init__.py", line 34, in __init__
self.login_page = self.get_cms_page('pu_login')
File "./areas/public/common/__init__.py", line 27, in get_cms_page
return get_object_or_404(Page, reverse_id=reverse_id, publisher_is_draft=False)
File "/srv/env/ftc/lib/python3.4/site-packages/django/shortcuts.py", line 155, in get_object_or_404
return queryset.get(*args, **kwargs)
File "/srv/env/ftc/lib/python3.4/site-packages/django/db/models/query.py", line 328, in get
num = len(clone)
File "/srv/env/ftc/lib/python3.4/site-packages/django/db/models/query.py", line 144, in __len__
self._fetch_all()
File "/srv/env/ftc/lib/python3.4/site-packages/django/db/models/query.py", line 965, in _fetch_all
self._result_cache = list(self.iterator())
File "/srv/env/ftc/lib/python3.4/site-packages/django/db/models/query.py", line 238, in iterator
results = compiler.execute_sql()
File "/srv/env/ftc/lib/python3.4/site-packages/django/db/models/sql/compiler.py", line 840, in execute_sql
cursor.execute(sql, params)
File "/srv/env/ftc/lib/python3.4/site-packages/django/db/backends/utils.py", line 79, in execute
return super(CursorDebugWrapper, self).execute(sql, params)
File "/srv/env/ftc/lib/python3.4/site-packages/django/db/backends/utils.py", line 64, in execute
return self.cursor.execute(sql, params)
File "/srv/env/ftc/lib/python3.4/site-packages/django/db/utils.py", line 98, in __exit__
six.reraise(dj_exc_type, dj_exc_value, traceback)
File "/srv/env/ftc/lib/python3.4/site-packages/django/utils/six.py", line 685, in reraise
raise value.with_traceback(tb)
File "/srv/env/ftc/lib/python3.4/site-packages/django/db/backends/utils.py", line 64, in execute
return self.cursor.execute(sql, params)
File "/srv/env/ftc/lib/python3.4/site-packages/django/db/backends/mysql/base.py", line 124, in execute
return self.cursor.execute(query, args)
File "/srv/env/ftc/lib/python3.4/site-packages/MySQLdb/cursors.py", line 250, in execute
self.errorhandler(self, exc, value)
File "/srv/env/ftc/lib/python3.4/site-packages/MySQLdb/connections.py", line 42, in defaulterrorhandler
raise errorvalue
File "/srv/env/ftc/lib/python3.4/site-packages/MySQLdb/cursors.py", line 247, in execute
res = self._query(query)
File "/srv/env/ftc/lib/python3.4/site-packages/MySQLdb/cursors.py", line 411, in _query
rowcount = self._do_query(q)
File "/srv/env/ftc/lib/python3.4/site-packages/MySQLdb/cursors.py", line 374, in _do_query
db.query(q)
File "/srv/env/ftc/lib/python3.4/site-packages/MySQLdb/connections.py", line 270, in query
_mysql.connection.query(self, query)
django.db.utils.OperationalError: (2006, 'MySQL server has gone away')
[pid: 20|app: 0|req: 1/10] 192.168.1.15 () {40 vars in 701 bytes} [Fri Nov 18 17:16:43 2016] GET /my-programs/ => generated 0 bytes in 258 msecs (HTTP/1.1 500) 0 headers in 0 bytes (1 switches on core 0)
...brutally killing workers...
worker 1 buried after 1 seconds
worker 2 buried after 1 seconds
worker 3 buried after 1 seconds
worker 4 buried after 1 seconds
worker 5 buried after 1 seconds
worker 6 buried after 1 seconds
worker 7 buried after 1 seconds
worker 8 buried after 1 seconds
worker 9 buried after 1 seconds
worker 10 buried after 1 seconds
binary reloading uWSGI...
chdir() to /
closing all non-uwsgi socket fds > 2 (max_fd = 65536)...
found fd 3 mapped to socket 0 (/srv/ftc/ftc.sock)
running /usr/local/bin/uwsgi
[uWSGI] getting INI configuration from /srv/ftc/conf/uwsgi.ini
Thanks in advance for any help!
This is usually a mysql configuration problem. The settings in particular that you want to adjust for your website are:
max_allowed_packet: http://dev.mysql.com/doc/refman/5.7/en/packet-too-large.html
wait_timeout: http://dev.mysql.com/doc/refman/5.7/en/gone-away.html
But if you’ll look at your log, the mysql gone away problem is only during the handling of an exception that is being caused somewhere else. I would try and solve this exception first before trying to tackle the mysql issue
Traceback (most recent call last):
File "/srv/env/ftc/lib/python3.4/site-packages/django/core/urlresolvers.py", line 393, in urlconf_module
return self._urlconf_module
AttributeError: 'RegexURLResolver' object has no attribute '_urlconf_module'
I found the solution. I added lazy-apps to uwsgi.ini. See ningx, uwsgi, python permanent mysql error after some time from starting application
I'm not using sql alchemy but this did fix the mysql server has gone away error.

DAL connection string for Web2Py to MySQL on TurnkeyLinux

On TurnkeyLinux I have tried to connect a Web2Py app to the MySQL instance (which is up and running) with the following DAL statement (in db.py):
db = DAL('mysql://root:pwd2sql#web2py/dbname', fake_migrate_all=True)
It doesn't work and throws the following ticket:
Failure to connect, tried 5 times: Traceback (most recent call last): File "/var/www/web2py/gluon/dal.py", line 7562, in init self.adapter = ADAPTERSself._dbname File "/var/www/web2py/gluon/dal.py", line 2572, in __init_ if do_connect: self.reconnect() File "/var/www/web2py/gluon/dal.py", line 606, in reconnect self.connection = f() File "/var/www/web2py/gluon/dal.py", line 2570, in connector return self.driver.connect(*driver_args) File "/usr/lib/python2.7/dist-packages/MySQLdb/init.py", line 81, in Connect return Connection(args, *kwargs) File "/usr/lib/python2.7/dist-packages/MySQLdb/connections.py", line 187, in init super(Connection, self).init(args, **kwargs2) OperationalError: (2003, "Can't connect to MySQL server on 'web2py' (111)")
Does anybody have a connection string sample I can use ?