Preserve maintenance timeout behavior and prepare SILO 20261026

Signed-off-by: Feng Ruohang <rh@vonng.com>
This commit is contained in:
Feng Ruohang
2026-10-26 22:43:51 +08:00
parent a13efd5760
commit dcc2f20ba8
34 changed files with 634 additions and 969 deletions
+2 -14
View File
@@ -59,16 +59,6 @@ type Response struct {
Err error
}
type withoutDefaultTimeoutKey struct{}
// WithoutDefaultTimeout disables the implicit single-request timeout.
// Explicit context cancellation and connection loss still end the request.
// Use this for admitted mutations that must return their actual result before
// the caller releases its lock.
func WithoutDefaultTimeout(ctx context.Context) context.Context {
return context.WithValue(ctx, withoutDefaultTimeoutKey{}, true)
}
func newMuxClient(ctx context.Context, muxID uint64, parent *Connection) *muxClient {
ctx, cancelFn := context.WithCancelCause(ctx)
return &muxClient{
@@ -111,10 +101,8 @@ func (m *muxClient) roundtrip(h HandlerID, req []byte) ([]byte, error) {
m.respMu.Unlock()
ctx := m.ctx
// Admitted storage mutations must not time out while the handler can
// still commit. A zero wire deadline also keeps their late response.
noDefaultTimeout, _ := ctx.Value(withoutDefaultTimeoutKey{}).(bool)
if msg.DeadlineMS == 0 && !noDefaultTimeout {
// Add deadline if none.
if msg.DeadlineMS == 0 {
msg.DeadlineMS = uint32(defaultSingleRequestTimeout / time.Millisecond)
var cancel context.CancelFunc
ctx, cancel = context.WithTimeout(ctx, defaultSingleRequestTimeout)