Commit a55a9258 authored by Kirill Smelkov's avatar Kirill Smelkov

.

parent 0d6b8ad3
...@@ -349,20 +349,33 @@ func (db *DB) Open(ctx context.Context, opt *ConnOptions) (_ *Connection, err er ...@@ -349,20 +349,33 @@ func (db *DB) Open(ctx context.Context, opt *ConnOptions) (_ *Connection, err er
return conn, nil return conn, nil
} }
// Resync resyncs the connection onto different database view. // Resync resyncs the connection onto different database view and transaction.
// //
// XXX previous conn's txn must be already complete. // Connection objects pinned in live cache are guaranteed to stay in live
// XXX must be run under transaction. // cache, even if maybe in ghost state (e.g. if they have to be invalidated due
// XXX objects are guaranteed to stay in live cache, even if in ghost state. // to database changes).
// XXX Resync allowed only for connections opened with NoPool flag. //
// XXX contrary to DB.Open at cannot be 0. // Resync can be used several times.
// XXX new at can be both higher and lower than previous at. //
func (conn *Connection) Resync(ctx context.Context, at Tid) { // Resync must be used only under the following conditions:
// XXX assert conn.noPool == true //
// XXX assert conn.txn == nil // - the connection was initially opened with NoPool flag.
// XXX assert at != 0 // - previous transaction, under which connection was previously
// opened/resynced, must be already complete.
// - contrary to DB.Open, at cannot be 0.
//
// Note: new at can be both higher and lower than previous connection at.
func (conn *Connection) Resync(txn transaction.Transaction, at Tid) {
if !conn.noPool {
panic("Conn.Resync: connection was opened without NoPool flag")
}
if conn.txn != nil {
panic("Conn.Resync: previous transaction is not yet complete")
}
if at == 0 {
panic("Conn.Resync: resync to at=0 (auto-mode is valid only for DB.Open)")
}
// XXX conn.cache.Lock ? - yes (e.g. if user also checks it from outside, right?) // XXX conn.cache.Lock ? - yes (e.g. if user also checks it from outside, right?)
txn := transaction.Current(ctx)
db := conn.db db := conn.db
db.mu.Lock() db.mu.Lock()
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment