laskoviymishka commented on code in PR #2732:
URL: https://github.com/apache/iceberg-go/pull/2732#discussion_r4723145075
##########
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:
Could we also read the `t.tbl` fields before `t.mx.Unlock()`?
`ExpireSnapshotsWithContext` writes `t.tbl = base` under the lock
([transaction.go#L880](https://github.com/apache/iceberg-go/blob/1375f861426cd475b1a63c6fd42e0af2dda603a3/table/transaction.go#L880)),
and the reads below run after it's released. `main` has the same race, so this
PR doesn't make it worse. A copy of the new test with `ExpireSnapshots()` in
place of `SetProperties` and n=3000 reports a race under `-race`: write at
L880, read at L2774.
--
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]