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

New memdb-based state store #1291

Merged
merged 110 commits into from
Oct 21, 2015
Merged

New memdb-based state store #1291

merged 110 commits into from
Oct 21, 2015

Conversation

slackpad
Copy link
Contributor

The major integration is done so I thought I'd open this up to start getting eyeballs on it.

Here's my current list of things outstanding:

  • Sweep through and finish remaining endpoint integration
  • Sweep through and resolve TODO comments in the source code
  • Unit tests for new watch.go
  • Unit tests for new delay.go
  • Unit tests for new graveyard.go
  • Unit test DirEntry.Clone() and ServiceNode.Clone() in structs.go
  • Look into lindex = 0 behavior for non-KV queries. I think we might need to return the table index in these cases to properly cover deletes. The new queries return a more fine-grained index if they can, but they will return 0 on an empty result set.
  • Verify memdb behavior in light of hashicorp/go-memdb@f5a621a
  • Add state store benchmarks back in
  • Run go vet
  • Fix up verify no UUID scripts
  • Delete old state store / blockingRPC code and get rid of "New" suffix (delete + search and replace)

Most of this is adding some small unit tests, but the lindex item could touch a few things.

@slackpad
Copy link
Contributor Author

I'll be pushing up some other changes today but this is worth an initial look /cc @armon @ryanuber.

&reply.QueryMeta,
state.QueryTables("ServiceNodes"),
state_store.NewMultiWatch(
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Not sure how you guys feel about this where we expose the table names up at this level. I really didn't like how KV was special so I normalized that, but I do see that this exposes lower-level details about the tables up. It would be easy to provide a string-based lookup thing like the old interface where you pass the name of the function you are calling here.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I'm actually going to push this down and keep something similar to the old interface (except for KV). This will be a better abstraction and will keep us from needing the state import in several places. Should be an easy change.

@slackpad slackpad force-pushed the f-memdb branch 2 times, most recently from b23a1b9 to bfd65e0 Compare October 15, 2015 21:53
if err := encoder.Encode(raw); err != nil {
return err
}
entries, err := s.state.KVSDump()
Copy link
Member

Choose a reason for hiding this comment

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

Could we just expose the iterator here?

Name: "session",
AllowMissing: true,
Unique: false,
Indexer: &memdb.StringFieldIndex{
Copy link
Member

Choose a reason for hiding this comment

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

I think we can use the UUIDFieldIndex here

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Got this - added a UUID maker just for unit tests.

@armon
Copy link
Member

armon commented Oct 16, 2015

Major feedback:

  • Use iterators in FSM snapshot to reduce performance impact
  • Use a single Txn in FSM restore to improve efficiency

Otherwise LGTM

@slackpad
Copy link
Contributor Author

Restore optimization is the last change based on Armon's feedback - working on that now.

@slackpad
Copy link
Contributor Author

@armon and @ryanuber all the outstanding comments have been addressed so please take another look.

I'm going to leave the TODO in PrefixWatch.Notify() for now since it's an existing bug and clean that up on another PR if I have time. I think it'll need a periodic sweep kind of cleanup, or else the notify groups will have to be able to tell the parent PrefixWatch once they have become empty.

state := s.fsm.State()
_, node, err := state.GetNode(member.Name)
if err != nil {
return fmt.Errorf("failed to lookup node %s: %s", member.Name, err)
Copy link
Member

Choose a reason for hiding this comment

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

It seems weird that this is the only error we prefix. Ideally they would all have some context around them. Does the returned error already contain the context for the nested calls below?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yeah these will end up pretty worthless, actually. I'll delete the prefix and just return err for these.

@ryanuber
Copy link
Member

@slackpad this all looks super solid! We should also remove the entry in the FAQ that mentions Consul's use of LMDB. I wasn't able to get a diff of the changes on the state store from where I left off and you picked up (because they are so large), but I perused the file and things looked sane. 👍

slackpad added a commit that referenced this pull request Oct 21, 2015
New memdb-based state store
@slackpad slackpad merged commit 7601a16 into master Oct 21, 2015
@slackpad slackpad deleted the f-memdb branch October 21, 2015 01:24
@ryanuber
Copy link
Member

Party! 🎉

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

Successfully merging this pull request may close these issues.

None yet

3 participants