On Tue, Jan 5, 2021, 6:59 PM Nathan Fisher <[email protected]> wrote:

> Does write only locking provide read correctness? I would’ve thought based
> on the memory model it could cause issues?
>
> https://golang.org/ref/mem#tmp_2
>

It depends on your notion of "read correctness", specifically when you
consider each read to have occurred with respect to its concurrent writes.
Linearizability may be a weaker guarantee than you want, and that's okay.

Linearizability requires that, for each operation, you can pick some point
between the start and end of an operation when it can be said to have
"occurred". When you consider all the operations in that order, the results
you see must be the same as a sequential execution.

In the case I have described, we can pick a linearization point for reads
just before the last write which they passed on their way down the tree.
The reads should then see all the writes which happened prior to this point.

This isn't the order the operations enter the root, but linearizability
doesn't care. It doesn't have an opinion on when overlapping operations
"occur" with respect to one another.

I don't think using a happens-before relation for the program order seen by
each goroutine is going to cause a problem with respect to choosing these
linearization points, but maybe I'm missing something.

Maybe also there is a standardized notion of read correctness that you're
referring to which I am not aware of.

-- 
You received this message because you are subscribed to the Google Groups 
"golang-nuts" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/golang-nuts/CALJzkY-RdyWhJcWFPyXQ7aUvfLSfefFqZQtsM-h9oKaPAymP9w%40mail.gmail.com.

Reply via email to