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

fix: Skip bad events in CDC. #8076

Merged
merged 1 commit into from
Aug 16, 2023
Merged

fix: Skip bad events in CDC. #8076

merged 1 commit into from
Aug 16, 2023

Conversation

danielmai
Copy link
Contributor

@danielmai danielmai commented Oct 12, 2021

A CDC event can return an error during JSON marshalling like the following:

2021/10/12 21:58:11 json: error calling MarshalJSON for type time.Time: Time.MarshalJSON: year outside of range [0,9999]

github.com/dgraph-io/dgraph/x.Check
    /ext-go/1/src/github.com/dgraph-io/dgraph/x/error.go:42
github.com/dgraph-io/dgraph/worker.(*CDC).processCDCEvents.func1
    /ext-go/1/src/github.com/dgraph-io/dgraph/worker/cdc_ee.go:207
github.com/dgraph-io/dgraph/worker.(*CDC).processCDCEvents.func2
    /ext-go/1/src/github.com/dgraph-io/dgraph/worker/cdc_ee.go:295
github.com/dgraph-io/dgraph/worker.(*CDC).processCDCEvents.func3
    /ext-go/1/src/github.com/dgraph-io/dgraph/worker/cdc_ee.go:331
github.com/dgraph-io/dgraph/worker.(*CDC).processCDCEvents
    /ext-go/1/src/github.com/dgraph-io/dgraph/worker/cdc_ee.go:351
runtime.goexit
    /usr/local/go/src/runtime/asm_amd64.s:1371

This change skips these events from being sent to CDC.

Copy link
Contributor Author

@danielmai danielmai left a comment

Choose a reason for hiding this comment

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

The error message can now look similar to the one below instead of panicking:

E1013 16:34:48.129933      19 cdc_ee.go:208] error while marshalling batch for event [&{Operation:set Uid:2097730 Attr:myEdge Value:53565-01-01 00:00:00 +0000 UTC ValueType:datetime}]: json: error calling MarshalJSON for type time.Time: Time.MarshalJSON: year outside of range [0,9999]
E1013 16:34:48.130017      19 cdc_ee.go:208] error while marshalling batch for event [&{Operation:set Uid:2097730 Attr:myEdge Value:53584-01-01 00:00:00 +0000 UTC ValueType:datetime}]: json: error calling MarshalJSON for type time.Time: Time.MarshalJSON: year outside of range [0,9999]
E1013 16:34:48.131383      19 cdc_ee.go:220] error while sending cdc event to sink kafka: Failed to deliver 2 messages.
E1013 16:34:48.131426      19 cdc_ee.go:355] unable to send events kafka: Failed to deliver 2 messages.
unable to send messages to sink
github.com/dgraph-io/dgraph/worker.(*CDC).processCDCEvents.func2
	/home/dmai/go/src/github.com/dgraph-io/dgraph/worker/cdc_ee.go:299
github.com/dgraph-io/dgraph/worker.(*CDC).processCDCEvents.func3
	/home/dmai/go/src/github.com/dgraph-io/dgraph/worker/cdc_ee.go:334
github.com/dgraph-io/dgraph/worker.(*CDC).processCDCEvents
	/home/dmai/go/src/github.com/dgraph-io/dgraph/worker/cdc_ee.go:354
runtime.goexit
	/usr/local/go/src/runtime/asm_amd64.s:1581
CDC: unable to process raft entry
github.com/dgraph-io/dgraph/worker.(*CDC).processCDCEvents.func3
	/home/dmai/go/src/github.com/dgraph-io/dgraph/worker/cdc_ee.go:335
github.com/dgraph-io/dgraph/worker.(*CDC).processCDCEvents
	/home/dmai/go/src/github.com/dgraph-io/dgraph/worker/cdc_ee.go:354
runtime.goexit
	/usr/local/go/src/runtime/asm_amd64.s:1581

Reviewable status: 0 of 1 files reviewed, all discussions resolved (waiting on @manishrjain)

@danielmai danielmai changed the title fix: Print error in CDC batch event. fix: Skip bad events in CDC. Oct 15, 2021
@CLAassistant
Copy link

CLAassistant commented Apr 29, 2022

CLA assistant check
All committers have signed the CLA.

This can have an error like the following:

    2021/10/12 21:58:11 json: error calling MarshalJSON for type
    time.Time: Time.MarshalJSON: year outside of range [0,9999]

    github.com/dgraph-io/dgraph/x.Check
        /ext-go/1/src/github.com/dgraph-io/dgraph/x/error.go:42
    github.com/dgraph-io/dgraph/worker.(*CDC).processCDCEvents.func1
        /ext-go/1/src/github.com/dgraph-io/dgraph/worker/cdc_ee.go:207
    github.com/dgraph-io/dgraph/worker.(*CDC).processCDCEvents.func2
        /ext-go/1/src/github.com/dgraph-io/dgraph/worker/cdc_ee.go:295
    github.com/dgraph-io/dgraph/worker.(*CDC).processCDCEvents.func3
        /ext-go/1/src/github.com/dgraph-io/dgraph/worker/cdc_ee.go:331
    github.com/dgraph-io/dgraph/worker.(*CDC).processCDCEvents
        /ext-go/1/src/github.com/dgraph-io/dgraph/worker/cdc_ee.go:351
    runtime.goexit
        /usr/local/go/src/runtime/asm_amd64.s:1371
Copy link
Contributor

@darkn3rd darkn3rd left a comment

Choose a reason for hiding this comment

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

LGTM

@mangalaman93 mangalaman93 merged commit 2bc63f9 into main Aug 16, 2023
11 checks passed
@mangalaman93 mangalaman93 deleted the danielmai/cdc-error-log branch August 16, 2023 04:47
jbhamra1 pushed a commit that referenced this pull request Aug 17, 2023
A CDC event can return an error during JSON marshalling like the
following. This change skips these events from being sent to CDC.

2021/10/12 21:58:11 json: error calling MarshalJSON for type time.Time:
Time.MarshalJSON: year outside of range [0,9999]

    github.com/dgraph-io/dgraph/x.Check
        /ext-go/1/src/github.com/dgraph-io/dgraph/x/error.go:42
    github.com/dgraph-io/dgraph/worker.(*CDC).processCDCEvents.func1
        /ext-go/1/src/github.com/dgraph-io/dgraph/worker/cdc_ee.go:207
    github.com/dgraph-io/dgraph/worker.(*CDC).processCDCEvents.func2
        /ext-go/1/src/github.com/dgraph-io/dgraph/worker/cdc_ee.go:295
    github.com/dgraph-io/dgraph/worker.(*CDC).processCDCEvents.func3
        /ext-go/1/src/github.com/dgraph-io/dgraph/worker/cdc_ee.go:331
    github.com/dgraph-io/dgraph/worker.(*CDC).processCDCEvents
        /ext-go/1/src/github.com/dgraph-io/dgraph/worker/cdc_ee.go:351
    runtime.goexit
        /usr/local/go/src/runtime/asm_amd64.s:1371

Co-authored-by: Aman Mangal <aman@dgraph.io>
jbhamra1 pushed a commit that referenced this pull request Aug 17, 2023
A CDC event can return an error during JSON marshalling like the
following. This change skips these events from being sent to CDC.

2021/10/12 21:58:11 json: error calling MarshalJSON for type time.Time:
Time.MarshalJSON: year outside of range [0,9999]

    github.com/dgraph-io/dgraph/x.Check
        /ext-go/1/src/github.com/dgraph-io/dgraph/x/error.go:42
    github.com/dgraph-io/dgraph/worker.(*CDC).processCDCEvents.func1
        /ext-go/1/src/github.com/dgraph-io/dgraph/worker/cdc_ee.go:207
    github.com/dgraph-io/dgraph/worker.(*CDC).processCDCEvents.func2
        /ext-go/1/src/github.com/dgraph-io/dgraph/worker/cdc_ee.go:295
    github.com/dgraph-io/dgraph/worker.(*CDC).processCDCEvents.func3
        /ext-go/1/src/github.com/dgraph-io/dgraph/worker/cdc_ee.go:331
    github.com/dgraph-io/dgraph/worker.(*CDC).processCDCEvents
        /ext-go/1/src/github.com/dgraph-io/dgraph/worker/cdc_ee.go:351
    runtime.goexit
        /usr/local/go/src/runtime/asm_amd64.s:1371

Co-authored-by: Aman Mangal <aman@dgraph.io>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

Successfully merging this pull request may close these issues.

5 participants