// This can include connections that have closed.
        dirtiers map[*Peer]struct{}
 
+       // Value to twiddle to detect races.
+       race byte
        // Currently being hashed.
        hashing bool
        // The piece state may have changed, and is being synchronized with storage.
 
                if hasDirty {
                        p.Flush() // You can be synchronous here!
                }
+               p.race++
                err := p.Storage().MarkComplete()
                if err != nil {
-                       t.logger.Levelf(log.Error, "error marking piece %v complete: %s", piece, err)
+                       t.slogger().Error("error marking piece complete", "piece", piece, "err", err)
                }
                t.cl.lock()
 
 
 func (t *Torrent) getPieceToHash() (_ g.Option[pieceIndex]) {
        for i := range t.piecesQueuedForHash.Iterate {
-               if t.piece(i).hashing {
+               p := t.piece(i)
+               if p.hashing || p.marking {
                        continue
                }
                return g.Some(i)