)]}'
{"/COMMIT_MSG":[{"author":{"_account_id":1179,"name":"Clay Gerrard","email":"clay.gerrard@gmail.com","username":"clay-gerrard"},"change_message_id":"1ce3f6d98bd17942a028748c17c98cf045383270","unresolved":true,"context_lines":[{"line_number":9,"context_line":"Currently the db_replicator will clean up files older then reclaim_age"},{"line_number":10,"context_line":"in the device_tmp directory, but it doesn\u0027t clean up any old .tmp files"},{"line_number":11,"context_line":"located in the db_dir directory. These .tmp files are created in"},{"line_number":12,"context_line":"initialize broker method, which will also then do a rename to the final"},{"line_number":13,"context_line":"db file name. We\u0027ve found a bunch in production along side the db files"},{"line_number":14,"context_line":"themselves so there must be an edgecase where it\u0027s not renamed, maybe a"},{"line_number":15,"context_line":"race condition with replication or the PUT."}],"source_content_type":"text/x-gerrit-commit-message","patch_set":6,"id":"923bdd4e_ef8e9f5d","line":12,"updated":"2026-01-16 17:40:44.000000000","message":"this was the pre-existing case","commit_id":"0862c231a28bb335a37fc407c8771fb15beb80c2"},{"author":{"_account_id":1179,"name":"Clay Gerrard","email":"clay.gerrard@gmail.com","username":"clay-gerrard"},"change_message_id":"1ce3f6d98bd17942a028748c17c98cf045383270","unresolved":true,"context_lines":[{"line_number":15,"context_line":"race condition with replication or the PUT."},{"line_number":16,"context_line":""},{"line_number":17,"context_line":"In anycase, we now want to move the sharding freshdbs to be initially"},{"line_number":18,"context_line":"created in the same manner, \u003cdb_dir\u003e/fresh\u003cuuid4\u003e.db.tmp and then rename"},{"line_number":19,"context_line":"once all configured. So there is a chance that these might be left"},{"line_number":20,"context_line":"around from time to time. So would be a good idea to clean them up."},{"line_number":21,"context_line":""}],"source_content_type":"text/x-gerrit-commit-message","patch_set":6,"id":"5aef4cf7_9742a1af","line":18,"updated":"2026-01-16 17:40:44.000000000","message":"this is new as of the previous commit, but it\u0027s now in the same boat.","commit_id":"0862c231a28bb335a37fc407c8771fb15beb80c2"}],"/PATCHSET_LEVEL":[{"author":{"_account_id":7233,"name":"Matthew Oliver","email":"matt@oliver.net.au","username":"mattoliverau"},"change_message_id":"f613b265572b568a20de8596466046d5a266def6","unresolved":false,"context_lines":[],"source_content_type":"","patch_set":1,"id":"fb487082_0b9b7659","updated":"2025-11-11 01:29:39.000000000","message":"Still writing tests for this one","commit_id":"730f7ed4bfd5c027f3bf1e48c304ec4e7db70095"},{"author":{"_account_id":5314,"name":"Brian Rosmaita","email":"rosmaita.fossdev@gmail.com","username":"brian-rosmaita"},"change_message_id":"066bf0cf5022bb95be5496fc10c4d797d10515cf","unresolved":false,"context_lines":[],"source_content_type":"","patch_set":6,"id":"5b57c77a_37f69d9a","updated":"2026-01-20 15:30:12.000000000","message":"Just want to add a note that the problematic test issue has been addressed by https://review.opendev.org/c/openstack/swift/+/973927","commit_id":"0862c231a28bb335a37fc407c8771fb15beb80c2"},{"author":{"_account_id":5314,"name":"Brian Rosmaita","email":"rosmaita.fossdev@gmail.com","username":"brian-rosmaita"},"change_message_id":"3f19ac4f33467e6ce9bb4dbdb107509d2f23299a","unresolved":false,"context_lines":[],"source_content_type":"","patch_set":6,"id":"6fea70b6_390dce73","updated":"2026-01-20 13:58:33.000000000","message":"There may be a problem with the unit test in this patch.  See comment inline.","commit_id":"0862c231a28bb335a37fc407c8771fb15beb80c2"},{"author":{"_account_id":1179,"name":"Clay Gerrard","email":"clay.gerrard@gmail.com","username":"clay-gerrard"},"change_message_id":"1ce3f6d98bd17942a028748c17c98cf045383270","unresolved":false,"context_lines":[],"source_content_type":"","patch_set":6,"id":"8fd1a3f3_371c963e","updated":"2026-01-16 17:40:44.000000000","message":"this is good - we should definitely clean up these .tmp dbs that get stale from failed broker.initialize calls.  KUDOS!","commit_id":"0862c231a28bb335a37fc407c8771fb15beb80c2"}],"swift/common/db_replicator.py":[{"author":{"_account_id":1179,"name":"Clay Gerrard","email":"clay.gerrard@gmail.com","username":"clay-gerrard"},"change_message_id":"1ce3f6d98bd17942a028748c17c98cf045383270","unresolved":true,"context_lines":[{"line_number":646,"context_line":""},{"line_number":647,"context_line":"    def _reclaim_tmp_dbs(self, broker, now):"},{"line_number":648,"context_line":"        fnames \u003d listdir(broker.db_dir)"},{"line_number":649,"context_line":"        fnames \u003d [os.path.join(broker.db_dir, fname) for fname in fnames"},{"line_number":650,"context_line":"                  if fname.endswith(\u0027.tmp\u0027)]"},{"line_number":651,"context_line":"        unlink_paths_older_than(fnames, now - self.reclaim_age)"},{"line_number":652,"context_line":""}],"source_content_type":"text/x-python","patch_set":6,"id":"ac7d7165_bc730ddd","line":649,"updated":"2026-01-16 17:40:44.000000000","message":"I think I would have either put the `listdir` in the list comprehension or used a new variable name like `file_paths` - this isn\u0027t *just* the \"file *names*\" anymore.\n\nSaving grace is the method extraction means you\u0027re really only trying to grok 3 lines of code - so it\u0027s pretty managable, kudos on the method extraction.","commit_id":"0862c231a28bb335a37fc407c8771fb15beb80c2"},{"author":{"_account_id":1179,"name":"Clay Gerrard","email":"clay.gerrard@gmail.com","username":"clay-gerrard"},"change_message_id":"1ce3f6d98bd17942a028748c17c98cf045383270","unresolved":true,"context_lines":[{"line_number":648,"context_line":"        fnames \u003d listdir(broker.db_dir)"},{"line_number":649,"context_line":"        fnames \u003d [os.path.join(broker.db_dir, fname) for fname in fnames"},{"line_number":650,"context_line":"                  if fname.endswith(\u0027.tmp\u0027)]"},{"line_number":651,"context_line":"        unlink_paths_older_than(fnames, now - self.reclaim_age)"},{"line_number":652,"context_line":""},{"line_number":653,"context_line":"    def _reclaim(self, broker, now\u003dNone):"},{"line_number":654,"context_line":"        if not now:"}],"source_content_type":"text/x-python","patch_set":6,"id":"8de5e7b2_2bb22bcc","line":651,"updated":"2026-01-16 17:40:44.000000000","message":"seems reasonable:\n\n```\ndef unlink_paths_older_than(filepaths, mtime):\n    \"\"\"\n    Remove any files from the given list that were\n    last modified before mtime.\n\n    :param filepaths: a list of strings, the full paths of files to check\n    :param mtime: timestamp of oldest file to keep\n    \"\"\"\n```","commit_id":"0862c231a28bb335a37fc407c8771fb15beb80c2"}],"test/unit/common/test_db_replicator.py":[{"author":{"_account_id":7233,"name":"Matthew Oliver","email":"matt@oliver.net.au","username":"mattoliverau"},"change_message_id":"bef12d035e551fcb96bb8497f063ed5cadd124d7","unresolved":true,"context_lines":[{"line_number":2028,"context_line":"        self.assertEqual([\u0027another_tmp_file.db.tmp\u0027,"},{"line_number":2029,"context_line":"                          \u0027somethingelse.txt\u0027,"},{"line_number":2030,"context_line":"                          \u0027the_db.db\u0027],"},{"line_number":2031,"context_line":"                         listdir(db_dir))"},{"line_number":2032,"context_line":""},{"line_number":2033,"context_line":""},{"line_number":2034,"context_line":"class TestHandoffsOnly(unittest.TestCase):"}],"source_content_type":"text/x-python","patch_set":3,"id":"d544370d_4fc18d65","line":2031,"updated":"2025-12-05 07:11:40.000000000","message":"Should add some more asserts, but at least this is something","commit_id":"ba844973b66cd740fbf36f0fcf9e4e2776a975b3"},{"author":{"_account_id":5314,"name":"Brian Rosmaita","email":"rosmaita.fossdev@gmail.com","username":"brian-rosmaita"},"change_message_id":"3f19ac4f33467e6ce9bb4dbdb107509d2f23299a","unresolved":true,"context_lines":[{"line_number":2020,"context_line":""},{"line_number":2021,"context_line":"        # OK now let\u0027s try and reclaim old tmp files"},{"line_number":2022,"context_line":"        with mock.patch(\u0027os.path.getmtime\u0027,"},{"line_number":2023,"context_line":"                        side_effect\u003dcycle(timestamps)) as mock_getmtime:"},{"line_number":2024,"context_line":"            replicator \u003d ConcreteReplicator({\u0027reclaim_age\u0027: 10})"},{"line_number":2025,"context_line":"            replicator._reclaim_tmp_dbs(broker, 18)"},{"line_number":2026,"context_line":""}],"source_content_type":"text/x-python","patch_set":6,"id":"30ec10c4_d5ea2c9c","line":2023,"updated":"2026-01-20 13:58:33.000000000","message":"This test is currently failing in the requirements gate on patch https://review.opendev.org/c/openstack/requirements/+/971428 (which shouldn\u0027t have any effect on this code at all).\n\nThis is a dumb question, but aren\u0027t you making an assumption that os.path.getmtime will be called on the files in the order you specified in lines 2011-2012, if you\u0027re going to be able to list the remaining files at lines 2029-2031?  The results in the test (see example [0]) show that 2 files are being removed, it\u0027s just that they are different files than you have in your line 2029 assertion.  So my theory is that in the gate, for some reason, when _reclaim_tmp_dbs() gets the list of tmp files, it\u0027s in a different order, and hence the timestamps are applied differently.","commit_id":"0862c231a28bb335a37fc407c8771fb15beb80c2"},{"author":{"_account_id":5314,"name":"Brian Rosmaita","email":"rosmaita.fossdev@gmail.com","username":"brian-rosmaita"},"change_message_id":"67012edddf47e19de024679d0c686e07fe7241dd","unresolved":true,"context_lines":[{"line_number":2020,"context_line":""},{"line_number":2021,"context_line":"        # OK now let\u0027s try and reclaim old tmp files"},{"line_number":2022,"context_line":"        with mock.patch(\u0027os.path.getmtime\u0027,"},{"line_number":2023,"context_line":"                        side_effect\u003dcycle(timestamps)) as mock_getmtime:"},{"line_number":2024,"context_line":"            replicator \u003d ConcreteReplicator({\u0027reclaim_age\u0027: 10})"},{"line_number":2025,"context_line":"            replicator._reclaim_tmp_dbs(broker, 18)"},{"line_number":2026,"context_line":""}],"source_content_type":"text/x-python","patch_set":6,"id":"c6c22689_0bf7a5fc","line":2023,"in_reply_to":"30ec10c4_d5ea2c9c","updated":"2026-01-20 14:01:47.000000000","message":"[0] https://zuul.opendev.org/t/openstack/build/f25232c5d495402382ad421935637af2/log/job-output.txt#11735","commit_id":"0862c231a28bb335a37fc407c8771fb15beb80c2"},{"author":{"_account_id":1179,"name":"Clay Gerrard","email":"clay.gerrard@gmail.com","username":"clay-gerrard"},"change_message_id":"1ce3f6d98bd17942a028748c17c98cf045383270","unresolved":true,"context_lines":[{"line_number":2022,"context_line":"        with mock.patch(\u0027os.path.getmtime\u0027,"},{"line_number":2023,"context_line":"                        side_effect\u003dcycle(timestamps)) as mock_getmtime:"},{"line_number":2024,"context_line":"            replicator \u003d ConcreteReplicator({\u0027reclaim_age\u0027: 10})"},{"line_number":2025,"context_line":"            replicator._reclaim_tmp_dbs(broker, 18)"},{"line_number":2026,"context_line":""},{"line_number":2027,"context_line":"        # It should only look at the tmp files and because of the cycle only"},{"line_number":2028,"context_line":"        # 2 of them should have been removed"}],"source_content_type":"text/x-python","patch_set":6,"id":"358ec439_9a504f82","line":2025,"updated":"2026-01-16 17:40:44.000000000","message":"I find the math here a little confusing, maybe because we\u0027re operating on such a TINY reclaim age SO far in the PAST.\n\n```\n(Pdb) print(datetime.fromtimestamp(5))\n1970-01-01 00:00:05\n(Pdb) print(datetime.fromtimestamp(10))\n1970-01-01 00:00:10\n(Pdb) print(datetime.fromtimestamp(18))\n1970-01-01 00:00:18\n(Pdb) print(datetime.fromtimestamp(18 - 10))\n1970-01-01 00:00:08\n```\n\nok, so the _reclaim_tmp_dbs takes \"now\" as an agrument, so way back at epoch+18s we checked for any db\u0027s older than 10s ago, and so the epoch+5s are old enough and the epoch+10s are not yet.","commit_id":"0862c231a28bb335a37fc407c8771fb15beb80c2"},{"author":{"_account_id":1179,"name":"Clay Gerrard","email":"clay.gerrard@gmail.com","username":"clay-gerrard"},"change_message_id":"1ce3f6d98bd17942a028748c17c98cf045383270","unresolved":true,"context_lines":[{"line_number":2029,"context_line":"        self.assertEqual(sorted([\u0027another_tmp_file.db.tmp\u0027,"},{"line_number":2030,"context_line":"                                 \u0027somethingelse.txt\u0027,"},{"line_number":2031,"context_line":"                                 \u0027the_db.db\u0027]),"},{"line_number":2032,"context_line":"                         sorted(listdir(db_dir)))"},{"line_number":2033,"context_line":"        self.assertTrue(mock_getmtime.called)"},{"line_number":2034,"context_line":"        # We should\u0027ve only called getmtime on the files ending in .tmp so"},{"line_number":2035,"context_line":"        # 3 times."}],"source_content_type":"text/x-python","patch_set":6,"id":"3c808f47_37ab1187","line":2032,"updated":"2026-01-16 17:40:44.000000000","message":"I guess this is the most important assertion - some of the \"old\" .tmp dbs are gone.","commit_id":"0862c231a28bb335a37fc407c8771fb15beb80c2"},{"author":{"_account_id":1179,"name":"Clay Gerrard","email":"clay.gerrard@gmail.com","username":"clay-gerrard"},"change_message_id":"1ce3f6d98bd17942a028748c17c98cf045383270","unresolved":true,"context_lines":[{"line_number":2039,"context_line":"            mock.call(os.path.join(db_dir, \u0027another_tmp_file.db.tmp\u0027)),"},{"line_number":2040,"context_line":"            mock.call(os.path.join(db_dir, \u0027some_temp_file.tmp\u0027))]"},{"line_number":2041,"context_line":"        self.assertEqual(sorted(expected_paths_called),"},{"line_number":2042,"context_line":"                         sorted(list(mock_getmtime.call_args_list)))"},{"line_number":2043,"context_line":""},{"line_number":2044,"context_line":""},{"line_number":2045,"context_line":"class TestHandoffsOnly(unittest.TestCase):"}],"source_content_type":"text/x-python","patch_set":6,"id":"4d43ccda_8d879b89","line":2042,"updated":"2026-01-16 17:40:44.000000000","message":"... but this is good too - we\u0027re checking mtime on all the .tmp db - so there shouldn\u0027t be any race with initializing dbs.","commit_id":"0862c231a28bb335a37fc407c8771fb15beb80c2"}]}
