-
Notifications
You must be signed in to change notification settings - Fork 5.8k
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
An immediate read after two UPDATE transactions does not pick up the change in the other transaction #15716
Comments
@yanmingcao Thanks for your feedback, but I can't reproduce your problem on my computer.
Could you please check your operation again? And if there are still some problems, please |
@qw4990 Thanks for looking into it. The script is not quite correct. The two transactions should be in pessimistic mode: begin pessimistic; -- T1
begin pessimistic; -- T2 By the way, I found something strange about transaction mode. begin optimistic;
select @@tidb_txn_mode; -- Shows "pessimistic"
commit |
@coocood @tiancaiamao PTAL |
@yanmingcao How the queries are executed? (terminal or application) Is it possible that the start time of first |
I use two mysqlsh shells on my Windows laptop. One shell runs T1 and the other shell runs T2. The TiDB environment was set up using T2 has been commited before the last two |
@yanmingcao |
@coocood select * from test; -- T1. Shows 1 => 10
update test set value = 11 where id = 1; -- T2
select * from test; -- T1. Shows 1 => 10 (caching problem?)
select * from test; -- T1. Shows 1 => 11 (correct result)
|
@yanmingcao |
I use However I do see some strange thing about this enviroment. When I run |
@yanmingcao I tested with |
@jackysp PTAL |
@yanmingcao I can not reproduce it by using mysqlsh like |
@yanmingcao |
It seems By the way, in |
Maybe the log file is not the right one?
No, it's not related. |
Can not reproduce +1 Did you use this order? @yanmingcao
|
I wonder why the queries are not logged into tidb.log. Is there any other log?
|
No. I committed two transactions before running the Did you try this on Windows 10? The version of
|
Please post the result of |
|
|
@yanmingcao
|
@yanmingcao
with
And try again |
The result for your request is below:
|
Thank you, please replace the T2
and post the result, along with the T1's result of
|
|
@yanmingcao Now it seems that it has nothing to do with mysqlsh or Windows. Another two things may help address this issue.
Thank you! |
With
|
@yanmingcao |
By the way, please change the previous
on T2, to
|
|
@yanmingcao |
It seems that none of us can reproduce your issue, @yanmingcao . Do you have a WeChat account? If you don't mind, you can send your WeChat account to [email protected] and we can contact on WeChat. |
Sorry @yanmingcao , [email protected] did not previously have permission to receive out-of-company mail. If we missed your contact information, please send it again. Thank you! |
@jackysp I sent email to [email protected] twice. Not sure you got it. |
I've received it. Sorry for the late reply. |
Simple reproduction steps for MacOSX or Linux users:
create table t (i int);
insert into t values (1);
package main
import (
"database/sql"
"log"
_ "github.com/go-sql-driver/mysql"
)
func main() {
connStr := "root@tcp(127.0.0.1:38900)/test?charset=utf8mb4&parseTime=True&loc=Local"
db, err := sql.Open("mysql", connStr)
if err != nil {
log.Fatal(err)
}
defer db.Close()
db2, err := sql.Open("mysql", connStr)
if err != nil {
log.Fatal(err)
}
defer db2.Close()
_, err = db.Exec("-- T1")
if err != nil {
log.Fatal(err)
}
_, err = db2.Exec( "update t set i = i + 1")
if err != nil {
log.Fatal(err)
}
for i := 0; i < 2; i++ {
rows, err := db.Query("select * from t")
if err != nil {
log.Fatal(err)
}
log.Println("time", i)
var r int
for rows.Next() {
if err := rows.Scan(&r); err != nil {
log.Fatal(err)
}
log.Println(r)
}
}
} |
Bug Report
Please answer these questions before submitting your issue. Thanks!
1. What did you do?
I run the following script which consists of two transactions. After both transactions commit, a first SELECT cannot see the UPDATE by the other session. However if I run the same SELECT again, it picks up the UPDATE by the other session.
2. What did you expect to see?
The last two SELECT should return same result.
3. What did you see instead?
The next to last SELECT returns a result that does not reflect the change by T2.
4. What version of TiDB are you using? (
tidb-server -V
or runselect tidb_version();
on TiDB)v3.0.12
The text was updated successfully, but these errors were encountered: