Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

How to avoid duplicates in a directory #48

Closed
farshidtz opened this issue Aug 10, 2020 · 5 comments
Closed

How to avoid duplicates in a directory #48

farshidtz opened this issue Aug 10, 2020 · 5 comments
Assignees

Comments

@farshidtz
Copy link
Member

farshidtz commented Aug 10, 2020

Registration of TDs using non-idempotent HTTP POST method enables creation of anonymous TDs (TDs without id attribute). The producer can distinguish between the created TDs using the unique-system generated IDs given in the response Location header.

A side-effect of this is that clients will be able to register duplicate TDs accidentally or on purpose.

Need to clarify:

  • What are the use cases where a duplicate TD is desired?
  • How can we mitigate accidental duplicates (deduplication)?
@farshidtz
Copy link
Member Author

A use case for valid duplicates is for devices which have event interaction affordances to publish/subscribe to an MQTT broker under the same topic or to call an external webhook endpoint whenever data is available.

The TD will be duplicate if it is anonymous (for whatever reason). The system-generated IDs (generated by TDD) may be used to locate the TD or update it. The events produced by these devices may include the ID or have some other identifier.

Example 34 without ID:

{   
    "@context": "https://www.w3.org/2019/wot/td/v1",
    "title": "MyIlluminanceSensor",
    "securityDefinitions": {"nosec_sc": {"scheme": "nosec"}},
    "security": ["nosec_sc"],
    "events": {
        "illuminance": {
            "data":{"type": "integer"},
            "forms": [
                {
                    "href": "mqtt://192.168.1.187:1883/illuminance",
                    "contentType" : "text/plain",
                    "op" : "subscribeevent"
                }
            ]
        }
    } 
}

mqtt://192.168.1.187:1883/illuminance is the the broker URI which can be reused by all luminance sensors.

@farshidtz
Copy link
Member Author

We should note that duplicates can also happen unintentionally when TDs are not anonymous.

In a non-WoT context, we had applications which were generating UUIDs at startup time and using them to register themselves into a directory. One application (service) was crashing and restarting continuously, creating a unique registration every time, until it was fixed. In the meantime, it created thousands of unique looking registrations.

To avoid such scenarios, we introduced mandatory, short TTL for registrations to eventually cleanup accidental registrations and only keep those that are actively maintained (e.g. with a keep alive mechanism). Note: issue #18 relates to this.

@egekorkan
Copy link
Contributor

Regarding the MQTT comment above, in a way, in MQTT case, a TD describes the broker and not really the Thing.

@farshidtz
Copy link
Member Author

I propose closing this issue for the following reasons:

@mmccool
Copy link
Contributor

mmccool commented Jul 4, 2022

Discussed July 4, 2022; will close. Resolved (or well, users of the directory are responsible for not using duplicate ids unless they mean to do an update).

@mmccool mmccool closed this as completed Jul 4, 2022
This was referenced Jul 4, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants