Skip to content

Commit

Permalink
close EC streams when idle, reopen on demand
Browse files Browse the repository at this point in the history
* gateways: remove open-ec-streams logic from bucket initialization
  (no need)

Co-authored-by: Vladimir Markelov <[email protected]>
Signed-off-by: Alex Aizman <[email protected]>
  • Loading branch information
alex-aizman and VladimirMarkelov committed Sep 11, 2024
1 parent 8fd6845 commit b471cb1
Show file tree
Hide file tree
Showing 7 changed files with 23 additions and 12 deletions.
1 change: 0 additions & 1 deletion ais/prxbck.go
Original file line number Diff line number Diff line change
Expand Up @@ -193,7 +193,6 @@ func (bctx *bctx) initAndTry() (bck *meta.Bck, err error) {
// 1. init bucket
bck = bctx.bck
if ecode, err = bctx.init(); err == nil {
err = bctx.p.onEC(bck)
return
}
if ecode != http.StatusNotFound {
Expand Down
8 changes: 6 additions & 2 deletions ais/prxec.go
Original file line number Diff line number Diff line change
Expand Up @@ -132,7 +132,8 @@ func (p *proxy) _toggleEC(action string) error {
for _, res := range results {
if res.err != nil {
freeBcArgs(args)
return fmt.Errorf("%s: %s failed to %s: %v", p, res.si.StringEx(), action, res.err)
err := fmt.Errorf("%s: %s failed to %s: %v", p, res.si.StringEx(), action, res.err)
return err
}
}

Expand Down Expand Up @@ -163,10 +164,13 @@ func (p *proxy) offEC(last int64) {
}
p.ec.rust = 0

if err := p._toggleEC(apc.ActEcClose); err == nil {
err := p._toggleEC(apc.ActEcClose)
if err == nil {
return
}

nlog.Warningln(err) // benign (see errCloseStreams)

// undo
p._onEC(mono.NanoTime())
}
5 changes: 1 addition & 4 deletions ais/prxs3.go
Original file line number Diff line number Diff line change
Expand Up @@ -712,10 +712,7 @@ func (p *proxy) initByNameOnly(w http.ResponseWriter, r *http.Request, bucket st
s3.WriteErr(w, r, err, ecode)
return nil
}
if err = p.onEC(bck); err != nil {
s3.WriteErr(w, r, err, 0)
return nil
}
debug.Assert(bck != nil)
return bck
}

Expand Down
13 changes: 12 additions & 1 deletion ais/tgtec.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
package ais

import (
"errors"
"fmt"
"net/http"
"os"
Expand All @@ -20,6 +21,8 @@ import (
"github.com/NVIDIA/aistore/hk"
)

var errCloseStreams = errors.New("EC is currently active, cannot close streams")

func (t *target) ecHandler(w http.ResponseWriter, r *http.Request) {
switch r.Method {
case http.MethodGet:
Expand Down Expand Up @@ -87,6 +90,10 @@ func (t *target) httpecpost(w http.ResponseWriter, r *http.Request) {
if !t.ensureIntraControl(w, r, true /* from primary */) {
return
}
if ec.ECM.IsActive() {
t.writeErr(w, r, errCloseStreams)
return
}
nlog.Infoln(t.String(), "hk-postpone", action)
hk.Reg(hkname, closeEc, postpone)
default:
Expand All @@ -95,7 +102,11 @@ func (t *target) httpecpost(w http.ResponseWriter, r *http.Request) {
}

func closeEc(int64) time.Duration {
ec.ECM.CloseStreams(false /*with refc*/)
if ec.ECM.IsActive() {
nlog.Warningln("hk-cb:", errCloseStreams)
} else {
ec.ECM.CloseStreams(false /*with refc*/)
}
return hk.UnregInterval
}

Expand Down
2 changes: 1 addition & 1 deletion cmd/cli/go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ module github.com/NVIDIA/aistore/cmd/cli
go 1.22.3

require (
github.com/NVIDIA/aistore v1.3.24-0.20240909232046-a91636bc334a
github.com/NVIDIA/aistore v1.3.24-0.20240911183340-8fd68450c4bc
github.com/fatih/color v1.17.0
github.com/json-iterator/go v1.1.12
github.com/onsi/ginkgo/v2 v2.20.0
Expand Down
4 changes: 2 additions & 2 deletions cmd/cli/go.sum
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
code.cloudfoundry.org/bytefmt v0.0.0-20190710193110-1eb035ffe2b6/go.mod h1:wN/zk7mhREp/oviagqUXY3EwuHhWyOvAdsn5Y4CzOrc=
github.com/BurntSushi/toml v1.3.2/go.mod h1:CxXYINrC8qIiEnFrOxCa7Jy5BFHlXnUU2pbicEuybxQ=
github.com/NVIDIA/aistore v1.3.24-0.20240909232046-a91636bc334a h1:3pqUBkkTtvMa+6+YqA8o199Wvucqc9uJaAtndLJk2vo=
github.com/NVIDIA/aistore v1.3.24-0.20240909232046-a91636bc334a/go.mod h1:si83S9r29vwIC0f0CE2Mk+25bFiaN6mmVlmuBpP4hHM=
github.com/NVIDIA/aistore v1.3.24-0.20240911183340-8fd68450c4bc h1:EZnKo05NVLt6rDsAzCrjv/nft44uOvDb0LZ41jiqO1E=
github.com/NVIDIA/aistore v1.3.24-0.20240911183340-8fd68450c4bc/go.mod h1:si83S9r29vwIC0f0CE2Mk+25bFiaN6mmVlmuBpP4hHM=
github.com/OneOfOne/xxhash v1.2.8 h1:31czK/TI9sNkxIKfaUfGlU47BAxQ0ztGgd9vPyqimf8=
github.com/OneOfOne/xxhash v1.2.8/go.mod h1:eZbhyaAYD41SGSSsnmcpxVoRiQ/MPUTjUdIIOT9Um7Q=
github.com/VividCortex/ewma v1.1.1/go.mod h1:2Tkkvm3sRDVXaiyucHiACn4cqf7DpdyLvmxzcbUokwA=
Expand Down
2 changes: 1 addition & 1 deletion cmn/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -1681,7 +1681,7 @@ func (c *TimeoutConf) Validate() error {
}
// must be greater than (2 * keepalive.interval*keepalive.factor)
if c.EcStreams > 0 && c.EcStreams.D() < EcStreamsMini {
return fmt.Errorf("invalid timeout.ec_streams_time=%s (never timeout: %v; minimum: %s; default: %s)",
return fmt.Errorf("invalid timeout.ec_streams_time=%s (no timeout: %v; minimum: %s; default: %s)",
c.EcStreams, EcStreamsEver, EcStreamsMini, EcStreamsDflt)
}
return nil
Expand Down

0 comments on commit b471cb1

Please sign in to comment.