mirror of
https://github.com/matrix-org/dendrite.git
synced 2026-01-16 18:43:10 -06:00
Return to a working state hopefully
This commit is contained in:
parent
a15ce36f35
commit
123bc72c0c
|
|
@ -56,22 +56,30 @@ type Database struct {
|
||||||
}
|
}
|
||||||
|
|
||||||
func (d *Database) NewDatabaseSnapshot(ctx context.Context) (*DatabaseTransaction, error) {
|
func (d *Database) NewDatabaseSnapshot(ctx context.Context) (*DatabaseTransaction, error) {
|
||||||
txn, err := d.DB.BeginTx(ctx, &sql.TxOptions{
|
return d.NewDatabaseTransaction(ctx)
|
||||||
// Set the isolation level so that we see a snapshot of the database.
|
|
||||||
// In PostgreSQL repeatable read transactions will see a snapshot taken
|
/*
|
||||||
// at the first query, and since the transaction is read-only it can't
|
TODO: Repeatable read is probably the right thing to do here,
|
||||||
// run into any serialisation errors.
|
but it seems to cause some problems with the invite tests, so
|
||||||
// https://www.postgresql.org/docs/9.5/static/transaction-iso.html#XACT-REPEATABLE-READ
|
need to investigate that further.
|
||||||
Isolation: sql.LevelRepeatableRead,
|
|
||||||
ReadOnly: true,
|
txn, err := d.DB.BeginTx(ctx, &sql.TxOptions{
|
||||||
})
|
// Set the isolation level so that we see a snapshot of the database.
|
||||||
if err != nil {
|
// In PostgreSQL repeatable read transactions will see a snapshot taken
|
||||||
return nil, err
|
// at the first query, and since the transaction is read-only it can't
|
||||||
}
|
// run into any serialisation errors.
|
||||||
return &DatabaseTransaction{
|
// https://www.postgresql.org/docs/9.5/static/transaction-iso.html#XACT-REPEATABLE-READ
|
||||||
Database: d,
|
Isolation: sql.LevelRepeatableRead,
|
||||||
txn: txn,
|
ReadOnly: true,
|
||||||
}, nil
|
})
|
||||||
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
return &DatabaseTransaction{
|
||||||
|
Database: d,
|
||||||
|
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