Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Chore(raft): Add debug logs to print all transactions #8890

Merged
merged 12 commits into from
Jul 17, 2023
Merged
Show file tree
Hide file tree
Changes from 9 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions posting/list.go
Original file line number Diff line number Diff line change
Expand Up @@ -524,6 +524,8 @@ func (l *List) addMutationInternal(ctx context.Context, txn *Txn, t *pb.Directed
hex.EncodeToString(l.key), mpost)
}

x.PrintMutationEdge(t, pk, txn.StartTs)

// We ensure that commit marks are applied to posting lists in the right
// order. We can do so by proposing them in the same order as received by the Oracle delta
// stream from Zero, instead of in goroutines.
Expand Down Expand Up @@ -897,6 +899,7 @@ func (l *List) Rollup(alloc *z.Allocator, readTs uint64) ([]*bpb.KV, error) {
return bytes.Compare(kvs[i].Key, kvs[j].Key) <= 0
})

x.PrintRollup(out.plist, out.parts, l.key, kv.Version)
x.VerifyPostingSplits(kvs, out.plist, out.parts, l.key)
return kvs, nil
}
Expand Down
1 change: 1 addition & 0 deletions worker/draft.go
Original file line number Diff line number Diff line change
Expand Up @@ -812,6 +812,7 @@ func (n *node) processApplyCh() {

// TODO(Anurag - 4 May 2020): Are we using pkey? Remove if unused.
func (n *node) commitOrAbort(pkey uint64, delta *pb.OracleDelta) error {
x.PrintOracleDelta(delta)
// First let's commit all mutations to disk.
writer := posting.NewTxnWriter(pstore)
toDisk := func(start, commit uint64) {
Expand Down
16 changes: 16 additions & 0 deletions x/debug.go
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,24 @@ import (
"github.com/dgraph-io/badger/v4"
bpb "github.com/dgraph-io/badger/v4/pb"
"github.com/dgraph-io/dgraph/protos/pb"
"github.com/golang/glog"
harshil-goel marked this conversation as resolved.
Show resolved Hide resolved
)

func PrintRollup(plist *pb.PostingList, parts map[uint64]*pb.PostingList, baseKey []byte, ts uint64) {
k, _ := Parse(baseKey)
glog.V(2).Infof("[TXNLOG] DOING ROLLUP for key: %+v at timestamp: %v\n", k, ts)
harshil-goel marked this conversation as resolved.
Show resolved Hide resolved
}

func PrintMutationEdge(plist *pb.DirectedEdge, key ParsedKey, startTs uint64) {
glog.V(2).Infof("[TXNLOG] ADDING MUTATION at TS: %v, key: %v, value: %v \n", startTs, key.String(), plist)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

don't need the space and \n at the end

}

func PrintOracleDelta(delta *pb.OracleDelta) {
for _, status := range delta.Txns {
glog.V(2).Infof("[TXNLOG] COMMITING: startTs: %v, commitTs: %v\n", status.StartTs, status.CommitTs)
harshil-goel marked this conversation as resolved.
Show resolved Hide resolved
}
}

// VerifyPack checks that the Pack should not be nil if the postings exist.
func VerifyPack(plist *pb.PostingList) {
if plist.Pack == nil && len(plist.Postings) > 0 {
Expand Down
11 changes: 11 additions & 0 deletions x/keys.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ package x
import (
"encoding/binary"
"encoding/hex"
"fmt"
"math"
"strconv"
"strings"
Expand Down Expand Up @@ -300,6 +301,16 @@ type ParsedKey struct {
bytePrefix byte
}

func (p ParsedKey) String() string {
if p.IsIndex() {
return fmt.Sprintf("UID: %v, Attr: %v, IsIndex: true, Term: %v", p.Uid, p.Attr, p.Count)
} else if p.IsCountOrCountRev() {
return fmt.Sprintf("UID: %v, Attr: %v, IsCount/Ref: true, Count: %v", p.Uid, p.Attr, p.Count)
} else {
return fmt.Sprintf("UID: %v, Attr: %v, Data key", p.Uid, p.Attr)
}
}

// IsData returns whether the key is a data key.
func (p ParsedKey) IsData() bool {
return (p.bytePrefix == DefaultPrefix || p.bytePrefix == ByteSplit) && p.ByteType == ByteData
Expand Down
12 changes: 12 additions & 0 deletions x/nodebug.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,18 @@ import (
"github.com/dgraph-io/dgraph/protos/pb"
)

// PrintRollup prints information about any rollup that happen
func PrintRollup(plist *pb.PostingList, parts map[uint64]*pb.PostingList, baseKey []byte, ts uint64) {
}

// PrintMutationEdge prints all edges that are being inserted into badger
func PrintMutationEdge(plist *pb.DirectedEdge, key ParsedKey, startTs uint64) {
}

// PrintOracleDelta prints all delta proposals that are commited
func PrintOracleDelta(delta *pb.OracleDelta) {
}

// VerifyPack works in debug mode. Check out the comment in debug_on.go
func VerifyPack(plist *pb.PostingList) {
}
Expand Down