tikv / sig-transaction

Resources for the transaction SIG
63 stars 13 forks source link

Sync of PD timestamps and timestamps computed when resolving a lock for parallel commit #21

Closed nrc closed 4 years ago

nrc commented 4 years ago

@MyonKeminta believes there will be problems if and only if the computed ts is > PD's latest ts + 1. I'm not clear on the concrete problems this causes or if/how they can be mitigated.

nrc commented 4 years ago

This is not a problem if we only use timestamps from PD as read ts, but might be a problem due to conflict_for_update_ts.

sticnarf commented 4 years ago

A simple workaround is recording whether a timestamp is allocated from PD or calculated. We can limit deriving a timestamp from a calculated timestamp. In other words, if conflict_for_update_ts is a calculated timestamp, TiDB gets a new timestamp from PD and retry reading.

However, if the workload is to update the same key frequently, up to half of transactions need to get timestamps from PD, which makes performance a bit worse.

MyonKeminta commented 4 years ago

@sticnarf I think we do not have any other better solution. We can adopt this solution for now, and in the scenario you said maybe it's better to disable parallel commit.

youjiali1995 commented 4 years ago

Agree.

nrc commented 4 years ago

This is currently not a bug in the implementation, but is something we should bear in mind for future optimisations.