You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Currently the jsonrpc server provides support for request batching automatically. But, those requests are all processed in parallel with no atomicity guarantees between them. So, one response might be as of ledger x, and another could be as of ledger x+1.
What would you like to see?
We should use a single database transaction for a batch.
This means we need to:
Change the jsonrpc server to so that we can detect batches instead of having them handled automatically (I assume, check the docs).
Refactor the database transaction system so we can use a transaction for a whole batch. In the past I've done this with something roughly like:
typeDBinterface {
// Standard db methods and stuffExec(ctx context.Context, querystring, ...argsinterface{}) error
io.Closer// etc// Execute some code in a transactionTransaction(fnfunc(dbDB) error) error
}
func (d*sqliteDB) Transaction(fnfunc(dbDB) error) error {
tx:=txWrapper{d.BeginTx()}
err:=fn(tx)
iferr==nil {
tx.Commit()
} else {
tx.Rollback()
}
returnerr
}
// txWrapper implements the DB interfacetypetxWrapperstruct {
*Transaction
}
// Standard db methods implemented on txWrapper// func (tx *txWrapper) Exec(ctx context.Context, query string, ...args interface{}) error // etcfunc (tx*txWrapper) Transaction(fn (dDB) error) error {
// We are already in a transaction, no-op.returnfn(tx)
}
funcmain() {
conn:= sqlite.Open(...)
conn.Transaction(func(dbDB) error {
// This code now is in a transaction, but it doesn't know that.returndb.Transaction(func(dbDB) error {
// It can nest transactions, but this will still only open a single transaction with the database.
})
})
}
What alternatives are there?
Don't do it, and tell users there is not atomicity within batches.
The text was updated successfully, but these errors were encountered:
What problem does your feature solve?
See discussion in #48
Currently the jsonrpc server provides support for request batching automatically. But, those requests are all processed in parallel with no atomicity guarantees between them. So, one response might be as of ledger x, and another could be as of ledger x+1.
What would you like to see?
We should use a single database transaction for a batch.
This means we need to:
What alternatives are there?
Don't do it, and tell users there is not atomicity within batches.
The text was updated successfully, but these errors were encountered: