harshilv17 commented on code in PR #2732:
URL: https://github.com/apache/iceberg-go/pull/2732#discussion_r4725545530


##########
table/transaction.go:
##########
@@ -2745,7 +2745,17 @@ func (t *Transaction) Scan(opts ...ScanOption) (*Scan, 
error) {
 }
 
 func (t *Transaction) StagedTable() (*StagedTable, error) {
+       if err := t.checkNotNil(); err != nil {
+               return nil, err
+       }
+       // apply swaps t.meta under t.mx, so copy the builder under the lock and
+       // build the staged view from the copy.
+       t.mx.Lock()
        meta, err := t.txnMeta()
+       if err == nil {
+               meta = meta.clone()
+       }
+       t.mx.Unlock()

Review Comment:
   Done in a0236625: `StagedTable` now reads `t.tbl` under `t.mx` along with 
the builder copy. Added 
`TestTransactionStagedTableConcurrentWithExpireSnapshots` (n=3000), which 
reports a race under `-race` with the old reads and passes with the change.
   



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to