View Issue Details

IDProjectCategoryView StatusLast Update
0008088mantisbtotherpublic2014-07-19 04:43
Reporterharako Assigned Todregad  
PrioritynormalSeverityfeatureReproducibilityalways
Status closedResolutionduplicate 
Product Version1.1.0a3 
Summary0008088: Data is overwritten by another data when two persons are editing a same issue.
Description

I know it's a typical behaviour of web system.

I think however, I would appreciate it if the following behaviour is implemented as option.

  • Option1: Any changes are recorded.
    If this option is enabled, much disk area will be used.
    But I think it is in demand like a configuration management.

  • Option2: Locking an issue
    Locking an issue for not to be updated by others.

Steps To Reproduce
  1. Foo opens an issue and edits.

  2. Bar opens the same issue and edits.

  3. Foo submits the changes.

  4. Bar also submits the changes.

  5. Foo's changes are discarded overwritten with Bar's changes.

TagsNo tags attached.
Attached Files
bug_lock_patch.zip (1,347 bytes)

Relationships

duplicate of 0005466 closeddregad Changes are overwritten 

Activities

ryandesign

ryandesign

2007-06-21 00:25

reporter   ~0014790

Last edited: 2007-06-21 00:26

In fact, there's a pretty simple solution that can be implemented:

  • Add a field to the bug table which is the modification token. This can be an incrementing integer or a random integer or string or whatever. Point is just that for each modification, the field's contents changes.

  • Send the modification token to the browser in the bug edit form. When the user submits their changes, the modification token comes back to the server.

  • If the modification token received from the browser is the same as the modification token currently in the bug table, the edit is accepted and recorded in the bug table, and the modification token is updated (either incremented, or another random value is stored there).

  • If the modification token received from the browser is different from the modification token currently in the bug table, then someone else has modified the bug already, and the user should be informed of this and asked to redo their changes.

FileMaker Pro has this (it's called the mod_id there). Wikipedia and probably other wiki systems have this. It's a good idea.

brianstv

brianstv

2008-08-18 12:38

reporter   ~0019176

Another solution:

Using the mantis_tokens_table or similar table, add a type for TOKEN_ISSUE_LOCK.

Then when a user goes into the bug update form, add a row to the table with the 'timestamp' being when they started editing, the 'expiry' set to when their exclusive update rights end, and 'value' set to the issue id.
When the user's update of the issue is complete, the token is deleted.

If second user attempts to go into the bug update form for an issue already "locked", they will get a message stating who is already updating that issue.

If the first user never completes the update before the "expiry" time, the second user is allowed to update the issue and the first user will then have to re-submit their changes. This would be accomplished by the second user's update removing the first user's token when their token is added to the token table.

The 'expiry' value should be calculated from something defined in the config_defaults_inc.php file as 30 min. or 1 hour. that way it is configurable.

vboctor

vboctor

2008-08-18 19:56

manager   ~0019177

I'm aware of this issue and the method I had in mind for fixing it is what ryandesign suggested with "last modified" field as the token. Last modified is currently updated when an issue is updated or its related data like notes are changed. Although this may cause more conflict than what is abosuletely necessary, I don't think the conflict will happen often enough to justify an extra field.

There is also a benefit from disallowing two users to add notes in parallel, is that the 2nd user should ideally take the note of the first user in consideration before submitting their notes.

So adding notes / updating issue header information / and potentionally other operations can all be guarded by the issue last modified timestamp.

brianstv

brianstv

2008-09-08 14:29

reporter   ~0019335

My suggestion helps to resolve conflict between two users working on the same issue while minimizing users having to re-enter their work, and lets the second user know someone is already working on the issue.

The only additional field would be for the timeout value, and could just be hard-coded if necessary.

mutscheller

mutscheller

2010-08-13 09:49

reporter   ~0026302

I had the same problem in my team.
My solution is attached as zip including 3 files:

  • bug_unlock.php
    --> This is a new file needed to force an unlock on a bug.
  • bug_update.php.diff
    --> Unified diff file. I'm not quite sure if the diff info fits to actual mantis release, so just add the block directly under following lines

    Update the bug entry, notify if we haven't done so already

    $t_bug_data->update( true, ( false == $t_notify ) );

  • bug_update_advanced_page.php.diff
    --> same issue... Just add the first block directly under the line print_recently_visited();
    And the second block somewhere in the form.

Additionaly you need 2 new rows in mantis_bug_table:
locked_since int(11)
locked_by text

That's all. Maybe this patch will appear in next mantis release ;-)

mutscheller

mutscheller

2010-08-13 10:07

reporter   ~0026303

additional functions for bug_api.php:
/**

  • locks the bug
  • @param int p_bug_id integer representing bug ids
  • @param user user who wants to lock the bug
  • @return bool (always true)
  • @access public
  • @uses database_api.php
    */
    function bug_lock( $p_bug_id, $user_name, $time_stamp ) {

    $t_bug_table = db_get_table( 'mantis_bug_table' );

    $query = "UPDATE $t_bug_table
    SET locked_by=\"" . $user_name ."\",
    locked_since=$time_stamp
    WHERE id=$p_bug_id";

    db_query_bound( $query );

    return true;
    }

/**

  • unlocks the bug
  • @param int p_bug_id integer representing bug ids
  • @return bool (always true)
  • @access public
  • @uses database_api.php
    */
    function bug_unlock( $p_bug_id ) {

    $t_bug_table = db_get_table( 'mantis_bug_table' );

    $query = "UPDATE $t_bug_table
    SET locked_by=\"\",
    locked_since=0
    WHERE id=$p_bug_id";

    db_query_bound( $query );

    return true;
    }