git/list[1] front-page[2] threads[3] people[4] search[5] about
 

[PATCH 0/4] Make update_refs more atomic V2

From
Ronnie Sahlberg <sahlberg@google.com>
Date
Apr 10, 2014, 18:30 UTC
Message-ID
<1397154625-11884-1-git-send-email-sahlberg@google.com>

refs.c:update_refs() intermingles doing updates and checks with actually applying changes to the refs in loops that abort on error. This is done one ref at a time and means that if an error is detected that will fail the operation after only some of the ref operations have been been updated on the disk.

These patches change the update and delete functions to use a three call pattern of

1, lock 2, update, or flag for deletion 3, apply on disk

In the final patch I change update_refs to perform these actions in three separate loops where the final loop to 'apply on disk' all the changes will only be performed if there were no error conditions detected during any of previous loops.

This should make the changes of refs in update_refs slightly more atomic.

This may overlap with other current patch series for making refs updates more atomic which may mean these patches become obsolete, but I would still like some review and feedback on these changes.

Version 2:
Updates and fixes based on Junio's feedback.
* Fix the subject line for patches so they comply with the project standard.
* Redo the update/delete loops so that we maintain the correct order of
  operations. Perform all updates first, then perform the deletes.
* Add an additional patch that allows us to do the update/delete in the correct
  order from within a single loop by first sorting the refs so that deletes
  are after all non-deletes.
Ronnie Sahlberg (4):
  refs.c: split writing and commiting a ref into two separate functions
  refs.c: split delete_ref_loose() into a separate flag-for-deletion and
    commit phase
  refs.c: change update_refs to run the commit loops once all work is
    finished
  refs.c: sort the refs by new_sha1 and merge the two update/delete
    loops into one
 branch.c               |  10 ++++-
 builtin/commit.c       |   5 +++
 builtin/fetch.c        |   7 +++-
 builtin/receive-pack.c |   4 ++
 builtin/replace.c      |   6 ++-
 builtin/tag.c          |   6 ++-
 fast-import.c          |   7 +++-
 refs.c                 | 102 +++++++++++++++++++++++++++++++++----------------
 refs.h                 |   6 +++
 sequencer.c            |   4 ++
 walker.c               |   4 ++
 11 files changed, 123 insertions(+), 38 deletions(-)
-- 
1.9.1.478.ga5a8238.dirty
Next: Ronnie Sahlberg
Message 1 of 9 in “Make update_refs more atomic V2”
  1. 0/4 Make update_refs more atomic V2Ronnie Sahlberg, Apr 10, 2014
  2. 1/4 refs.c: split writing and commiting a ref into two separate functionsRonnie Sahlberg, Apr 10, 2014
  3. 2/4 refs.c: split delete_ref_loose() into a separate flag-for-deletion and commit phaseRonnie Sahlberg, Apr 10, 2014
  4. 3/4 refs.c: change update_refs to run the commit loops once all work is finishedRonnie Sahlberg, Apr 10, 2014
  5. 4/4 refs.c: sort the refs by new_sha1 and merge the two update/delete loops into oneRonnie Sahlberg, Apr 10, 2014
  6. Junio C HamanoApr 10, 2014
  7. Ronnie SahlbergApr 10, 2014
  8. Junio C HamanoApr 10, 2014
  9. Junio C HamanoApr 10, 2014

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.