Partition/kv indexid sessions (#11639)

* state: port KV and Tombstone tables to new pattern

* go fmt'ed

* handle wildcards for tombstones

* Fix graveyard ent vs oss

* fix oss compilation error

* add partition to tombstones and kv state store indexes

* refactor to use `indexWithEnterpriseIndexable`

* Apply suggestions from code review

Co-authored-by: Chris S. Kim <ckim@hashicorp.com>
Co-authored-by: R.B. Boyer <4903+rboyer@users.noreply.github.com>

* partition `tableSessions` table

* fix sessions to use UUID and fix prefix index

* fix oss build

* clean up unused functions

* fix oss compilation

* add a partition indexer for sessions

* Fix oss to not have partition index

* fix oss tests

* remove unused operations_ent.go and operations_oss.go func

* convert `indexNodeCheck` of `session_checks` table

* partition `indexID` and `indexSession` of `tableSessionChecks`

* remove partition for Checks as it's always use the session partition

* partition sessions index id table

* fix rebase issues

Co-authored-by: Daniel Nephin <dnephin@hashicorp.com>
Co-authored-by: Chris S. Kim <ckim@hashicorp.com>
Co-authored-by: R.B. Boyer <4903+rboyer@users.noreply.github.com>
pull/11697/head
Dhia Ayachi 3 years ago committed by GitHub
parent 2b8273bc6e
commit 3820e09a47
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

@ -120,3 +120,7 @@ func kvsDeleteWithEntry(tx WriteTxn, entry *structs.DirEntry, idx uint64) error
func partitionedIndexEntryName(entry string, _ string) string { func partitionedIndexEntryName(entry string, _ string) string {
return entry return entry
} }
func partitionedAndNamespacedIndexEntryName(entry string, _ *structs.EnterpriseMeta) string {
return entry
}

@ -296,8 +296,7 @@ func (s *Store) SessionGet(ws memdb.WatchSet,
tx := s.db.Txn(false) tx := s.db.Txn(false)
defer tx.Abort() defer tx.Abort()
// Get the table index. idx := maxIndexTxnSessions(tx, entMeta)
idx := sessionMaxIndex(tx, entMeta)
// Look up the session by its ID // Look up the session by its ID
if entMeta == nil { if entMeta == nil {
@ -324,7 +323,7 @@ func (s *Store) NodeSessions(ws memdb.WatchSet, nodeID string, entMeta *structs.
defer tx.Abort() defer tx.Abort()
// Get the table index. // Get the table index.
idx := sessionMaxIndex(tx, entMeta) idx := maxIndexTxnSessions(tx, entMeta)
// Get all of the sessions which belong to the node // Get all of the sessions which belong to the node
result, err := nodeSessionsTxn(tx, ws, nodeID, entMeta) result, err := nodeSessionsTxn(tx, ws, nodeID, entMeta)

@ -183,3 +183,7 @@ func (s *Store) SessionList(ws memdb.WatchSet, entMeta *structs.EnterpriseMeta)
return idx, result, nil return idx, result, nil
} }
func maxIndexTxnSessions(tx *memdb.Txn, _ *structs.EnterpriseMeta) uint64 {
return maxIndexTxn(tx, tableSessions)
}

@ -72,7 +72,7 @@ func TestStateStore_SessionCreate_SessionGet(t *testing.T) {
if err := s.SessionCreate(2, sess); err != nil { if err := s.SessionCreate(2, sess); err != nil {
t.Fatalf("err: %s", err) t.Fatalf("err: %s", err)
} }
if idx := s.maxIndex("sessions"); idx != 2 { if idx := s.maxIndex(partitionedAndNamespacedIndexEntryName(tableSessions, &sess.EnterpriseMeta)); idx != 2 {
t.Fatalf("bad index: %s", err) t.Fatalf("bad index: %s", err)
} }
if !watchFired(ws) { if !watchFired(ws) {
@ -379,7 +379,7 @@ func TestStateStore_SessionDestroy(t *testing.T) {
} }
// Check that the index was updated // Check that the index was updated
if idx := s.maxIndex("sessions"); idx != 3 { if idx := s.maxIndex(partitionedAndNamespacedIndexEntryName(tableSessions, &sess.EnterpriseMeta)); idx != 3 {
t.Fatalf("bad index: %d", idx) t.Fatalf("bad index: %d", idx)
} }

Loading…
Cancel
Save