My understanding of the REPEATABLE READ
transaction isolation level is that once it is set, the data read through in the transaction will not change. I have used the following code to verify this:
ctx = context.Background()
tx, _ := db.BeginTx(ctx, &sql.TxOptions{Isolation: sql.LevelSerializable})
time.Sleep(5 * time.Second)
// do query on tx
While the process is sleeping, I have inserted another record through the console. But the newly inserted record has appeared in the results. Why is that so? I don't want to read the records which are inserted after the transaction has begun. I also tried:
tx, _ := db.Begin()
_, err = tx.Exec(`set transaction isolation level repeatable read;`)
But still the results are the same.