Skip to content

Commit

Permalink
Adding log statements for hung keynode
Browse files Browse the repository at this point in the history
  • Loading branch information
saurav-c committed Apr 24, 2021
1 parent 36eedbf commit 4d39722
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 0 deletions.
4 changes: 4 additions & 0 deletions cmd/keynode/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -164,11 +164,14 @@ func (k *KeyNode) validate(tid string, beginTs int64, commitTs int64, keys []str
}

func (k *KeyNode) checkPendingConflicts(beginTs int64, commitTs int64, keys []string, reportChan chan bool) {
log.Infof("Inside check pending conflicts")
for _, key := range keys {
log.Infof("Checking conflict for %s", key)
k.PendingVersionIndex.mutex.RLock()
pLock, ok := k.PendingVersionIndex.locks[key]

if !ok {
log.Info("Pending KVI does not exist")
k.PendingVersionIndex.mutex.RUnlock()
pLock, _ = k.PendingVersionIndex.create(key, k.StorageManager)
k.PendingVersionIndex.mutex.RLock()
Expand All @@ -178,6 +181,7 @@ func (k *KeyNode) checkPendingConflicts(beginTs int64, commitTs int64, keys []st
pendingVersions := k.PendingVersionIndex.index[key]
k.PendingVersionIndex.mutex.RUnlock()

log.Info("Got the pending versions")
for _, versions := range pendingVersions.Versions {
split := strings.Split(versions, cmn.VersionDelimeter)
versionCommitTsStr := split[0]
Expand Down
5 changes: 5 additions & 0 deletions cmd/keynode/util.go
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,9 @@ PRE: KeyLock should be LOCKED
POST: Returns TRUE if index found in storage and updates index
*/
func (idx *VersionIndex) readFromStorage(key string, storageManager storage.StorageManager) (*kpb.KeyVersionList, bool) {
log.Infof("Trying to read index %s from storage", key)
data, err := storageManager.Get(fmt.Sprintf(idx.indexFormat, key))
log.Infof("Read index %s from storage", key)
if err != nil {
if strings.Contains(err.Error(), "KEY_DNE") {
return nil, false
Expand Down Expand Up @@ -143,6 +145,7 @@ Pre: No locks required
Post: Returns key lock and key version list
*/
func (idx *VersionIndex) create(key string, storageManager storage.StorageManager) (*sync.RWMutex, *kpb.KeyVersionList) {
log.Infof("Creating key version state for %s", key)
idx.mutex.Lock()

var keyLock *sync.RWMutex
Expand All @@ -156,9 +159,11 @@ func (idx *VersionIndex) create(key string, storageManager storage.StorageManage
idx.mutex.Unlock()

// Check storage if index exists
log.Infof("Fetching from storage")
if storageVersionList, ok := idx.readFromStorage(key, storageManager); ok {
versionList = storageVersionList
}
log.Infof("Returned fetch from storage")
keyLock.Unlock()
} else {
keyLock = kLock
Expand Down

0 comments on commit 4d39722

Please sign in to comment.