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>
This commit is contained in:
Dhia Ayachi 2021-11-24 11:34:36 -05:00 committed by GitHub
parent 3d1b859533
commit f605689154
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 12 additions and 5 deletions

View File

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

View File

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

View File

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

View File

@ -72,7 +72,7 @@ func TestStateStore_SessionCreate_SessionGet(t *testing.T) {
if err := s.SessionCreate(2, sess); err != nil {
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)
}
if !watchFired(ws) {
@ -379,7 +379,7 @@ func TestStateStore_SessionDestroy(t *testing.T) {
}
// 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)
}