Uploaded image for project: 'Couchbase Gateway'
  1. Couchbase Gateway
  2. CBG-2060

[3.0.1 Backport] Compaction w/ import and xattrs enabled can panic

    XMLWordPrintable

Details

    • Bug
    • Resolution: Fixed
    • Major
    • 3.0.1
    • 3.0
    • SyncGateway
    • Security Level: Public
    • None
    • 1

    Description

      I've got a unit test that reproduces this consistently, though have struggled to reproduce it "in the wild":

      func TestImportCompactPanic(t *testing.T) {
      	if !base.TestUseXattrs() {
      		t.Skip("requires xattrs")
      	}
      	// Set the compaction and metadata purge interval unrealistically low to reproduce faster
      	options := DatabaseContextOptions{
      		CompactInterval: 1,
      	}
      	AddOptionsFromEnvironmentVariables(&options)
      	bucket := base.GetTestBucket(t)
      	dbc, err := NewDatabaseContext("db", bucket, true, options)
      	require.NoError(t, err, "Couldn't create context for database 'db'")
      	dbc.PurgeInterval = time.Millisecond
      	db, err := CreateDatabase(dbc)
      	require.NoError(t, err, "Couldn't create database 'db'")
       
      	// Create a document, then delete it
      	rev, doc, err := db.Put("test", Body{})
      	require.NoError(t, err)
      	_, err = db.DeleteDoc(doc.ID, rev)
      	require.NoError(t, err)
       
      	waitForBGTCompletion(BGTCompletionMaxWait, db.backgroundTasks, db.Name)
      }
      

      This fails with:

      2022/05/04 15:41:11 Unexpected panic: runtime error: invalid memory address or nil pointer dereference - stopping process
      goroutine 1750 [running]:
      runtime/debug.Stack()
      	/Users/marks.polakovs@couchbase.com/sdk/go1.17.9/src/runtime/debug/stack.go:24 +0x65
      github.com/couchbase/sync_gateway/base.FatalPanicHandler()
      	/Users/marks.polakovs@couchbase.com/code/sync_gateway_3.0.1/godeps/src/github.com/couchbase/sync_gateway/base/util.go:1476 +0x49
      panic({0x1b2ef60, 0x26cfc90})
      	/Users/marks.polakovs@couchbase.com/sdk/go1.17.9/src/runtime/panic.go:1038 +0x215
      github.com/couchbase/sync_gateway/base.(*SafeTerminator).Done(...)
      	/Users/marks.polakovs@couchbase.com/code/sync_gateway_3.0.1/godeps/src/github.com/couchbase/sync_gateway/base/util.go:1280
      github.com/couchbase/sync_gateway/db.(*Database).Compact(0xc002c903c0, 0x0, 0x1d62450, 0x0)
      	/Users/marks.polakovs@couchbase.com/code/sync_gateway_3.0.1/godeps/src/github.com/couchbase/sync_gateway/db/database.go:1163 +0x783
      github.com/couchbase/sync_gateway/db.NewDatabaseContext.func10({0x1eaf300, 0xc002c90c30})
      	/Users/marks.polakovs@couchbase.com/code/sync_gateway_3.0.1/godeps/src/github.com/couchbase/sync_gateway/db/database.go:548 +0x85
      github.com/couchbase/sync_gateway/db.NewBackgroundTask.func1()
      	/Users/marks.polakovs@couchbase.com/code/sync_gateway_3.0.1/godeps/src/github.com/couchbase/sync_gateway/db/utils.go:46 +0x237
      created by github.com/couchbase/sync_gateway/db.NewBackgroundTask
      	/Users/marks.polakovs@couchbase.com/code/sync_gateway_3.0.1/godeps/src/github.com/couchbase/sync_gateway/db/utils.go:37 +0x331
      

      Attachments

        Issue Links

          Activity

            People

              marks.polakovs Marks Polakovs (Inactive)
              ben.brooks Ben Brooks
              Votes:
              0 Vote for this issue
              Watchers:
              2 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved:

                PagerDuty