Skip to content

Make class ConfigForm concurrency safe #4780

@nilmerg

Description

@nilmerg

Preparations

  1. Checkout db: Add tables and models for config storage #4778 and base off a new branch from it.
  2. Apply the migration scripts for version 2.11 to the mysql and postgresql database.
  3. Checkout Select: Add support for locking clauses ipl-sql#55, you'll need it

Goal

If there are multiple users updating the same configuration at the same time, no change must be ignored or overridden without explicit user action.

Assuming there are two users:

User A User B
opens config
opens config
submits changes
submits changes
succeeds
fails

If the update fails, the user must be informed about it. In addition, the new configuration values should be shown in a message at the top of the form.

Tasks

  • Add a new validator to ConfigForm (You may need to extend method isValid() to achieve this as it should be a validator for the entire form)
  • Fetch the hash for the configuration's scope and compare it against the one sent in the form data (That's a task of Adjust ConfigForm to write configurations to database #4779)
    • Apply a locking clause to the query to ensure you'll get a result only if there's noone writing to it. (See FOR UPDATE)
  • If the hashes don't match
    • fetch the new config options from database
    • show a message at the top of the form ($this->warning) and list the new options there
    • forget the old hash and set the new hash so that the next submit includes it (Otherwise the validation fails again)
    • let the form validation fail

Hints

You can fake another user by running a transaction on the database in the console with a sleep in it:

begin;

update icingaweb_config_scope ... ;

do sleep(60);

commit;

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions