[SERVER-79489] time-series bucket change-stream events lack `bucketRoundingSeconds`. Created: 30/Jul/23  Updated: 30/Jan/24

Status: Backlog
Project: Core Server
Component/s: None
Affects Version/s: None
Fix Version/s: None

Type: Bug Priority: Major - P3
Reporter: Felipe Gasper Assignee: Backlog - Query Execution
Resolution: Unresolved Votes: 0
Labels: bkp
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified

Issue Links:
Backports
Related
Assigned Teams:
Query Execution
Operating System: ALL
Backport Requested:
v7.3
Participants:

 Description   

Whenever a time-series collection’s granularity changes, the resulting change-stream event always seems to lack `bucketRoundingSeconds`.

This may complicate delivery of mongosync’s time-series collection support.



 Comments   
Comment by Felipe Gasper [ 08/Aug/23 ]

ana.meza@mongodb.com: This doesn’t appear to impede mongosync’s time-series collection support in v6 thanks to the workaround that mickey.winters@mongodb.com mentioned.

At present our logic is:

+func FixGranularity(props bson.D) bson.D {
+       propsMap := props.Map()
+
+       // If we got granularity, then the server will actually forbid
+       // bucketRoundingSeconds. So we should be done.
+       if _, hasGranularity := propsMap["granularity"]; hasGranularity {
+               return props
+       }
+
+       // Check for bucketMaxSpanSeconds (“mss”).
+       if mss, hasMSS := propsMap["bucketMaxSpanSeconds"]; hasMSS {
+
+               // If we got mss *and* rounding-seconds, then we should be done.
+               if _, hasRounding := propsMap["bucketRoundingSeconds"]; hasRounding {
+                       return props
+               }
+
+               // If mss matches a “granularity” preset, then just use that.
+               granularity, granOk := maxSpanSecondsToGranularity[cast.ToInt(mss)]
+               if granOk {
+                       mbson.DReplace(props, "bucketMaxSpanSeconds", "granularity", granularity)
+                       return props
+               }
+
+               // Finally: if we have a custom max-span-seconds and no granularity,
+               // then just assign the mss value as rounding-seconds.
+               props = append(props, bson.D{{"bucketRoundingSeconds", mss}}...)
+       }
+
+       return props
+}

Generated at Thu Feb 08 06:41:06 UTC 2024 using Jira 9.7.1#970001-sha1:2222b88b221c4928ef0de3161136cc90c8356a66.