{"thread":{"id":"6601","subject":"git repack -a -d is not safe","startedAt":"2007-02-01T11:25:45Z","lastAt":"2007-02-01T23:26:35Z","messageCount":3,"participants":["Matthias Lederhofer","Shawn O. Pearce","Johannes Schindelin"],"isPatch":false,"patchVersion":null,"patchTotal":null},"messages":[{"id":"33225","messageId":"20070201112545.GA19855@moooo.ath.cx","threadId":"6601","inReplyTo":null,"subject":"git repack -a -d is not safe","fromName":"Matthias Lederhofer","fromEmail":"matled@gmx.net","sentAt":"2007-02-01T11:25:45Z","receivedAt":"2007-02-01T11:25:45Z","isPatch":false,"sender":{"key":"matled@gmx.net","avatar":null},"body":"First the object is unpacked, start something using read_sha1_file.\nread_sha1_file: try packed object (fails)\nrun git repack -a -d\nread_sha1_file: try to read the loose object (fails)\nread_sha1_file: reread list of packs\nrun git repack -a -d so it will create a new pack\nread_sha1_file: tries to open the old packs, not the new one, and\n                fails\n\nAnyway this is quite improbable because normally a read_sha1_file is\nmuch faster than git repack -a -d.\n\ngdb commands to do that:\nshell git init\nshell seq 1 10 > a\nshell git add a\nshell git commit -m first\nfile git-cat-file\nbreak read_sha1_file\nrun -p HEAD:a\nnext\nnext\nshell git repack -a -d\nnext\nnext\nnext\nshell seq 11 20 >> a\nshell git add a\nshell git commit -m second\nshell git repack -a -d\ncontinue\n\ngdb session running the commands:\nGNU gdb 6.4.90-debian\nCopyright (C) 2006 Free Software Foundation, Inc.\nGDB is free software, covered by the GNU General Public License, and you are\nwelcome to change it and/or distribute copies of it under certain conditions.\nType \"show copying\" to see the conditions.\nThere is absolutely no warranty for GDB.  Type \"show warranty\" for details.\nThis GDB was configured as \"i486-linux-gnu\".\n$ shell git init\nInitialized empty Git repository in .git/\n$ shell seq 1 10 > a\n$ shell git add a\n$ shell git commit -m first\nCreated initial commit c520a6d82591b2c6654abe65418a2223302f927b\n 1 files changed, 10 insertions(+), 0 deletions(-)\n create mode 100644 a\n$ file git-cat-file\nReading symbols from /home/matled/local/bin/git-cat-file...done.\nUsing host libthread_db library \"/lib/tls/i686/cmov/libthread_db.so.1\".\n$ break read_sha1_file\nBreakpoint 1 at 0x8098959: file sha1_file.c, line 1483.\n$ run -p HEAD:a\nStarting program: /home/matled/local/bin/git-cat-file -p HEAD:a\nwarning: Lowest section in system-supplied DSO at 0xffffe000 is .hash at ffffe0b4\n\nBreakpoint 1, read_sha1_file (sha1=0xffcc0db8 \"Å ¦Ø%\\221²ÆeJ¾eA\\212\\\"#0/\\222{\", type=0xffcc0dd0 \"ÿÿÿÿ\", size=0xffcc0dcc)\n    at sha1_file.c:1483\n1483            buf = read_packed_sha1(sha1, type, size);\n$ next\n1484            if (buf)\n$ next\n1486            map = map_sha1_file(sha1, &mapsize);\n$ shell git repack -a -d\nGenerating pack...\nDone counting 3 objects.\nDeltifying 3 objects.\n 100% (3/3) done\nWriting 3 objects.\n 100% (3/3) done\nTotal 3 (delta 0), reused 0 (delta 0)\nPack pack-fcbc60879b35995a9b532543a3b072b83a50b510 created.\nRemoving unused objects 100%...\nDone.\n$ next\n1487            if (map) {\n$ next\n1492            reprepare_packed_git();\n$ next\n1493            return read_packed_sha1(sha1, type, size);\n$ shell seq 11 20 >> a\n$ shell git add a\n$ shell git commit -m second\nCreated commit 0bc9af2dfb8538abf9247ae282d0a2bd0cfc7b0d\n 1 files changed, 10 insertions(+), 0 deletions(-)\n$ shell git repack -a -d\nGenerating pack...\nDone counting 6 objects.\nDeltifying 6 objects.\n 100% (6/6) done\nWriting 6 objects.\n 100% (6/6) done\nTotal 6 (delta 0), reused 3 (delta 0)\nPack pack-ad55ad59fa078c3261550ebd9adf0035cf89fa63 created.\nRemoving unused objects 100%...\nDone.\n$ continue \nContinuing.\nfatal: packfile .git/objects/pack/pack-fcbc60879b35995a9b532543a3b072b83a50b510.pack cannot be opened\n\nProgram exited with code 0200.\n$ \n"},{"id":"33283","messageId":"20070201205934.GA19057@spearce.org","threadId":"6601","inReplyTo":"20070201112545.GA19855@moooo.ath.cx","subject":"Re: git repack -a -d is not safe","fromName":"Shawn O. Pearce","fromEmail":"spearce@spearce.org","sentAt":"2007-02-01T20:59:34Z","receivedAt":"2007-02-01T20:59:34Z","isPatch":false,"sender":{"key":"spearce@spearce.org","avatar":"https://avatars.githubusercontent.com/u/34844?v=4"},"body":"Matthias Lederhofer <matled@gmx.net> wrote:\n> First the object is unpacked, start something using read_sha1_file.\n> read_sha1_file: try packed object (fails)\n> run git repack -a -d\n> read_sha1_file: try to read the loose object (fails)\n> read_sha1_file: reread list of packs\n> run git repack -a -d so it will create a new pack\n> read_sha1_file: tries to open the old packs, not the new one, and\n>                 fails\n\nMy 4 patch series that I just posted should (partially) fix this\nproblem.  We cannot close it completely however as there always\nexists the potential of the OS to starve the reader and allow 2\nfull repacks between the time the reader notices a .idx file and\nthe time the reader could open the .pack.\n\nAt least now with my additional changes Git will report that a\npackfile is not usable, and then that the object cannot be found,\nand die.\n\nAll I can say is, wait at least a few minutes between repacks?  ;-)\n\n-- \nShawn.\n"},{"id":"33309","messageId":"Pine.LNX.4.63.0702020023170.22628@wbgn013.biozentrum.uni-wuerzburg.de","threadId":"6601","inReplyTo":"20070201205934.GA19057@spearce.org","subject":"Re: git repack -a -d is not safe","fromName":"Johannes Schindelin","fromEmail":"johannes.schindelin@gmx.de","sentAt":"2007-02-01T23:26:35Z","receivedAt":"2007-02-01T23:26:35Z","isPatch":false,"sender":{"key":"johannes.schindelin@gmx.de","avatar":"https://avatars.githubusercontent.com/u/127790?v=4"},"body":"Hi,\n\nOn Thu, 1 Feb 2007, Shawn O. Pearce wrote:\n\n> Matthias Lederhofer <matled@gmx.net> wrote:\n> > First the object is unpacked, start something using read_sha1_file.\n> > read_sha1_file: try packed object (fails)\n> > run git repack -a -d\n> > read_sha1_file: try to read the loose object (fails)\n> > read_sha1_file: reread list of packs\n> > run git repack -a -d so it will create a new pack\n> > read_sha1_file: tries to open the old packs, not the new one, and\n> >                 fails\n> \n> My 4 patch series that I just posted should (partially) fix this\n> problem.  We cannot close it completely however as there always\n> exists the potential of the OS to starve the reader and allow 2\n> full repacks between the time the reader notices a .idx file and\n> the time the reader could open the .pack.\n\nI may be misunderstanding the problem, but can't we just keep looking for \na new pack until either there is _no_ new pack to be mapped, or the object \nis found?\n\nCiao,\nDscho\n"}]}