mozilla-services / syncserver

Run-Your-Own Firefox Sync Server
Mozilla Public License 2.0
1.87k stars 145 forks source link

PyMySQL Packet sequence number wrong #199

Open Beneter opened 4 years ago

Beneter commented 4 years ago

When running make serve on the latest master version 7557f7f06cf175537e639dd3ae16d137c70c5905 with the configuration option sqluri = pymysql://firefox-sync:password@localhost/firefox_sync I get the following exception: InternalError: (pymysql.err.InternalError) Packet sequence number wrong - got 1 expected 0 Traceback.txt

I triple checked my connection string and the MySQL permissions. According to https://github.com/PyMySQL/PyMySQL/issues/422 this might be caused by multithreading.

jrconlin commented 4 years ago

Reading that bug notes that PyMySQL is not thread safe. I'm a bit surprised that this hasn't popped up more on production, but good info none the less. Thanks!

rfk commented 4 years ago

Reading that bug notes that PyMySQL is not thread safe.

IIRC, SQLAlchemy is supposed to have some logic to help deal with this, by using the connectionpool to ensure only one thread is dealing with a connection at any one time. It's possible we're doing something wrong in that regard though.

Beneter commented 4 years ago

So thanks to #202 I was able to reconfigure the sqluri to mysql+mysqldb://firefox-sync:password@localhost/firefox_sync and after installing ./local/bin/pip install mysqlclient I was finally able to start the syncserver. It might be helpful to add this option to the Readme.md.