Postgres current xid desync between replicas
# spicedb
k
Hi, We have SpiceDB deployed to a say cluster A, with PostgresDB deployed to the same cluster A. We have a PostgresDB logical replica in cluster B and readonly SpiceDB instance on top of it (so definitely no writes are being made there). What we're observing is even when we run the
spicedb datastore repair
, after some time the current Xid becomes desynchronised between he cluster A and cluster B Postgres. This of course might lead to some issues with SpiceDB. I know it doesn't seem to be a SpiceDB issue itself. However, maybe you are aware or you've run into this issue in the past and can point us into a correct direction of how to investigate and fix this? Cheers, Kuba
y
that's strange... we used logical replication at my last company and i don't remember seeing issues like that, though our system was relatively low traffic. logical replication is basically replaying the WAL, right? are there operations happening in your primary cluster that would increment the transaction counter but wouldn't show up in the WAL?
k
Good point, maybe postgres vacuum operation increments the counter while it's not a logical change? I'll investigate in this direction
@yetitwo at your previous company, was it definitely a logical replication? Or maybe a physical one? The more I read about it, the more I think current transaction id can't be 100% in sync at all times, even after running
spicedb datastore repair
. I might be missing something but postgres docs only say that "transactional consistency is guaranteed" (data, sequence) but xids are assigned independently and how it works is pretty much internal to postgres so not sure if can be relied on...
From postgres docs: ''' Non-virtual TransactionIds (or xid), e.g., 278394, are assigned sequentially to transactions from a global counter used by all databases within the PostgreSQL cluster. ''' We do have different databases in the cluster, as we use Azure Postgres (e.g.
azure_maintenance
,
azure_sys
). Maybe it's because of this?
y
we were definitely using logical replication. it may have been that the traffic was small enough or the instances were similar enough that we didn't run into the issue except when we were doing things that explicitly broke expectations, like standing up a new instance and starting logical replication or truncating tables
we were using AWS RDS postgres, so there may be cloud-specific differences between them
it would be a bummer if something about Azure Postgres caused problems here 🤔
11 Views