Commit 77af4d91 authored by Vivek Naik's avatar Vivek Naik
Browse files

added global lock for lazy write in append bucket

added global lock for lazy write in append  bucket 
parent be84f87a
Branches
Tags
2 merge requests!125Mep release 7 nov,!124segregation of pack operation and fdb operations
Showing with 5 additions and 11 deletions
......@@ -42,6 +42,7 @@ const (
// ErrNoDataFound - This error describes that the required data might be deleted and not found. Kidly ignore this error in caller.
var ErrNoDataFound = errors.New("No data found")
var bucketLock = sync.Mutex{}
// Bucket - Bucket
type Bucket struct {
......@@ -122,10 +123,8 @@ func (fdb *FDB) GetIndexDB(index *Index) (*buntdb.DB, error) {
return db, nil
}
// GetNewBucket - return Bucket Obj
// GetNewBucket - return Bucket Obj with provided data and new guid
func (fdb *FDB) GetNewBucket(BucketNameQuery string, IsDynamicName bool, parentBucket *Bucket) *Bucket {
fdb.bLocker.Lock()
defer fdb.bLocker.Unlock()
bucket := &Bucket{
BucketID: guidmdl.GetGUID(),
BucketNameQuery: BucketNameQuery,
......@@ -143,11 +142,7 @@ func (fdb *FDB) GetNewBucket(BucketNameQuery string, IsDynamicName bool, parentB
func (fdb *FDB) NewBucket(bucket, parentBucket *Bucket) *Bucket {
fdb.bLocker.Lock()
defer fdb.bLocker.Unlock()
// bucket := &Bucket{
// BucketID: guidmdl.GetGUID(),
// BucketNameQuery: BucketNameQuery,
// IsDynamicName: IsDynamicName,
// }
bucketNameQuery := bucket.BucketNameQuery
if bucket.IsDynamicName {
bucketNameQuery = "$$" + bucket.BucketNameQuery
......@@ -315,8 +310,8 @@ func getUpdatedFilePath(filePath string, data gjson.Result) (string, error) {
func AppendDataInLazyObjectInCache(bucketID string, data gjson.Result) error {
// lazy cache must be present for provided bucketID
// loggermdl.LogError("AppendDataInLazyObjectInCache")
mutex := sync.Mutex{}
mutex.Lock()
bucketLock.Lock()
defer bucketLock.Unlock()
lazyObj, ok := AppendLazyObjHolder.Get(bucketID)
if !ok {
loggermdl.LogError(AppendLazyObjHolder.GetItems())
......@@ -360,7 +355,6 @@ func AppendDataInLazyObjectInCache(bucketID string, data gjson.Result) error {
}
AppendLazyObjHolder.SetNoExpiration(bucketID, bucketLazyData)
mutex.Unlock()
return nil
}
......
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment