Summary:
`TabletVectorIndexes` keeps its vector index list (`vector_indexes_list_`) as a copy-on-write `shared_ptr` that lock-free readers snapshot under a brief shared lock and then iterate without holding the lock.
`DoCreateIndex` and `RemoveTableFromList` used a `shared_ptr::use_count() == 1` check to decide it was safe to mutate the list buffer in place.
`use_count()` is a relaxed, non-synchronizing load, so it does not establish a happens-before relationship with a reader that has just released its snapshot.
As a result the writer could reallocate the buffer in place while a reader's access to it was unsynchronized, which TSAN reported as a data race in `InsertVectorIndex`.
This collides when post-split vector index compaction (`VectorIndexList::WaitForCompaction`) runs concurrently with the creation of another vector index on the same tablet.
Always build a new vector and publish it via the `shared_ptr` instead of mutating in place.
A published buffer is then immutable, so lock-free readers holding a snapshot are safe, and old buffers are freed via the reference count's `acq_rel` decrement, which establishes happens-before.
Add the regression test `PgVectorIndexSingleServerTest.ConcurrentCreateIndexAndListRace`, which reproduces the race deterministically under TSAN.
It coordinates the reader and writer with relaxed atomics rather than latches or sync-point dependencies, since those would introduce happens-before and mask the race, plus a `DEBUG_ONLY_TEST_SYNC_POINT` in `DoCreateIndex`.
Test Plan: ./yb_build.sh tsan --cxx-test pgwrapper_pg_vector_index-test --gtest_filter '*ConcurrentCreateIndexAndListRace/DistributedYbHnswHnswlibPackingV1'
Reviewers: arybochkin
Reviewed By: arybochkin
Subscribers: ybase, yql
Tags: #jenkins-ready
Differential Revision: https://phorge.dev.yugabyte.com/D55154