Skip to content

Commit

Permalink
debug logs
Browse files Browse the repository at this point in the history
  • Loading branch information
nirav24 committed Jan 12, 2023
1 parent 733584f commit cca6101
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 3 deletions.
2 changes: 1 addition & 1 deletion db/background_mgr_resync_dcp.go
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,7 @@ func (r *ResyncManagerDCP) Run(ctx context.Context, options map[string]interface
var err error
docID := string(event.Key)
key := realDocID(docID)
base.TracefCtx(ctx, base.KeyAll, "[%s] Received DCP event %d for doc %v", resyncLoggingID, event.Opcode, base.UD(docID))
base.DebugfCtx(ctx, base.KeyAll, "[%s] Received DCP event %d for doc %v", resyncLoggingID, event.Opcode, base.UD(docID))
// Don't want to process raw binary docs
// The binary check should suffice but for additional safety also check for empty bodies
if event.DataType == base.MemcachedDataTypeRaw || len(event.Value) == 0 {
Expand Down
2 changes: 1 addition & 1 deletion db/background_mgr_resync_dcp_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -314,7 +314,7 @@ func TestResyncManagerDCPRunTwice(t *testing.T) {
assert.Equal(t, db.DbStats.Database().SyncFunctionCount.Value(), int64(docsToCreate))
}

func TestResycnManagerDCPResumeStoppedProcess(t *testing.T) {
func TestResyncManagerDCPResumeStoppedProcess(t *testing.T) {
if base.UnitTestUrlIsWalrus() {
t.Skip("Test requires Couchbase Server")
}
Expand Down
11 changes: 10 additions & 1 deletion db/util_testing.go
Original file line number Diff line number Diff line change
Expand Up @@ -182,6 +182,8 @@ func WaitForUserWaiterChange(userWaiter *ChangeWaiter) bool {

// emptyAllDocsIndex ensures the AllDocs index for the given bucket is empty. Works similarly to db.Compact, except on a different index and without a DatabaseContext
func emptyAllDocsIndex(ctx context.Context, dataStore sgbucket.DataStore, tbp *base.TestBucketPool) (numCompacted int, err error) {
base.InfofCtx(ctx, base.KeyAll, "emptyAllDocsIndex called")

purgedDocCount := 0
purgeBody := Body{"_purged": true}

Expand All @@ -197,6 +199,7 @@ WHERE META(ks).xattrs._sync.sequence >= 0
AND META(ks).xattrs._sync.sequence < 9223372036854775807
AND META(ks).id NOT LIKE '\\_sync:%'`
results, err := n1qlStore.Query(statement, nil, base.RequestPlus, true)
base.InfofCtx(ctx, base.KeyAll, "emptyAllDocsIndex failed to remove allDocsIndex %+v", err)
if err != nil {
return 0, err
}
Expand Down Expand Up @@ -227,11 +230,13 @@ WHERE META(ks).xattrs._sync.sequence >= 0
}
}
err = results.Close()
base.InfofCtx(ctx, base.KeyAll, "emptyAllDocsIndex results.Close %+v", err)

if err != nil {
return 0, err
}

tbp.Logf(ctx, "Finished compaction ... Total docs purged: %d", purgedDocCount)
base.InfofCtx(ctx, base.KeyAll, "Finished compaction ... Total docs purged: %d", purgedDocCount)
return purgedDocCount, nil
}

Expand All @@ -258,6 +263,8 @@ var viewsAndGSIBucketReadier base.TBPBucketReadierFunc = func(ctx context.Contex
for _, dataStoreName := range dataStores {
dataStore := b.NamedDataStore(dataStoreName)
if _, err := emptyAllDocsIndex(ctx, dataStore, tbp); err != nil {
base.InfofCtx(ctx, base.KeyAll, "emptyAllDocsIndex error %+v", err)

return err
}

Expand All @@ -266,6 +273,8 @@ var viewsAndGSIBucketReadier base.TBPBucketReadierFunc = func(ctx context.Contex
return errors.New("attempting to empty indexes with non-N1QL store")
}
tbp.Logf(ctx, "waiting for empty bucket indexes")
base.InfofCtx(ctx, base.KeyAll, "waiting for empty bucket indexes")
// we can't init indexes concurrently, so we'll just wait for them to be empty after emptying instead of recreating.
// we can't init indexes concurrently, so we'll just wait for them to be empty after emptying instead of recreating.
if err := WaitForIndexEmpty(n1qlStore, base.TestUseXattrs()); err != nil {
tbp.Logf(ctx, "WaitForIndexEmpty returned an error: %v", err)
Expand Down

0 comments on commit cca6101

Please sign in to comment.