Skip to content

Resolve "Creating two link row fields simultaneously fails hard"

This merge request fixes a race condition where if two link row fields are created simultaneously, one of the requests fails hard because of a link_row_relation_id conflict. It fixes this problem by using a serial fields that automatically increments independently of the transaction. This is similar as to how a normal auto increment primary id works.

The changes are proposal of how we could solve this. Would love to get on feedback on whether we want to take this route.

How to test

  • Start Baserow in a multi worker mode using gunicorn gunicorn -w 5 -b 127.0.0.1:8000 baserow.config.wsgi:application --log-level=debug --chdir=/baserow.
    • Add a time.sleep(10) to the CoreHandler::import_applications_to_group method to slow down the installation of a template.
    • Install a template that contains a link_row fields.
    • While installing create a link_row field somewhere.
    • Both operations should succeed and the newly created link row fields should not have a conflicting link_row_relation_id.
  • Test whether the old link_row_relation_id sequence continues where it was before. So if the last link_row_relation_id was 1000, after checking and this branch and applying the migration, the new link row field should continue at 1001.

Merge Request Checklist

  • changelog.md has been updated if required
  • New/updated Premium features are separated correctly in the premium folder
  • The latest Chrome and Firefox have been used to test any new frontend features
  • Documentation has been updated
  • Quality Standards are met
  • Performance: tables are still fast with 100k+ rows, 100+ field tables
  • The redoc API pages have been updated for any REST API changes
  • Our custom API docs are updated for changes to endpoints accessed via api tokens
  • The UI/UX has been updated following UI Style Guide

Closes #913 (closed)

Edited by Bram Wiepjes

Merge request reports