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

server: remove unreferenced non-root objects #219

Closed
jcaamano opened this issue Aug 23, 2021 · 2 comments · Fixed by #375
Closed

server: remove unreferenced non-root objects #219

jcaamano opened this issue Aug 23, 2021 · 2 comments · Fixed by #375

Comments

@jcaamano
Copy link
Collaborator

From rfc 7047:

      The "isRoot" boolean is used to determine whether rows in the
      table require strong references from other rows to avoid garbage
      collection.  (See the discussion of "strong" and "weak" references
      below in the description of <base-type>.)  If "isRoot" is
      specified as true, then rows in the table exist independent of any
      references (they can be thought of as part of the "root set" in a
      garbage collector).  If "isRoot" is omitted or specified as false,
      then any given row in the table may exist only when there is at
      least one reference to it, with refType "strong", from a different
      row (in the same table or a different table).  This is a
      "deferred" action: unreferenced rows in the table are deleted just
      before transaction commit.
@dave-tucker
Copy link
Collaborator

this is on my todo list, i'll hopefully get to it next week.

i'm not 100% sure how to implement the reference counter at the moment, but this is my plan.

  1. map[string]map[string]map[string]int is our ref counter, which maps database name, to table, to uuid, to count 😓
  2. when we create a non-root object we add it to the map
  3. when something references that object we increment the counter (note: we should also enforce strong vs weak refType checking here too)
  4. when something removes a reference to that object we decrement the counter, if it's zero we add it to another map to flag it for garbage collection
  5. before Commit is called at the end of the transaction, we remove any items from the garbage collection map from the database (which could include rows that we were committing as part of the transaction)

@jcaamano
Copy link
Collaborator Author

When pondering about this I toyed with the idea of placing the ref counter as a hidden column somewhere in the existing rows. Other than that I had the same ideas.

flavio-fernandes added a commit to flavio-fernandes/ovn-kubernetes-ds that referenced this issue Jun 22, 2022
This is a POC change, where egressip will explicitly remove the logical router policy
when logical router no longer uses it. Currently in 4.10, the implementation expects
ovsdb server to automatically garbage collect it, since that is a non-root table.

NOTE: This change will break unit tests, since libovsdb ovsdb server used does not have
garbage collection. See: ovn-org/libovsdb#219

Signed-off-by: Flavio Fernandes <[email protected]>
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 a pull request may close this issue.

2 participants