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 5 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
1 change: 1 addition & 0 deletions posting/list.go
Original file line number Diff line number Diff line change
Expand Up @@ -897,6 +897,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
2 changes: 2 additions & 0 deletions worker/draft.go
Original file line number Diff line number Diff line change
Expand Up @@ -490,6 +490,7 @@ func (n *node) applyMutations(ctx context.Context, proposal *pb.Proposal) (rerr
}

m := proposal.Mutations
x.PrintMutationProposal(m)

// It is possible that the user gives us multiple versions of the same edge, one with no facets
// and another with facets. In that case, use stable sort to maintain the ordering given to us
Expand Down Expand Up @@ -812,6 +813,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
20 changes: 20 additions & 0 deletions x/debug.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ package x

import (
"bytes"
"fmt"
"log"
"sort"

Expand All @@ -29,6 +30,25 @@ import (
"github.com/dgraph-io/dgraph/protos/pb"
)

func PrintRollup(plist *pb.PostingList, parts map[uint64]*pb.PostingList, baseKey []byte, ts uint64) {
k, _ := Parse(baseKey)
fmt.Printf("Doing rollup for key: %v at timestamp: %v\n", k, ts)
}

func PrintMutationProposal(mutations *pb.Mutations) {
startTs := mutations.StartTs
fmt.Printf("MUTATION PROPOSAL AT: %v \n", startTs)
for _, edge := range mutations.Edges {
fmt.Printf("Mutation Edge, StartTs: %v, Edge: %v\n", startTs, edge)
}
}

func PrintOracleDelta(delta *pb.OracleDelta) {
for _, status := range delta.Txns {
fmt.Println("COMMITING: ", status.StartTs, status.CommitTs)
}
}

// 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
13 changes: 13 additions & 0 deletions x/nodebug.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,19 @@ import (
"github.com/dgraph-io/dgraph/protos/pb"
)

// Print rollup that happen
func PrintRollup(plist *pb.PostingList, parts map[uint64]*pb.PostingList, baseKey []byte, ts uint64) {

harshil-goel marked this conversation as resolved.
Show resolved Hide resolved
}

// Print mutation proposal that shows that a proposal came in
harshil-goel marked this conversation as resolved.
Show resolved Hide resolved
func PrintMutationProposal(pb *pb.Mutations) {
}

// Print Oracle delta recieved when commting a transaction
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