MCPcopy Create free account
hub / github.com/couchbase/sync_gateway / releaseSequence

Method releaseSequence

db/sequence_allocator.go:402–413  ·  view source on GitHub ↗

ReleaseSequence writes an unused sequence document, used to notify sequence buffering that a sequence has been allocated and not used. Sequence is stored as the document body to avoid null doc issues.

(ctx context.Context, sequence uint64)

Source from the content-addressed store, hash-verified

400// ReleaseSequence writes an unused sequence document, used to notify sequence buffering that a sequence has been allocated and not used.
401// Sequence is stored as the document body to avoid null doc issues.
402func (s *sequenceAllocator) releaseSequence(ctx context.Context, sequence uint64) error {
403 key := fmt.Sprintf("%s%d", s.metaKeys.UnusedSeqPrefix(), sequence)
404 body := make([]byte, 8)
405 binary.LittleEndian.PutUint64(body, sequence)
406 _, err := s.datastore.AddRaw(key, UnusedSequenceTTL, body)
407 if err != nil {
408 return err
409 }
410 s.dbStats.SequenceReleasedCount.Add(1)
411 base.DebugfCtx(ctx, base.KeyCRUD, "Released unused sequence #%d", sequence)
412 return nil
413}
414
415// releaseSequenceRange writes a binary document with the key _sync:unusedSeqs:fromSeq:toSeq.
416// fromSeq and toSeq are inclusive (i.e. both fromSeq and toSeq are unused).

Callers 5

releaseSequencesMethod · 0.80
UpdatePrincipalMethod · 0.80
ReleaseTestSequenceFunction · 0.80
assignSequenceMethod · 0.80
updateAndReturnDocMethod · 0.80

Calls 4

DebugfCtxFunction · 0.92
UnusedSeqPrefixMethod · 0.80
AddRawMethod · 0.45
AddMethod · 0.45

Tested by

no test coverage detected