Skip to content

DomInfoUpdateTask polling period DOM_INFO_UPDATE_PERIOD_SECS improperly delays polling #756

@aditya-nexthop

Description

@aditya-nexthop

DOM_INFO_UPDATE_PERIOD_SECS should be the time delay between polling information from a specified interface, say Ethernet0

So the expectation is:

Polled Ethernet0 @ t=0
Polled Ethernet4 @ t = ...
...
Polled Ethernet200 @ t = X

Polled Ethernet0 @ t=DOM_INFO_UPDATE_PERIOD_SECS

Instead what we see is:

Polled Ethernet0 @ t=0
Polled Ethernet4 @ t = ...
...
Polled Ethernet200 @ t = X

Polled Ethernet0 @ t=X+DOM_INFO_UPDATE_PERIOD_SECS

This means no information is polled from any transceiver for DOM_INFO_UPDATE_PERIOD_SECS after the polling loop completes, even though more time than DOM_INFO_UPDATE_PERIOD_SECS may have elapsed since Ethernet0 was polled.

This is due to the following code:

class DomInfoUpdateBase(threading.Thread):
...
    def task_worker(self):
...
        # Start loop to update dom info in DB periodically and handle port change events
        while not self.task_stopping_event.is_set():
            # Check if periodic db update is needed
            if next_periodic_db_update_time <= datetime.datetime.now():
                is_periodic_db_update_needed = True
...
            for physical_port, logical_ports in self.port_mapping.physical_to_logical.items():
...
            if is_periodic_db_update_needed:
                next_periodic_db_update_time = datetime.datetime.now() + \          <<===============
                                               datetime.timedelta(seconds=dom_info_update_periodic_secs)
                is_periodic_db_update_needed = False

In order to enforce proper timing delay, now should be set at the start of the loop and used at the highlighted place to set next_periodic_db_update_time

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions