mirror of
https://github.com/hoernschen/dendrite.git
synced 2024-12-28 16:08:27 +00:00
Repeatable reads for /sync
(#2783)
This puts repeatable reads into all sync streams. Co-authored-by: kegsay <kegan@matrix.org>
This commit is contained in:
parent
ded43e0f2d
commit
ba2ffb7da9
1 changed files with 17 additions and 25 deletions
|
@ -57,31 +57,23 @@ type Database struct {
|
||||||
}
|
}
|
||||||
|
|
||||||
func (d *Database) NewDatabaseSnapshot(ctx context.Context) (*DatabaseTransaction, error) {
|
func (d *Database) NewDatabaseSnapshot(ctx context.Context) (*DatabaseTransaction, error) {
|
||||||
return d.NewDatabaseTransaction(ctx)
|
txn, err := d.DB.BeginTx(ctx, &sql.TxOptions{
|
||||||
|
// Set the isolation level so that we see a snapshot of the database.
|
||||||
/*
|
// In PostgreSQL repeatable read transactions will see a snapshot taken
|
||||||
TODO: Repeatable read is probably the right thing to do here,
|
// at the first query, and since the transaction is read-only it can't
|
||||||
but it seems to cause some problems with the invite tests, so
|
// run into any serialisation errors.
|
||||||
need to investigate that further.
|
// https://www.postgresql.org/docs/9.5/static/transaction-iso.html#XACT-REPEATABLE-READ
|
||||||
|
Isolation: sql.LevelRepeatableRead,
|
||||||
txn, err := d.DB.BeginTx(ctx, &sql.TxOptions{
|
ReadOnly: true,
|
||||||
// Set the isolation level so that we see a snapshot of the database.
|
})
|
||||||
// In PostgreSQL repeatable read transactions will see a snapshot taken
|
if err != nil {
|
||||||
// at the first query, and since the transaction is read-only it can't
|
return nil, err
|
||||||
// run into any serialisation errors.
|
}
|
||||||
// https://www.postgresql.org/docs/9.5/static/transaction-iso.html#XACT-REPEATABLE-READ
|
return &DatabaseTransaction{
|
||||||
Isolation: sql.LevelRepeatableRead,
|
Database: d,
|
||||||
ReadOnly: true,
|
ctx: ctx,
|
||||||
})
|
txn: txn,
|
||||||
if err != nil {
|
}, nil
|
||||||
return nil, err
|
|
||||||
}
|
|
||||||
return &DatabaseTransaction{
|
|
||||||
Database: d,
|
|
||||||
ctx: ctx,
|
|
||||||
txn: txn,
|
|
||||||
}, nil
|
|
||||||
*/
|
|
||||||
}
|
}
|
||||||
|
|
||||||
func (d *Database) NewDatabaseTransaction(ctx context.Context) (*DatabaseTransaction, error) {
|
func (d *Database) NewDatabaseTransaction(ctx context.Context) (*DatabaseTransaction, error) {
|
||||||
|
|
Loading…
Reference in a new issue