state: use tableIndex constant
This commit is contained in:
parent
7cb2255838
commit
e4a60a2a8d
|
@ -2950,7 +2950,7 @@ func ensureIndexForService(t *testing.T, s *Store, serviceName string, expectedI
|
||||||
t.Helper()
|
t.Helper()
|
||||||
tx := s.db.Txn(false)
|
tx := s.db.Txn(false)
|
||||||
defer tx.Abort()
|
defer tx.Abort()
|
||||||
transaction, err := tx.First("index", "id", serviceIndexName(serviceName, nil))
|
transaction, err := tx.First(tableIndex, "id", serviceIndexName(serviceName, nil))
|
||||||
if err == nil {
|
if err == nil {
|
||||||
if idx, ok := transaction.(*IndexEntry); ok {
|
if idx, ok := transaction.(*IndexEntry); ok {
|
||||||
if expectedIndex != idx.Value {
|
if expectedIndex != idx.Value {
|
||||||
|
|
|
@ -295,7 +295,7 @@ func deleteConfigEntryTxn(tx WriteTxn, idx uint64, kind, name string, entMeta *s
|
||||||
if err := tx.Delete(tableConfigEntries, existing); err != nil {
|
if err := tx.Delete(tableConfigEntries, existing); err != nil {
|
||||||
return fmt.Errorf("failed removing config entry: %s", err)
|
return fmt.Errorf("failed removing config entry: %s", err)
|
||||||
}
|
}
|
||||||
if err := tx.Insert("index", &IndexEntry{tableConfigEntries, idx}); err != nil {
|
if err := tx.Insert(tableIndex, &IndexEntry{tableConfigEntries, idx}); err != nil {
|
||||||
return fmt.Errorf("failed updating index: %s", err)
|
return fmt.Errorf("failed updating index: %s", err)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -326,7 +326,7 @@ func (s *Store) CARootSetCAS(idx, cidx uint64, rs []*structs.CARoot) (bool, erro
|
||||||
}
|
}
|
||||||
|
|
||||||
// Update the index
|
// Update the index
|
||||||
if err := tx.Insert("index", &IndexEntry{tableConnectCARoots, idx}); err != nil {
|
if err := tx.Insert(tableIndex, &IndexEntry{tableConnectCARoots, idx}); err != nil {
|
||||||
return false, fmt.Errorf("failed updating index: %s", err)
|
return false, fmt.Errorf("failed updating index: %s", err)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -407,7 +407,7 @@ func (s *Store) CASetProviderState(idx uint64, state *structs.CAConsulProviderSt
|
||||||
}
|
}
|
||||||
|
|
||||||
// Update the index
|
// Update the index
|
||||||
if err := tx.Insert("index", &IndexEntry{tableConnectCABuiltin, idx}); err != nil {
|
if err := tx.Insert(tableIndex, &IndexEntry{tableConnectCABuiltin, idx}); err != nil {
|
||||||
return false, fmt.Errorf("failed updating index: %s", err)
|
return false, fmt.Errorf("failed updating index: %s", err)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -436,7 +436,7 @@ func (s *Store) CADeleteProviderState(idx uint64, id string) error {
|
||||||
if err := tx.Delete(tableConnectCABuiltin, providerState); err != nil {
|
if err := tx.Delete(tableConnectCABuiltin, providerState); err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
if err := tx.Insert("index", &IndexEntry{tableConnectCABuiltin, idx}); err != nil {
|
if err := tx.Insert(tableIndex, &IndexEntry{tableConnectCABuiltin, idx}); err != nil {
|
||||||
return fmt.Errorf("failed updating index: %s", err)
|
return fmt.Errorf("failed updating index: %s", err)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -476,7 +476,7 @@ func (s *Store) CAIncrementProviderSerialNumber(idx uint64) (uint64, error) {
|
||||||
tx := s.db.WriteTxn(idx)
|
tx := s.db.WriteTxn(idx)
|
||||||
defer tx.Abort()
|
defer tx.Abort()
|
||||||
|
|
||||||
existing, err := tx.First("index", "id", tableConnectCABuiltinSerial)
|
existing, err := tx.First(tableIndex, "id", tableConnectCABuiltinSerial)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return 0, fmt.Errorf("failed built-in CA serial number lookup: %s", err)
|
return 0, fmt.Errorf("failed built-in CA serial number lookup: %s", err)
|
||||||
}
|
}
|
||||||
|
@ -491,7 +491,7 @@ func (s *Store) CAIncrementProviderSerialNumber(idx uint64) (uint64, error) {
|
||||||
}
|
}
|
||||||
next := last + 1
|
next := last + 1
|
||||||
|
|
||||||
if err := tx.Insert("index", &IndexEntry{tableConnectCABuiltinSerial, next}); err != nil {
|
if err := tx.Insert(tableIndex, &IndexEntry{tableConnectCABuiltinSerial, next}); err != nil {
|
||||||
return 0, fmt.Errorf("failed updating index: %s", err)
|
return 0, fmt.Errorf("failed updating index: %s", err)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -160,7 +160,7 @@ func (s *Store) CoordinateBatchUpdate(idx uint64, updates structs.Coordinates) e
|
||||||
}
|
}
|
||||||
|
|
||||||
// Update the index.
|
// Update the index.
|
||||||
if err := tx.Insert("index", &IndexEntry{"coordinates", idx}); err != nil {
|
if err := tx.Insert(tableIndex, &IndexEntry{"coordinates", idx}); err != nil {
|
||||||
return fmt.Errorf("failed updating index: %s", err)
|
return fmt.Errorf("failed updating index: %s", err)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -117,7 +117,7 @@ func federationStateSetTxn(tx WriteTxn, idx uint64, config *structs.FederationSt
|
||||||
if err := tx.Insert(tableFederationStates, config); err != nil {
|
if err := tx.Insert(tableFederationStates, config); err != nil {
|
||||||
return fmt.Errorf("failed inserting federation state: %s", err)
|
return fmt.Errorf("failed inserting federation state: %s", err)
|
||||||
}
|
}
|
||||||
if err := tx.Insert("index", &IndexEntry{tableFederationStates, idx}); err != nil {
|
if err := tx.Insert(tableIndex, &IndexEntry{tableFederationStates, idx}); err != nil {
|
||||||
return fmt.Errorf("failed updating index: %v", err)
|
return fmt.Errorf("failed updating index: %v", err)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -216,7 +216,7 @@ func federationStateDeleteTxn(tx WriteTxn, idx uint64, datacenter string) error
|
||||||
if err := tx.Delete(tableFederationStates, existing); err != nil {
|
if err := tx.Delete(tableFederationStates, existing); err != nil {
|
||||||
return fmt.Errorf("failed removing federation state: %s", err)
|
return fmt.Errorf("failed removing federation state: %s", err)
|
||||||
}
|
}
|
||||||
if err := tx.Insert("index", &IndexEntry{tableFederationStates, idx}); err != nil {
|
if err := tx.Insert(tableIndex, &IndexEntry{tableFederationStates, idx}); err != nil {
|
||||||
return fmt.Errorf("failed updating index: %s", err)
|
return fmt.Errorf("failed updating index: %s", err)
|
||||||
}
|
}
|
||||||
return nil
|
return nil
|
||||||
|
|
|
@ -16,7 +16,7 @@ func (g *Graveyard) insertTombstoneWithTxn(tx WriteTxn, _ string, stone *Tombsto
|
||||||
return fmt.Errorf("failed updating tombstone index: %v", err)
|
return fmt.Errorf("failed updating tombstone index: %v", err)
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
if err := tx.Insert("index", &IndexEntry{"tombstones", stone.Index}); err != nil {
|
if err := tx.Insert(tableIndex, &IndexEntry{"tombstones", stone.Index}); err != nil {
|
||||||
return fmt.Errorf("failed updating tombstone index: %s", err)
|
return fmt.Errorf("failed updating tombstone index: %s", err)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -561,7 +561,7 @@ func legacyIntentionSetTxn(tx WriteTxn, idx uint64, ixn *structs.Intention) erro
|
||||||
if err := tx.Insert(tableConnectIntentions, ixn); err != nil {
|
if err := tx.Insert(tableConnectIntentions, ixn); err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
if err := tx.Insert("index", &IndexEntry{tableConnectIntentions, idx}); err != nil {
|
if err := tx.Insert(tableIndex, &IndexEntry{tableConnectIntentions, idx}); err != nil {
|
||||||
return fmt.Errorf("failed updating index: %s", err)
|
return fmt.Errorf("failed updating index: %s", err)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -689,7 +689,7 @@ func legacyIntentionDeleteTxn(tx WriteTxn, idx uint64, queryID string) error {
|
||||||
if err := tx.Delete(tableConnectIntentions, wrapped); err != nil {
|
if err := tx.Delete(tableConnectIntentions, wrapped); err != nil {
|
||||||
return fmt.Errorf("failed intention delete: %s", err)
|
return fmt.Errorf("failed intention delete: %s", err)
|
||||||
}
|
}
|
||||||
if err := tx.Insert("index", &IndexEntry{tableConnectIntentions, idx}); err != nil {
|
if err := tx.Insert(tableIndex, &IndexEntry{tableConnectIntentions, idx}); err != nil {
|
||||||
return fmt.Errorf("failed updating index: %s", err)
|
return fmt.Errorf("failed updating index: %s", err)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -706,13 +706,13 @@ func (s *Store) LegacyIntentionDeleteAll(idx uint64) error {
|
||||||
if _, err := tx.DeleteAll(tableConnectIntentions, "id"); err != nil {
|
if _, err := tx.DeleteAll(tableConnectIntentions, "id"); err != nil {
|
||||||
return fmt.Errorf("failed intention delete-all: %s", err)
|
return fmt.Errorf("failed intention delete-all: %s", err)
|
||||||
}
|
}
|
||||||
if err := tx.Insert("index", &IndexEntry{tableConnectIntentions, idx}); err != nil {
|
if err := tx.Insert(tableIndex, &IndexEntry{tableConnectIntentions, idx}); err != nil {
|
||||||
return fmt.Errorf("failed updating index: %s", err)
|
return fmt.Errorf("failed updating index: %s", err)
|
||||||
}
|
}
|
||||||
// Also bump the index for the config entry table so that
|
// Also bump the index for the config entry table so that
|
||||||
// secondaries can correctly know when they've replicated all of the service-intentions
|
// secondaries can correctly know when they've replicated all of the service-intentions
|
||||||
// config entries that USED to exist in the old intentions table.
|
// config entries that USED to exist in the old intentions table.
|
||||||
if err := tx.Insert("index", &IndexEntry{tableConfigEntries, idx}); err != nil {
|
if err := tx.Insert(tableIndex, &IndexEntry{tableConfigEntries, idx}); err != nil {
|
||||||
return fmt.Errorf("failed updating index: %s", err)
|
return fmt.Errorf("failed updating index: %s", err)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -234,7 +234,7 @@ func preparedQuerySetTxn(tx WriteTxn, idx uint64, query *structs.PreparedQuery)
|
||||||
if err := tx.Insert("prepared-queries", &queryWrapper{query, ct}); err != nil {
|
if err := tx.Insert("prepared-queries", &queryWrapper{query, ct}); err != nil {
|
||||||
return fmt.Errorf("failed inserting prepared query: %s", err)
|
return fmt.Errorf("failed inserting prepared query: %s", err)
|
||||||
}
|
}
|
||||||
if err := tx.Insert("index", &IndexEntry{"prepared-queries", idx}); err != nil {
|
if err := tx.Insert(tableIndex, &IndexEntry{"prepared-queries", idx}); err != nil {
|
||||||
return fmt.Errorf("failed updating index: %s", err)
|
return fmt.Errorf("failed updating index: %s", err)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -269,7 +269,7 @@ func preparedQueryDeleteTxn(tx WriteTxn, idx uint64, queryID string) error {
|
||||||
if err := tx.Delete("prepared-queries", wrapped); err != nil {
|
if err := tx.Delete("prepared-queries", wrapped); err != nil {
|
||||||
return fmt.Errorf("failed prepared query delete: %s", err)
|
return fmt.Errorf("failed prepared query delete: %s", err)
|
||||||
}
|
}
|
||||||
if err := tx.Insert("index", &IndexEntry{"prepared-queries", idx}); err != nil {
|
if err := tx.Insert(tableIndex, &IndexEntry{"prepared-queries", idx}); err != nil {
|
||||||
return fmt.Errorf("failed updating index: %s", err)
|
return fmt.Errorf("failed updating index: %s", err)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -42,7 +42,7 @@ func sessionDeleteWithSession(tx WriteTxn, session *structs.Session, idx uint64)
|
||||||
}
|
}
|
||||||
|
|
||||||
// Update the indexes
|
// Update the indexes
|
||||||
err := tx.Insert("index", &IndexEntry{"sessions", idx})
|
err := tx.Insert(tableIndex, &IndexEntry{"sessions", idx})
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return fmt.Errorf("failed updating sessions index: %v", err)
|
return fmt.Errorf("failed updating sessions index: %v", err)
|
||||||
}
|
}
|
||||||
|
@ -72,7 +72,7 @@ func insertSessionTxn(tx WriteTxn, session *structs.Session, idx uint64, updateM
|
||||||
return fmt.Errorf("failed updating sessions index: %v", err)
|
return fmt.Errorf("failed updating sessions index: %v", err)
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
err := tx.Insert("index", &IndexEntry{"sessions", idx})
|
err := tx.Insert(tableIndex, &IndexEntry{"sessions", idx})
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return fmt.Errorf("failed updating sessions index: %v", err)
|
return fmt.Errorf("failed updating sessions index: %v", err)
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue