mysql.connector+mysql hangs on fetching - mysql

I have a database that is accessed from python3 script using mysql.connector. Mysql version is 5.5.58-0ubuntu0.14.04.1, tested on Linux Mint 17 x64 and a few other Linux machines. The script requests a chunk of data (from tens to about five thousand records) and then sends about ten times as many single-row requests. After that, the connection is closed and a new one opens to do the same. Alternatively, several connections are run in parallel. The entire script is available at github
It works fine for ~5 to ~50 times (per process, if launched in multiprocessing pool), then hangs. The python3 process is sleeping, mysql shows a single sleeping connection per process. If the script is killed, the traceback is following:
Traceback (most recent call last):
File "/home/morozov/tools/phylome/process_outers.py", line 116, in <module>
r = wrapper(fasta)
File "/home/morozov/tools/phylome/process_outers.py", line 108, in wrapper
password=args.p, database=args.d)
File "/home/morozov/tools/phylome/process_outers.py", line 43, in process_fasta
result = cursor.fetchall()
File "/usr/local/lib/python3.4/dist-packages/mysql/connector/cursor.py", line 825, in fetchall
(rows, eof) = self._connection.get_rows()
File "/usr/local/lib/python3.4/dist-packages/mysql/connector/connection.py", line 671, in get_rows
rows = self._protocol.read_text_result(self._socket, count)
File "/usr/local/lib/python3.4/dist-packages/mysql/connector/protocol.py", line 309, in read_text_result
packet = sock.recv()
File "/usr/local/lib/python3.4/dist-packages/mysql/connector/network.py", line 245, in recv_plain
read = self.sock.recv_into(packet_view, rest)
KeyboardInterrupt
After restarting the script, the file it hang on is processed alright and it hangs on some other one down the line. What should I fix to keep it running?

Still not the slightest idea what was wrong, but using pymysql instead of mysql.connector fixed it.

Related

Java heap space error in TypeDB when importing CSV files

I tried to import some CSV files into my TypeDB schema using Python and got the following error.
Traceback (most recent call last):
File "C:\Users\panxx006\Desktop\test\migrate.py", line 65, in <module>
build_test_graph(inputs=inputs)
File "C:\Users\panxx006\Desktop\test\migrate.py", line 9, in build_test_graph
load_data_into_typedb(input, session)
File "C:\Users\panxx006\Desktop\test\migrate.py", line 21, in load_data_into_typedb
transaction.commit()
File "C:\Users\panxx006\AppData\Local\Programs\Python\Python39\lib\site-packages\typedb\connection\transaction.py", line 95, in commit
self.execute(transaction_commit_req())
File "C:\Users\panxx006\AppData\Local\Programs\Python\Python39\lib\site-packages\typedb\connection\transaction.py", line 80, in execute
return self.run_query(request, batch).get()
File "C:\Users\panxx006\AppData\Local\Programs\Python\Python39\lib\site-packages\typedb\stream\bidirectional_stream.py", line 136, in get
return self._stream.fetch(self._request_id)
File "C:\Users\panxx006\AppData\Local\Programs\Python\Python39\lib\site-packages\typedb\stream\bidirectional_stream.py", line 84, in fetch
raise error
typedb.common.exception.TypeDBClientException: Java heap space
Please check server logs for the stack trace.
Could you please tell me the way to fix this error? I'm using TypeDB 2.6.3
Upgrading your version of TypeDB to the latest version will help solve this error. As of writing, TypeDB 2.13.0 is the newest version, which includes a number of improvements to memory usage so you should see fewer errors of this kind in the future.
You can download the latest version of TypeDB from the releases page on GitHub: https://github.com/vaticle/typedb/releases
Full disclosure: I work for Vaticle, the creators of TypeDB.

Unable to create instance from CLI

I've installed the single DevStack and been able to create a compute instance through the WUI, but if I try and perform the same task from the CLI I receive the following error
Traceback (most recent call last): File "/opt/stack/nova/nova/conductor/manager.py", line 703, in build_instances raise exception.MaxRetriesExceeded(reason=msg) nova.exception.MaxRetriesExceeded: Exceeded maximum number of retries. Exhausted all hosts available for retrying build failures for instance 1a5e912b-dac4-4633-834d-3a49800edd74.
Looking at that line in the code it would appear to suggest it's unable to schedule the build; though why would it work through the WUI?
Thanks.

Windows 10 Rtree installation successful from .whl file, but error when running code

I am running Python 3.7, 64bit on Windows 10 and trying desperately to get Rtree running. I use the package Rtree-0.9.1-cp37-cp37m-win_amd64.whl from Christoph Gohlke (https://www.lfd.uci.edu/~gohlke/pythonlibs/).
I have tried for very long to get it to work, but keep on getting the following error message when running a script that uses geopandas.
Traceback (most recent call last):
File "C:\Python37\lib\site-packages\rtree\core.py", line 90, in <module>
rt = ctypes.CDLL(os.path.join(here, 'spatialindex_c.dll'))
File "C:\Python37\lib\ctypes\__init__.py", line 364, in __init__
self._handle = _dlopen(self._name, mode)
OSError: [WinError 126] The specified module could not be found
The installation of the whl-package should include the libspatialindex files, but they are not found when running the code. I tried to use Python 2.7 first to run it, then installed Python 3.7. I've checked all the dependencies and checked whether the "spatialindex_c.dll" files are at the right place, but nothing helps. Would be great to get an answer on that.

Disk is too full, resizing is not helping or taking effect [Google Compute Engine]

I am using Google Compute engine and I got what is commonly known issue cannot connect via ssh or any means due to Disk is too full. I have resized disk multiple times and even x10 but changes are visible within compute engine but ssh still won't connect and logs still says disk is full.
Is there any other ways to solve this, I have important data/mongodb in that engine ?
resized incrementally few times, didn't help
added additional disks, didn't help
tried to delete some files via startup-script, didn't help
Some part of error messages...
Traceback (most recent call last):
File "/usr/bin/cloud-init", line 618, in <module>
sys.exit(main())
File "/usr/bin/cloud-init", line 614, in main
get_uptime=True, func=functor, args=(name, args))
File "/usr/lib/python2.7/dist-packages/cloudinit/util.py", line 1900, in log_time
ret = func(*args, **kwargs)
File "/usr/bin/cloud-init", line 489, in status_wrapper
atomic_write_json(status_path, status)
File "/usr/bin/cloud-init", line 434, in atomic_write_json
raise e
IOError: [Errno 28] No space left on device
Aug 5 04:46:15 backend google: startup script found in metadata.
/usr/share/google/fetch_script: line 30: echo: write error: No space left on device
Aug 5 04:46:15 backend startupscript: Running startup script /var/run/google.startup.script
Aug 5 04:46:15 backend startupscript: Finished running startup script /var/run/google.startup.script
...
accounts-from-metadata: WARNING Could not update /home/ubuntu/.ssh/authorized_keys due to Disk is too full
After few different attempts I was able to fix issue by:
creating snapshot of the disk and creating new instance with increased persistent storage, data is there and size of disk is increased, all set.

Stanford Tagger in nltk not working due to JVM parameters

I am having a wired error while running following example code snippet
st = StanfordTagger('bidirectional-distsim-wsj-0-18.tagger')
st.tag('What is the airspeed of an unladen swallow ?'.split())
The first line worked properly but second line is giving following error.
Could not create the Java virtual machine.
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/usr/local/lib/python2.6/dist-packages/nltk-2.0.1rc1- py2.6.egg/nltk/tag/stanford.py", line 51, in tag
return self.batch_tag([tokens])[0]
File "/usr/local/lib/python2.6/dist-packages/nltk-2.0.1rc1-py2.6.egg/nltk/tag/stanford.py", line 77, in batch_tag
stdout=PIPE, stderr=PIPE)
File "/usr/local/lib/python2.6/dist-packages/nltk-2.0.1rc1-py2.6.egg/nltk/internals.py", line 166, in java
raise OSError('Java command failed!')
OSError: Java command failed!
I have tried adding .usr/lib/jvm into path but still not working
It wasn't working for me either. So I tried the following and its working perfectly.
st = POSTagger('path-to/stanford-postagger-full-2012-07-09/models/wsj-0-18-left3words.tagger','path-to/stanford-postagger-full-2012-07-09/stanford-postagger.jar')
and use nltk's tokenize method instead of Python's split()
taggedSentence= st.tag(nltk.word_tokenize(sentence))
I see that question is very outdated, but this days I got same error for unknown reason. It gives me a lot of headache. But I found solution.
First, I installed Oracle Java (here is instructions: How To Manually Install Oracle Java on a Debian or Ubuntu VPS)
Now, my python script told me more information on error. It outputs something like:
Forking JVM: error=12, Cannot allocate memory or error=12, Not enough space
Here you can read more about such problem: Forking the JVM
And to avoid that annoying error I need to edit /etc/sysctl.conf and add the following:
vm.overcommit_memory = 1
Then restart system for the change to take effect.