-
Notifications
You must be signed in to change notification settings - Fork 976
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Transaction savepoints do not work #948
Comments
Hi.
Also, please check if there is anything suspicious in the error log. Thanks. |
Helo Rene We've already set
The query rules are trivial:
|
Hi. |
My colleague @mosquito was so kind that he prepared environment which reproduces the bug |
Very kind! Thank you @mosquito |
@renecannao problem reproducing only when many workers are working with |
I confirm the issue. Still investigating |
From the OK packet it seems that The easy solution is to automatically disable multiplexing for that HG once A better solution is to automatically disable multiplexing for that HG once |
Thank you Rene for investigation! |
@renecannao when you plan to release 1.4.0 with fix of the problem #948? |
Hi, |
This, or a variation of it, is occurring for me using 1.4.9 and the Django ORM. Steps to reproduce:
This causes error messages like: |
This appears to be a regression from 1.4.3. Running the exact same script (which errors 100% of the time on 1.4.9) against 1.4.3 does not have the issue. |
Currently, I'm facing the same issue with using 1.4.11( also reproduced at 1.4.3 ). I resolved this issue by adding below rules to mysql_query_rules. (I'm using only one HG)
But, I'm wondering that these query rules automatically re-enable multiplexing? and is there any way to verify that connection multiplexing works well? Thanks. |
Been a while since there was an update, just wanted to add we identified this as the bug which breaks django admin user add functionality so bit us as well :( |
We're being bitten by this with SQLAlchemy. I tried the query rules above but no dice. @renecannao is there any work being done on this? |
I hit the missing-savepoint errors in a Django test suite, and seem to be working around OK by setting autocommit-related settings conservatively (autocommit_false_is_transaction, forward_autocommit, and enforce_autocommit_on_reads all true). This isn't live yet, so it's still possible we could find problems, but a large test suite is passing OK. Of course, that may mean you need to tweak your app code if you're currently counting on multiplexing while autocommit is off for performance, connection count, or whatever. |
I am using ProxySQL 2.0.2 on CentOS 7 PC . Using multiple write node. Query rules are following for disabling multiplexing. But no luck for me . getting the Error during query on (1,ip,3306): 1305, SAVEPOINT TransactionBegin does not exist regular basis.
|
I did some tests with Django's nested FYI, I have set |
This is a temporary workaround until we fix an autocommit bug
Closing. Fixed in 2.0.13 |
This is a temporary workaround until we fix an autocommit bug
I am still seeing Unlike in my comment above, which is about 1.4.16, I haven't found a global or user setting that gets around the problem (except setting fast_forward on the user, which disables a lot of functionality we want). I'll try to follow up with anything I'm able to figure out, like reproducers or whether I can work around it with query rules. We do have nested savepoints in multiple processes concurrently, like in zbentley's steps to reproduce. Since it seems to be new information that SAVEPOINT still doesn't work for some after 2.0.13, I figured it was worth reporting that even while I look for other info. |
@twotwotwo : please do not use query rules related to savepoint: they should work out of the box. |
Nice, I had just independently decided I should test with autocommit-y variables in their default states, started the run, came back and saw this comment. The suite takes a while, but will let you know what I find. |
A run with autocommit settings at their defaults but multiplexing on did have some failures at RELEASE SAVEPOINT statements. (And this is trivial, but a run with fast_forward off and multiplexing off succeeded as you'd expect.) I haven't yet made a minimal reproducer. I'm signing off work soon but one thread I'll dig into more when I get back to this: Python's DB interface spec says Python must initially have autocommit off on connections. The ProxySQL code references a MySQL bug where the server misreports autocommit as on when it's off. ProxySQL uses MySQL's reported autocommit status bit as part of the test for whether it should clear STATUS_MYSQL_CONNECTION_HAS_SAVEPOINT. If MySQL is misreporting autocommit as on, that could confuse that test. If that's what's happening, then using In my ProxySQL 1.4 work long ago, I did have to patch our application to not trust the Python DB interface's |
Just fiddling at the CLI, it looks like Django's transaction.atomic wrapper uses autocommit=0 to open the outer "transaction" with no explicit BEGIN, and uses savepoints for any nested ones. In the context of our test suite, things work pretty often (immediately issuing I'm guessing we got away with Django's behavior under ProxySQL 1.4 because we enabled forward_autocommit, which is gone now. Is there anything low-impact I could do to ensure autocommit status gets passed back to the backend? (Is this still the right bug for this issue? It might be a different one that is more about autocommit than savepoints.) |
I do not observe your issue when I try it myself. Here is some output, when connecting to proxysql.
I am using
In the same output, you can see that there is no
In the above, what is new is that we now have a
The client is now linked to a backend, multiplexing is disabled, and proxysql knows there is a savepoint! Next, we run
Nothing relevant has changed in the above output after running Now let's run
Now you can see that
Please confirm with some output. Please also run
Yes, |
Progress! It turns out my trivial steps only "worked" with forward_autocommit true in 2.0.18, and with that disabled, only the test suite reproduces it. Sorry for the false lead. (I had thought the forward_autocommit setting from the old script we wrote for 1.4 was now a no-op, but that was because I was looking at the latest code, not 2.0.18's.) With strace, I think I found that the OK response right before the failure has the autocommit bit on when I would not expect it:
PROXYSQL INTERNAL SESSION right after this also has Up to this point the app had flipped autocommit on/off several times, created and released some savepoints, and run some selects and DDL, all successfully. The immediately previous commands are (Edit: replaced the session info since initially posting. The first version had the "After set autocommit=off" info repeated twice due to a silly typo in my debug code)
|
Hi @twotwotwo , From the output you provided it is possible that, while you are focus on just
The above clearly states that multiplexing is disabled, for at least 2 reasons: Furthermore, and probably because of point A, the client connection is locked on hostgroup 1 , meaning that both routing and multiplexing are disabled (error log should have details about this). I would suggest to enable query logging in ProxySQL (see https://proxysql.com/documentation/query-logging/ ) and track down all the queries executed by a client connection that then trigger an error. |
Yep. I'm okay with multiplexing disabled in some places for now and have ideas how we could reduce that, but |
@twotwotwo : you are welcome. |
I realized part of what I'm seeing makes sense from the code--once proxysql/lib/MySQL_Session.cpp Line 1116 in 3117914
I still don't know why the backend didn't pick up the change in my real example, whereas it does if I just force lock_hostgroup before changing autocommit at the CLI. Still interesting for the sake of potential workarounds to know that lock_hostgroup also changes how autocommit is handled. |
Hey @rtnpro are you still operating any ProxySQL instance/cluster for Django applications? are you using any specific set of configurations for ProxySQL to support transactions and SAVEPOINTS properly? |
Keen to get an answer to this as well. Is no one using proxysql with Django in prod? |
After we started using transaction savepoints in business logic, we noticed that RELEASE SAVEPOINT statement began to fail when proxysql is used with error "no savepoint exists". On the other hand, when connecting directly to MySQL (Percona server in our case) all works fine.
Some examination of proxysql' repository gave me a hint that the problem could be possibly workarounded by disabling connection multiplexing, and this actually worked.
But obviously there should be a better solution for this problem.
FYI: all statements are issued from client, no stored procedures are used at all.
The text was updated successfully, but these errors were encountered: