diag.DefaultSink is not safe for concurrent use.
Whether we use it with os.File or with a bytes.Buffer,
both targets do not synchronize their writes,
so this leaves room for interleaving of messages.
Making diag.DefaultSink thread-safe is generally desirable,
but is also a requirement for #12438
so that it can run upgrades concurrently
and print warnings as tasks fail.
This makes the result of DefaultSink thread-safe
by adding a mutex around the targeted stdout and stderr.
Note:
As a special case, when stdout and stderr are the same
we want to use the same mutex for them.
This matches the behavior of [os/exec.Cmd][1]
// If Stdout and Stderr are the same writer, and have a type that can
// be compared with ==, at most one goroutine at a time will call Write.
Stdout io.Writer
Stderr io.Writer
[1]: https://pkg.go.dev/os/exec#Cmd
A writer implementation can be anything,
and is not guaranteed to be comparable with `==`.
When that happens, the `==` will panic.
To prevent regressions, we have to handle that case
and treat uncomparable writers as different.
This is also similar to how os/exec does it:
https://cs.opensource.google/go/go/+/refs/tags/go1.20.2:src/os/exec/exec.go;l=475
* about error string: error string should not be capitalized or end with punctuation mark
* apply suggestions from code review
* lint: fix format error and simplify the code
Co-authored-by: Fraser Waters <frassle@gmail.com>
Co-authored-by: Aaron Friel <mayreply@aaronfriel.com>
* Make `async:true` the default for `invoke` calls (#3750)
* Switch away from native grpc impl. (#3728)
* Remove usage of the 'deasync' library from @pulumi/pulumi. (#3752)
* Only retry as long as we get unavailable back. Anything else continues. (#3769)
* Handle all errors for now. (#3781)
* Do not assume --yes was present when using pulumi in non-interactive mode (#3793)
* Upgrade all paths for sdk and pkg to v2
* Backport C# invoke classes and other recent gen changes (#4288)
Adjust C# generation
* Replace IDeployment with a sealed class (#4318)
Replace IDeployment with a sealed class
* .NET: default to args subtype rather than Args.Empty (#4320)
* Adding system namespace for Dotnet code gen
This is required for using Obsolute attributes for deprecations
```
Iam/InstanceProfile.cs(142,10): error CS0246: The type or namespace name 'ObsoleteAttribute' could not be found (are you missing a using directive or an assembly reference?) [/Users/stack72/code/go/src/github.com/pulumi/pulumi-aws/sdk/dotnet/Pulumi.Aws.csproj]
Iam/InstanceProfile.cs(142,10): error CS0246: The type or namespace name 'Obsolete' could not be found (are you missing a using directive or an assembly reference?) [/Users/stack72/code/go/src/github.com/pulumi/pulumi-aws/sdk/dotnet/Pulumi.Aws.csproj]
```
* Fix the nullability of config type properties in C# codegen (#4379)