Use mongo $bit operation instead of $inc for tracking agent liveness

Bug #1699678 reported by John A Meinel
6
This bug affects 1 person
Affects Status Importance Assigned to Milestone
Canonical Juju
Fix Released
Medium
John A Meinel
2.2
Fix Released
Medium
John A Meinel

Bug Description

https://docs.mongodb.com/manual/reference/operator/update/bit/
Bitwise OR was supported all the way back to Mongo 2.2

We currently have to manage a whole "presence.beings" table to ensure that we never ping the same slot 2 times because we are using a $inc instead of a bitwise or.
However, bitwise or has been supported since Mongo 2.2. Which means we could just reuse any slot for a given operator instead of growing them without bound and having to prune them, etc.

We'd also need to know whether $inc vs $or is going to be a performance issue.

Revision history for this message
John A Meinel (jameinel) wrote :

https://github.com/juju/juju/pull/7863

addresses this and bug #1703675 at the same time.

Changed in juju:
assignee: nobody → John A Meinel (jameinel)
status: Triaged → In Progress
Revision history for this message
John A Meinel (jameinel) wrote :

So this did land, but it turns out that Mongo 2.4 "supports" $bit. Specifically, in 2.4 it fails to create a document if you specify upsert:

3.2:
> db.foo.update({_id: "a"}, {$bit: {"a": {"or": NumberLong(1)}}}, {upsert: 1})
WriteResult({ "nMatched" : 0, "nUpserted" : 1, "nModified" : 0, "_id" : "a" })
> db.foo.find()
{ "_id" : "a", "a" : NumberLong(1) }
>

2.4:
> db.foo.update({_id: "a"}, {$bit: {"a": {"or": NumberLong(1)}}}, {upsert: 1})
WriteResult({ "nMatched" : 0, "nUpserted" : 0 })
> db.foo.find()

And since we still use 2.4 on Trusty, we either need to special case this, or not use $bit.

Revision history for this message
John A Meinel (jameinel) wrote :

This should have landed in 2.3-beta1

Changed in juju:
milestone: none → 2.3-beta2
status: In Progress → Fix Released
Changed in juju:
milestone: 2.3-beta2 → 2.3-beta1
To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.