postgresqlspicedb

SpiceDB relation tuples left in db


I'm using spicedb with postgres database, I've noticed that when I delete a Relation the corresponding tuple is left in the relation_tuple table and the value of the column deleted_xid is set to transaction id.

Are those records to remain there forever? When will they be actually deleted?

I'm worrying that in a relative short time the table will be clogged with useless records...


Solution

  • In order to implement "time-traveling queries", SpiceDB's Postgres datastore implementation actually retains data for a period of time after deletion.

    How long this data is available, how often garbage collection is conducted, and how long until garbage collection times out are all configurable.

    From the spicedb serve --help usage:

      --datastore-gc-interval duration            amount of time between passes of garbage collection (postgres driver only) (default 3m0s)
      --datastore-gc-max-operation-time duration  maximum amount of time a garbage collection pass can operate before timing out (postgres driver only) (default 1m0s)
      --datastore-gc-window duration              amount of time before revisions are garbage collected (default 24h0m0s)
    

    If you're curious, you can dive deeper into the implementation by reading this particular file: https://github.com/authzed/spicedb/blob/v1.25.0/internal/datastore/postgres/gc.go