DROP INDEX error due to internal serialization error
Version: 2.1.3
The error looks like this
Error running SQL DROP INDEX sd.foo@foo_1_idx, err: pq: table descriptor for "sd.public.foo" became unavailable within same txn: HandledRetryableTxnError: ReadWithinUncertaintyIntervalError: read at time 1555454417.579639810,0 encountered previous write with future timestamp 1555454417.584529926,0 within uncertainty interval `t <= 1555454417.586895758,0`; observed timestamps: [{1 1555454417.579639810,0} {2 1555454417.586895758,0}]
Appears to be coming from https://github.com/cockroachdb/cockroach/blob/8572f7833c28637ec495b885c4ac60538b4815fe/pkg/sql/drop_index.go#L74
The index was recently added and there are other recent schema changes on the table. There is no application level concurrency however, there is a single application thread performing schema changes one at a time in separate transactions. I see background operations on it in cockroach logs
I190416 22:39:15.324332 928 sql/lease.go:345 [n1,client=127.0.0.1:36464,user=rk_owner] publish: descID=214 (foo) version=14 mtime=2019-04-16 22:39:15.305663061 +0000 UTC
I190416 22:39:15.348808 928 sql/event_log.go:126 [n1,client=127.0.0.1:36464,user=rk_owner] Event: "alter_table", target: 214, info: {TableName:sd.public.foo Statement:ALTER TABLE sd.public.foo ADD COLUMN latest_failover_id STRING User:rk_owner MutationID:5 Cascad
eDroppedViews:[]}
I190416 22:39:15.372907 6863 sql/lease.go:876 new lease: 214("foo") ver=14:1555454609.409089534,0, refcount=0
I190416 22:39:15.388609 928 sql/lease.go:315 publish (1 leases): desc=[{foo 214 13}]
I190416 22:39:15.491628 928 sql/lease.go:345 [n1,client=127.0.0.1:36464,user=rk_owner,scExec] publish: descID=214 (foo) version=15 mtime=2019-04-16 22:39:15.49097418 +0000 UTC
I190416 22:39:15.510209 928 sql/lease.go:315 publish (1 leases): desc=[{foo 214 14}]
I190416 22:39:15.510816 6888 sql/lease.go:876 new lease: 214("foo") ver=15:1555454724.587014011,0, refcount=0
I190416 22:39:15.539243 928 sql/backfill.go:134 [n1,client=127.0.0.1:36464,user=rk_owner,scExec] Running backfill for "foo", v=15, m=5
I190416 22:39:15.548526 928 sql/lease.go:345 [n1,client=127.0.0.1:36464,user=rk_owner,scExec] publish: descID=214 (foo) version=16 mtime=2019-04-16 22:39:15.547903116 +0000 UTC
I190416 22:39:15.581895 928 sql/event_log.go:126 [n1,client=127.0.0.1:36464,user=rk_owner,scExec] Event: "finish_schema_change", target: 214, info: {MutationID:5}
I190416 22:39:15.600214 6893 sql/lease.go:876 new lease: 214("foo") ver=16:1555454643.242357262,0, refcount=0
I190416 22:39:15.601550 928 sql/lease.go:315 publish (1 leases): desc=[{foo 214 15}]
These must be the ones causing the read to become uncertain.
This is a tricky issue and I haven't been able to figure out what's going on here. It seems obvious that somehow the first descriptor lookup at https://github.com/cockroachdb/cockroach/blob/8572f7833c28637ec495b885c4ac60538b4815fe/pkg/sql/drop_index.go#L43 is hitting the cache or else it would hit the read uncertainty error, but I can't see how.
Closing due to inactivity.