Increase initial timeout val for b2 dc
This commit is contained in:
parent
08555954d2
commit
51138e9263
|
@ -32,16 +32,18 @@ import (
|
||||||
const (
|
const (
|
||||||
// maxEmbeddingDataSize is the min size of an embedding object in bytes
|
// maxEmbeddingDataSize is the min size of an embedding object in bytes
|
||||||
minEmbeddingDataSize = 2048
|
minEmbeddingDataSize = 2048
|
||||||
embeddingFetchTimeout = 15 * gTime.Second
|
embeddingFetchTimeout = 10 * gTime.Second
|
||||||
)
|
)
|
||||||
|
|
||||||
// _fetchConfig is the configuration for the fetching objects from S3
|
// _fetchConfig is the configuration for the fetching objects from S3
|
||||||
type _fetchConfig struct {
|
type _fetchConfig struct {
|
||||||
RetryCount int
|
RetryCount int
|
||||||
FetchTimeOut gTime.Duration
|
InitialTimeout gTime.Duration
|
||||||
|
MaxTimeout gTime.Duration
|
||||||
}
|
}
|
||||||
|
|
||||||
var _defaultFetchConfig = _fetchConfig{RetryCount: 3, FetchTimeOut: 15 * gTime.Second}
|
var _defaultFetchConfig = _fetchConfig{RetryCount: 3, InitialTimeout: 5 * gTime.Second, MaxTimeout: 30 * gTime.Second}
|
||||||
|
var _b2FetchConfig = _fetchConfig{RetryCount: 3, InitialTimeout: 15 * gTime.Second, MaxTimeout: 30 * gTime.Second}
|
||||||
|
|
||||||
type Controller struct {
|
type Controller struct {
|
||||||
Repo *embedding.Repository
|
Repo *embedding.Repository
|
||||||
|
@ -333,11 +335,20 @@ func (c *Controller) getEmbeddingObjectsParallelV2(userID int64, dbEmbeddingRows
|
||||||
|
|
||||||
func (c *Controller) getEmbeddingObject(ctx context.Context, objectKey string, dc string) (ente.EmbeddingObject, error) {
|
func (c *Controller) getEmbeddingObject(ctx context.Context, objectKey string, dc string) (ente.EmbeddingObject, error) {
|
||||||
opt := _defaultFetchConfig
|
opt := _defaultFetchConfig
|
||||||
|
if dc == c.S3Config.GetHotBackblazeDC() {
|
||||||
|
opt = _b2FetchConfig
|
||||||
|
}
|
||||||
ctxLogger := log.WithField("objectKey", objectKey)
|
ctxLogger := log.WithField("objectKey", objectKey)
|
||||||
totalAttempts := opt.RetryCount + 1
|
totalAttempts := opt.RetryCount + 1
|
||||||
|
timeout := opt.InitialTimeout
|
||||||
for i := 0; i < totalAttempts; i++ {
|
for i := 0; i < totalAttempts; i++ {
|
||||||
// Create a new context with a timeout for each fetch
|
if i > 0 {
|
||||||
fetchCtx, cancel := context.WithTimeout(ctx, opt.FetchTimeOut)
|
timeout = timeout * 2
|
||||||
|
if timeout > opt.MaxTimeout {
|
||||||
|
timeout = opt.MaxTimeout
|
||||||
|
}
|
||||||
|
}
|
||||||
|
fetchCtx, cancel := context.WithTimeout(ctx, timeout)
|
||||||
select {
|
select {
|
||||||
case <-ctx.Done():
|
case <-ctx.Done():
|
||||||
cancel()
|
cancel()
|
||||||
|
|
Loading…
Reference in a new issue