[server][file data] Use primary bucket as preferred bucket to read (#6596)
## Description ## Tests
This commit is contained in:
@@ -22,6 +22,7 @@ import (
|
|||||||
"github.com/gin-gonic/gin"
|
"github.com/gin-gonic/gin"
|
||||||
log "github.com/sirupsen/logrus"
|
log "github.com/sirupsen/logrus"
|
||||||
"net/http"
|
"net/http"
|
||||||
|
"strings"
|
||||||
"sync"
|
"sync"
|
||||||
gTime "time"
|
gTime "time"
|
||||||
)
|
)
|
||||||
@@ -264,12 +265,12 @@ func (c *Controller) getS3FileMetadataParallel(ctx *gin.Context, dbRows []fileDa
|
|||||||
|
|
||||||
func (c *Controller) fetchS3FileMetadata(ctx context.Context, row fileData.Row, ctxLogger *log.Entry) (*fileData.S3FileMetadata, error) {
|
func (c *Controller) fetchS3FileMetadata(ctx context.Context, row fileData.Row, ctxLogger *log.Entry) (*fileData.S3FileMetadata, error) {
|
||||||
dc := row.LatestBucket
|
dc := row.LatestBucket
|
||||||
// :todo:neeraj make it configurable to
|
preferredBucket := c.S3Config.GetBucketID(row.Type)
|
||||||
// specify preferred dc to read from
|
// If the current primary bucket is different from the latest bucket where data was written,
|
||||||
// and fallback logic to read from different bucket when we fail to read from preferred dc
|
// check and use the preferred bucket if the data is replicated there.
|
||||||
if dc == "b5" {
|
if !strings.EqualFold(preferredBucket, dc) {
|
||||||
if array.StringInList("b6", row.ReplicatedBuckets) {
|
if array.StringInList(preferredBucket, row.ReplicatedBuckets) {
|
||||||
dc = "b6"
|
dc = preferredBucket
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
opt := _defaultFetchConfig
|
opt := _defaultFetchConfig
|
||||||
|
|||||||
Reference in New Issue
Block a user