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

tests/robustness: add in compaction checks for prevKV #18158

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

MadhavJivrajani
Copy link
Contributor

@MadhavJivrajani MadhavJivrajani commented Jun 11, 2024

Kubernetes issues watch to etcd using PrevKV() and with that, it relies on the property that create events always have prevKV=nil. This commit incorporates that explicit check in the robustness tests.

Further, etcd also can have prevKV=nil for any event type in the case of compaction taking place. This commit also adds in that check to ensure we are not changing these invariants.

We can make this change now because compaction support exists in robustness tests: #17833

Towards: #15820

/assign @serathius @siyuanfoundation

Kubernetes issues watch to etcd using PrevKV() and with that,
it relies on the property that create events always have prevKV=nil.
This commit incorporates that explicit check in the robustness tests.

Further, etcd also can have prevKV=nil for any event type in the case
of compaction taking place. This commit also adds in that check to
ensure we are not changing these invariants.

Signed-off-by: Madhav Jivrajani <madhav.jiv@gmail.com>
@MadhavJivrajani
Copy link
Contributor Author

oh wait I see my error - will fix in a little bit.

@serathius
Copy link
Member

Please ping me when it's ready for review.

// check that without knowing if compaction has run.
// i.e. for create events, prevKV is nil.
if event.IsCreate && event.PrevValue != nil {
lg.Error("prevValue field shold be nil in create event", zap.Int("client", report.ClientID), zap.Any("event", event), zap.Any("previousValue", prevState.KeyValues[event.Key]))
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
lg.Error("prevValue field shold be nil in create event", zap.Int("client", report.ClientID), zap.Any("event", event), zap.Any("previousValue", prevState.KeyValues[event.Key]))
lg.Error("prevValue field should be nil in create event", zap.Int("client", report.ClientID), zap.Any("event", event), zap.Any("previousValue", prevState.KeyValues[event.Key]))

err = errBrokePrevKV
}

// If compaction took place in the previous state, prevKV should be nil for all types of events in the current state:
Copy link
Member

@serathius serathius Jun 15, 2024

Choose a reason for hiding this comment

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

This is not correct. Event generation and compaction are independent processes. They are not serialized by WAL.

Idea that nil prevKV is caused by compaction is correct, but it cannot be validated this way. Hit me up if you want to discuss it.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Development

Successfully merging this pull request may close these issues.

None yet

4 participants