)]}'
{"networking_odl/common/config.py":[{"author":{"_account_id":7921,"name":"Mike Kolesnik","email":"mkolesni@redhat.com","username":"mkolesni"},"change_message_id":"6a034066445e1645db7b9f1dab2cf69bd4478dd5","unresolved":false,"context_lines":[{"line_number":72,"context_line":"                help\u003d_(\u0027Enables the networking-odl driver to supply special\u0027"},{"line_number":73,"context_line":"                       \u0027 neutron ports of \"dhcp\" type to OpenDaylight\u0027"},{"line_number":74,"context_line":"                       \u0027 Controller for its use in providing DHCP Service.\u0027)),"},{"line_number":75,"context_line":"    cfg.IntOpt(\u0027periodic_task_recovery_factor\u0027, default\u003d4,"},{"line_number":76,"context_line":"               help\u003d_(\u0027Journal recovery starts after \u0027"},{"line_number":77,"context_line":"                      \u0027maintenance_interval * periodic_task_recovery_factor \u0027"},{"line_number":78,"context_line":"                      \u0027seconds any process unlocks the periodic task\u0027)),"}],"source_content_type":"text/x-python","patch_set":7,"id":"1f485f77_33bd3802","line":75,"range":{"start_line":75,"start_character":16,"end_line":75,"end_character":45},"updated":"2017-11-15 12:26:24.000000000","message":"IMHO a better name would be \u0027periodic_task_stale_lock_expiration\u0027","commit_id":"13fa1f9b6bd706f70e67106133deb14206f5227c"},{"author":{"_account_id":26507,"name":"Michel Peterson","email":"michel@redhat.com","username":"mpeterson"},"change_message_id":"f83fe7fded1c8b8fb81cdc604543e2e580b1b339","unresolved":false,"context_lines":[{"line_number":72,"context_line":"                help\u003d_(\u0027Enables the networking-odl driver to supply special\u0027"},{"line_number":73,"context_line":"                       \u0027 neutron ports of \"dhcp\" type to OpenDaylight\u0027"},{"line_number":74,"context_line":"                       \u0027 Controller for its use in providing DHCP Service.\u0027)),"},{"line_number":75,"context_line":"    cfg.IntOpt(\u0027periodic_task_recovery_factor\u0027, default\u003d4,"},{"line_number":76,"context_line":"               help\u003d_(\u0027Journal recovery starts after \u0027"},{"line_number":77,"context_line":"                      \u0027maintenance_interval * periodic_task_recovery_factor \u0027"},{"line_number":78,"context_line":"                      \u0027seconds any process unlocks the periodic task\u0027)),"}],"source_content_type":"text/x-python","patch_set":7,"id":"1f485f77_93d3ccd5","line":75,"range":{"start_line":75,"start_character":16,"end_line":75,"end_character":45},"in_reply_to":"1f485f77_33bd3802","updated":"2017-11-15 13:00:24.000000000","message":"I don\u0027t know about that specific name but a more descriptive name is necessary.","commit_id":"13fa1f9b6bd706f70e67106133deb14206f5227c"},{"author":{"_account_id":7921,"name":"Mike Kolesnik","email":"mkolesni@redhat.com","username":"mkolesni"},"change_message_id":"6a034066445e1645db7b9f1dab2cf69bd4478dd5","unresolved":false,"context_lines":[{"line_number":73,"context_line":"                       \u0027 neutron ports of \"dhcp\" type to OpenDaylight\u0027"},{"line_number":74,"context_line":"                       \u0027 Controller for its use in providing DHCP Service.\u0027)),"},{"line_number":75,"context_line":"    cfg.IntOpt(\u0027periodic_task_recovery_factor\u0027, default\u003d4,"},{"line_number":76,"context_line":"               help\u003d_(\u0027Journal recovery starts after \u0027"},{"line_number":77,"context_line":"                      \u0027maintenance_interval * periodic_task_recovery_factor \u0027"},{"line_number":78,"context_line":"                      \u0027seconds any process unlocks the periodic task\u0027)),"},{"line_number":79,"context_line":"]"},{"line_number":80,"context_line":""},{"line_number":81,"context_line":"cfg.CONF.register_opts(odl_opts, \"ml2_odl\")"}],"source_content_type":"text/x-python","patch_set":7,"id":"1f485f77_3352d8df","line":78,"range":{"start_line":76,"start_character":23,"end_line":78,"end_character":68},"updated":"2017-11-15 12:26:24.000000000","message":"This is quite confusing, I\u0027d state something along the lines of: \"The number of iterations a single periodic task has to pass before a lock held by another task is presumed stale and forcefully unlocked\"","commit_id":"13fa1f9b6bd706f70e67106133deb14206f5227c"},{"author":{"_account_id":26507,"name":"Michel Peterson","email":"michel@redhat.com","username":"mpeterson"},"change_message_id":"f83fe7fded1c8b8fb81cdc604543e2e580b1b339","unresolved":false,"context_lines":[{"line_number":73,"context_line":"                       \u0027 neutron ports of \"dhcp\" type to OpenDaylight\u0027"},{"line_number":74,"context_line":"                       \u0027 Controller for its use in providing DHCP Service.\u0027)),"},{"line_number":75,"context_line":"    cfg.IntOpt(\u0027periodic_task_recovery_factor\u0027, default\u003d4,"},{"line_number":76,"context_line":"               help\u003d_(\u0027Journal recovery starts after \u0027"},{"line_number":77,"context_line":"                      \u0027maintenance_interval * periodic_task_recovery_factor \u0027"},{"line_number":78,"context_line":"                      \u0027seconds any process unlocks the periodic task\u0027)),"},{"line_number":79,"context_line":"]"},{"line_number":80,"context_line":""},{"line_number":81,"context_line":"cfg.CONF.register_opts(odl_opts, \"ml2_odl\")"}],"source_content_type":"text/x-python","patch_set":7,"id":"1f485f77_73dcd0e3","line":78,"range":{"start_line":76,"start_character":23,"end_line":78,"end_character":68},"in_reply_to":"1f485f77_3352d8df","updated":"2017-11-15 13:00:24.000000000","message":"+1","commit_id":"13fa1f9b6bd706f70e67106133deb14206f5227c"}],"networking_odl/journal/periodic_task.py":[{"author":{"_account_id":333,"name":"Isaku Yamahata","email":"isaku.yamahata@gmail.com","username":"yamahata"},"change_message_id":"dd422f88d5dd1fd0d20e6644441be50a8407258c","unresolved":false,"context_lines":[{"line_number":26,"context_line":""},{"line_number":27,"context_line":"class PeriodicTask(object):"},{"line_number":28,"context_line":"    # Recovery time is multiple of maintenance_interval and defined variable"},{"line_number":29,"context_line":"    RECOVERY_TIME_FACTOR \u003d 10"},{"line_number":30,"context_line":""},{"line_number":31,"context_line":"    def __init__(self, task, interval):"},{"line_number":32,"context_line":"        self.task \u003d task"}],"source_content_type":"text/x-python","patch_set":3,"id":"9f436f4f_83fe20ac","line":29,"range":{"start_line":29,"start_character":27,"end_line":29,"end_character":29},"updated":"2017-08-18 20:07:11.000000000","message":"hmm, this would be arguable. I would use 4 or something.\n But it\u0027s not essential part.","commit_id":"e7216d3a5a319f0e75d9a36f13872385b21c0842"},{"author":{"_account_id":7921,"name":"Mike Kolesnik","email":"mkolesni@redhat.com","username":"mkolesni"},"change_message_id":"882188862e33d7a39bc2b9655efe65d5da99207b","unresolved":false,"context_lines":[{"line_number":26,"context_line":""},{"line_number":27,"context_line":"class PeriodicTask(object):"},{"line_number":28,"context_line":"    # Recovery time is multiple of maintenance_interval and defined variable"},{"line_number":29,"context_line":"    RECOVERY_TIME_FACTOR \u003d 10"},{"line_number":30,"context_line":""},{"line_number":31,"context_line":"    def __init__(self, task, interval):"},{"line_number":32,"context_line":"        self.task \u003d task"}],"source_content_type":"text/x-python","patch_set":3,"id":"5f2577a7_48872711","line":29,"range":{"start_line":29,"start_character":27,"end_line":29,"end_character":29},"in_reply_to":"9f436f4f_83fe20ac","updated":"2017-09-12 15:31:41.000000000","message":"I agree, let\u0027s have this factor configurable and with a sane default.","commit_id":"e7216d3a5a319f0e75d9a36f13872385b21c0842"},{"author":{"_account_id":26507,"name":"Michel Peterson","email":"michel@redhat.com","username":"mpeterson"},"change_message_id":"537b246fb733c0a29e8db38d91d25f4f34b0fc84","unresolved":false,"context_lines":[{"line_number":67,"context_line":"        return db.was_task_executed_after_interval("},{"line_number":68,"context_line":"            context.session, self.task, self.interval)"},{"line_number":69,"context_line":""},{"line_number":70,"context_line":"    def is_recovery_not_needed(self, context):"},{"line_number":71,"context_line":""},{"line_number":72,"context_line":"        interval \u003d self.interval * self.RECOVERY_TIME_FACTOR"},{"line_number":73,"context_line":"        return db.was_task_executed_after_interval("}],"source_content_type":"text/x-python","patch_set":3,"id":"9f436f4f_ab3faeb3","line":70,"range":{"start_line":70,"start_character":4,"end_line":70,"end_character":30},"updated":"2017-08-20 12:54:17.000000000","message":"It\u0027s easier to comprehend if the function is called `is_recovery_needed` and when you test you test for the `not is_recovery_needed(...)`","commit_id":"e7216d3a5a319f0e75d9a36f13872385b21c0842"},{"author":{"_account_id":26507,"name":"Michel Peterson","email":"michel@redhat.com","username":"mpeterson"},"change_message_id":"537b246fb733c0a29e8db38d91d25f4f34b0fc84","unresolved":false,"context_lines":[{"line_number":63,"context_line":"            LOG.exception(\"Failed during periodic task operation %s.\","},{"line_number":64,"context_line":"                          op_details)"},{"line_number":65,"context_line":""},{"line_number":66,"context_line":"    def task_already_executed_recently(self, context):"},{"line_number":67,"context_line":"        return db.was_task_executed_after_interval("},{"line_number":68,"context_line":"            context.session, self.task, self.interval)"},{"line_number":69,"context_line":""},{"line_number":70,"context_line":"    def is_recovery_not_needed(self, context):"},{"line_number":71,"context_line":""},{"line_number":72,"context_line":"        interval \u003d self.interval * self.RECOVERY_TIME_FACTOR"},{"line_number":73,"context_line":"        return db.was_task_executed_after_interval("},{"line_number":74,"context_line":"            context.session, self.task, interval)"},{"line_number":75,"context_line":""},{"line_number":76,"context_line":"    def execute_ops(self):"},{"line_number":77,"context_line":"        LOG.info(\"Starting %s periodic task.\", self.task)"}],"source_content_type":"text/x-python","patch_set":3,"id":"9f436f4f_4b3162ec","line":74,"range":{"start_line":66,"start_character":3,"end_line":74,"end_character":49},"updated":"2017-08-20 12:54:17.000000000","message":"They are both basically doing the same but the latter with the recovery time factor.","commit_id":"e7216d3a5a319f0e75d9a36f13872385b21c0842"},{"author":{"_account_id":13912,"name":"rajiv","email":"thenakliman@gmail.com","username":"rajiv.kumar"},"change_message_id":"88061c0cf88d493165f81b8f964914db4bfd786c","unresolved":false,"context_lines":[{"line_number":86,"context_line":"            return"},{"line_number":87,"context_line":""},{"line_number":88,"context_line":"        if (not db.lock_periodic_task(context.session, self.task)) and ("},{"line_number":89,"context_line":"           self.is_recovery_not_needed(context)):"},{"line_number":90,"context_line":""},{"line_number":91,"context_line":"            LOG.info(\"Periodic %s task already running task\", self.task)"},{"line_number":92,"context_line":"            return"}],"source_content_type":"text/x-python","patch_set":3,"id":"9f436f4f_edee008a","line":89,"updated":"2017-08-18 15:49:20.000000000","message":"Multiple process might start syncing at the same time, thinking they have acquired the lock. To make sure, only one process sync, following approach can be taken, For example\n\n1) A column name, host should be added into periodic table to debug things easily. It will make sure, that if a process is restarted by some clustering services then it can release lock before XXX amount time.\n\n2) After XXX amount of time rather than moving to syncing, lock should be release by one of the process not owning the lock and then they should compete for lock normally.\n\nRemember point 1, can make sure to release lock before XXX amount.\n\n3) Use column version(like dependency calculations) to make sure that a legally acquired lock is not flushed by other process.\n\nMore approaches are welcome.","commit_id":"e7216d3a5a319f0e75d9a36f13872385b21c0842"},{"author":{"_account_id":26507,"name":"Michel Peterson","email":"michel@redhat.com","username":"mpeterson"},"change_message_id":"537b246fb733c0a29e8db38d91d25f4f34b0fc84","unresolved":false,"context_lines":[{"line_number":80,"context_line":"        # Lock make sure that periodic task is executed only after"},{"line_number":81,"context_line":"        # specified interval. It makes sure that maintenance tasks"},{"line_number":82,"context_line":"        # are not executed back to back."},{"line_number":83,"context_line":"        if self.task_already_executed_recently(context):"},{"line_number":84,"context_line":"            LOG.info(\"Periodic %s task executed after periodic interval \""},{"line_number":85,"context_line":"                     \"Skipping execution.\", self.task)"},{"line_number":86,"context_line":"            return"},{"line_number":87,"context_line":""},{"line_number":88,"context_line":"        if (not db.lock_periodic_task(context.session, self.task)) and ("},{"line_number":89,"context_line":"           self.is_recovery_not_needed(context)):"},{"line_number":90,"context_line":""},{"line_number":91,"context_line":"            LOG.info(\"Periodic %s task already running task\", self.task)"},{"line_number":92,"context_line":"            return"}],"source_content_type":"text/x-python","patch_set":3,"id":"9f436f4f_2b4cde74","line":89,"range":{"start_line":83,"start_character":0,"end_line":89,"end_character":49},"updated":"2017-08-20 12:54:17.000000000","message":"Well, now that it is inside a worker that only spawns once, it shouldn\u0027t be an issue. However, if we do want to make it more correctly, we can create a lock class that implements PEP-343 (with-stmt) and that creates a row lock in the DB, like Isaku proposes. Then we do the operations inside a with block, thus making sure that clean up is always done.\n\nOther than that, and in continuation of my previous comment, it doesn\u0027t seem right to make a similar check twice.","commit_id":"e7216d3a5a319f0e75d9a36f13872385b21c0842"},{"author":{"_account_id":333,"name":"Isaku Yamahata","email":"isaku.yamahata@gmail.com","username":"yamahata"},"change_message_id":"dd422f88d5dd1fd0d20e6644441be50a8407258c","unresolved":false,"context_lines":[{"line_number":86,"context_line":"            return"},{"line_number":87,"context_line":""},{"line_number":88,"context_line":"        if (not db.lock_periodic_task(context.session, self.task)) and ("},{"line_number":89,"context_line":"           self.is_recovery_not_needed(context)):"},{"line_number":90,"context_line":""},{"line_number":91,"context_line":"            LOG.info(\"Periodic %s task already running task\", self.task)"},{"line_number":92,"context_line":"            return"}],"source_content_type":"text/x-python","patch_set":3,"id":"9f436f4f_23277467","line":89,"in_reply_to":"9f436f4f_edee008a","updated":"2017-08-18 20:07:11.000000000","message":"we can use row locking or update where (timeout check) so that we can guarantee that only single thread can recover it.","commit_id":"e7216d3a5a319f0e75d9a36f13872385b21c0842"},{"author":{"_account_id":7921,"name":"Mike Kolesnik","email":"mkolesni@redhat.com","username":"mkolesni"},"change_message_id":"6a034066445e1645db7b9f1dab2cf69bd4478dd5","unresolved":false,"context_lines":[{"line_number":108,"context_line":"            return"},{"line_number":109,"context_line":""},{"line_number":110,"context_line":"        if not self._lock_task(context):"},{"line_number":111,"context_line":"            # NOTE(rajivk): Makes sure, it is executed only if task"},{"line_number":112,"context_line":"            # is already running."},{"line_number":113,"context_line":"            if self._is_recovery_needed(context):"},{"line_number":114,"context_line":"                LOG.info(\"Recoverying periodic task: %s\", self.task)"},{"line_number":115,"context_line":"                self._clear_and_unlock_task(context)"}],"source_content_type":"text/x-python","patch_set":7,"id":"1f485f77_73e850e1","line":112,"range":{"start_line":111,"start_character":12,"end_line":112,"end_character":33},"updated":"2017-11-15 12:26:24.000000000","message":"I\u0027m not sure what this comment means..","commit_id":"13fa1f9b6bd706f70e67106133deb14206f5227c"},{"author":{"_account_id":7921,"name":"Mike Kolesnik","email":"mkolesni@redhat.com","username":"mkolesni"},"change_message_id":"6a034066445e1645db7b9f1dab2cf69bd4478dd5","unresolved":false,"context_lines":[{"line_number":111,"context_line":"            # NOTE(rajivk): Makes sure, it is executed only if task"},{"line_number":112,"context_line":"            # is already running."},{"line_number":113,"context_line":"            if self._is_recovery_needed(context):"},{"line_number":114,"context_line":"                LOG.info(\"Recoverying periodic task: %s\", self.task)"},{"line_number":115,"context_line":"                self._clear_and_unlock_task(context)"},{"line_number":116,"context_line":"                LOG.info(\"Recovered Periodic task: %s\", self.task)"},{"line_number":117,"context_line":"            else:"}],"source_content_type":"text/x-python","patch_set":7,"id":"1f485f77_13c47c5e","line":114,"range":{"start_line":114,"start_character":20,"end_line":114,"end_character":24},"updated":"2017-11-15 12:26:24.000000000","message":"warn?","commit_id":"13fa1f9b6bd706f70e67106133deb14206f5227c"}]}
