0

I have a shared DB table have x number of records, and I have y number of running pods, how to make each pod take (x/y) records to process them?

  • I don't have a complete solution for you but a good way to have multiple workers reserve rows is to use a database transaction and a SELECT with FOR UPDATE SKIP LOCKED throw a LIMIT into the query to specify how many you want and an ORDER BY to get oldest first. The FOR UPDATE locks rows so the others can't get them. The SKIP LOCKED prevents the other from waiting for rows to get unlocked. When the worker is ready it can update the rows and commit. – Eelke Aug 31 '21 at 06:03
  • Please edit the question to limit it to a specific problem with enough detail to identify an adequate answer. – Community Sep 02 '21 at 07:53

0 Answers0