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

Fix for 8474 - Prevent a possible condition of slow snapshots, caused by a rapid series of document update(s) followed by a delete. #8595

Merged
merged 7 commits into from
Oct 30, 2024

Conversation

MarkDuckworth
Copy link
Contributor

@MarkDuckworth MarkDuckworth commented Oct 24, 2024

Fixes #8474.

Summary:
A rapid sequence of events for a single document, within the window of a single global snapshot, can result in delayed limbo resolution for that document.

The events sequence leading to the delay are:

  1. A watch change event (e.g. add, remove, or update document for any target), where the event contains updated document data.
  2. A watch change event (e.g. delete or remove document from target), where the event is the response to limbo resolution for the same document as event 1.

When these two events occur within the window of a single global snapshot, the limbo resolution associated with the delete event, is delayed until the next global snapshot.

Copy link

changeset-bot bot commented Oct 24, 2024

🦋 Changeset detected

Latest commit: 91fa315

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 3 packages
Name Type
@firebase/firestore Patch
firebase Patch
@firebase/firestore-compat Patch

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

@dconeybe
Copy link
Contributor

Pls add a description of the fix, in addition to the issue number

@google-oss-bot
Copy link
Contributor

google-oss-bot commented Oct 24, 2024

Size Report 1

Affected Products

  • @firebase/firestore

    TypeBase (4db3d3e)Merge (a84f4fb)Diff
    browser381 kB381 kB+301 B (+0.1%)
    main587 kB588 kB+693 B (+0.1%)
    module381 kB381 kB+301 B (+0.1%)
    react-native381 kB382 kB+301 B (+0.1%)
  • @firebase/rules-unit-testing

    TypeBase (4db3d3e)Merge (a84f4fb)Diff
    main12.3 kB12.3 kB-10 B (-0.1%)
  • bundle

    TypeBase (4db3d3e)Merge (a84f4fb)Diff
    firestore (CSI Auto Indexing Disable and Delete)272 kB272 kB+17 B (+0.0%)
    firestore (CSI Auto Indexing Enable)272 kB272 kB+17 B (+0.0%)
    firestore (Persistence)303 kB303 kB+217 B (+0.1%)
    firestore (Query Cursors)249 kB249 kB+217 B (+0.1%)
    firestore (Query)246 kB247 kB+217 B (+0.1%)
    firestore (Read data once)234 kB234 kB+217 B (+0.1%)
    firestore (Read Write w Persistence)328 kB328 kB+217 B (+0.1%)
    firestore (Realtime updates)236 kB237 kB+217 B (+0.1%)
    firestore (Transaction)214 kB214 kB+17 B (+0.0%)
    firestore (Write data)213 kB213 kB+17 B (+0.0%)
  • firebase

    TypeBase (4db3d3e)Merge (a84f4fb)Diff
    firebase-app.js103 kB101 kB-2.66 kB (-2.6%)
    firebase-compat.js794 kB794 kB+217 B (+0.0%)
    firebase-firestore-compat.js346 kB346 kB+216 B (+0.1%)
    firebase-firestore.js440 kB440 kB+301 B (+0.1%)

Test Logs

  1. https://storage.googleapis.com/firebase-sdk-metric-reports/S9a0PVFe1g.html

@google-oss-bot
Copy link
Contributor

google-oss-bot commented Oct 24, 2024

Size Analysis Report 1

Affected Products

  • @firebase/firestore

    • _internalAggregationQueryToProtoRunAggregationQueryRequest

      Dependency

      TypeBase (4db3d3e)Merge (a84f4fb)Diff
      variables

      14 dependencies

      D
      Ee
      S
      Te
      b
      de
      he
      le
      ne
      pe
      re
      w
      we
      ye

      14 dependencies

      D
      Ee
      Ie
      S
      b
      de
      he
      le
      ne
      pe
      re
      w
      we
      ye

      + Ie
      - Te

    • _internalQueryToProtoQueryTarget

      Dependency

      TypeBase (4db3d3e)Merge (a84f4fb)Diff
      variables

      15 dependencies

      D
      Ee
      S
      Te
      b
      de
      he
      le
      ne
      pe
      re
      v
      w
      we
      ye

      15 dependencies

      D
      Ee
      Ie
      S
      b
      de
      he
      le
      ne
      pe
      re
      v
      w
      we
      ye

      + Ie
      - Te

    • addDoc

      Size

      TypeBase (4db3d3e)Merge (a84f4fb)Diff
      size132 kB132 kB+17 B (+0.0%)
      size-with-ext-deps204 kB204 kB+17 B (+0.0%)
    • clearIndexedDbPersistence

    • deleteDoc

      Size

      TypeBase (4db3d3e)Merge (a84f4fb)Diff
      size122 kB122 kB+17 B (+0.0%)
      size-with-ext-deps194 kB194 kB+17 B (+0.0%)
    • disableNetwork

      Size

      TypeBase (4db3d3e)Merge (a84f4fb)Diff
      size111 kB111 kB+17 B (+0.0%)
      size-with-ext-deps183 kB183 kB+17 B (+0.0%)
    • enableIndexedDbPersistence

      Size

      TypeBase (4db3d3e)Merge (a84f4fb)Diff
      size187 kB187 kB+17 B (+0.0%)
      size-with-ext-deps258 kB258 kB+17 B (+0.0%)

      Dependency

      TypeBase (4db3d3e)Merge (a84f4fb)Diff
      variables

      53 dependencies

      $
      Ae
      B
      C
      D
      Ee
      F
      G
      H
      J
      K
      L
      M
      N
      O
      Q
      Re
      S
      Te
      U
      Ve
      W
      X
      Y
      Z
      _e
      ae
      b
      ce
      de
      ee
      fe
      ge
      he
      ie
      j
      k
      le
      me
      ne
      oe
      pe
      q
      re
      se
      te
      ue
      v
      w
      we
      x
      ye
      z

      53 dependencies

      $
      Ae
      B
      C
      D
      Ee
      F
      G
      H
      Ie
      J
      K
      L
      M
      N
      O
      Q
      Re
      S
      U
      Ve
      W
      X
      Y
      Z
      _e
      ae
      b
      ce
      de
      ee
      fe
      ge
      he
      ie
      j
      k
      le
      me
      ne
      oe
      pe
      q
      re
      se
      te
      ue
      v
      w
      we
      x
      ye
      z

      + Ie
      - Te

    • enableMultiTabIndexedDbPersistence

      Size

      TypeBase (4db3d3e)Merge (a84f4fb)Diff
      size222 kB223 kB+216 B (+0.1%)
      size-with-ext-deps295 kB295 kB+217 B (+0.1%)
    • enableNetwork

      Size

      TypeBase (4db3d3e)Merge (a84f4fb)Diff
      size111 kB111 kB+17 B (+0.0%)
      size-with-ext-deps183 kB183 kB+17 B (+0.0%)
    • executeWrite

      Size

      TypeBase (4db3d3e)Merge (a84f4fb)Diff
      size121 kB121 kB+17 B (+0.0%)
      size-with-ext-deps193 kB193 kB+17 B (+0.0%)
    • getAggregateFromServer

      Size

      TypeBase (4db3d3e)Merge (a84f4fb)Diff
      size119 kB119 kB+17 B (+0.0%)
      size-with-ext-deps190 kB190 kB+17 B (+0.0%)

      Dependency

      TypeBase (4db3d3e)Merge (a84f4fb)Diff
      variables

      24 dependencies

      C
      D
      Ee
      Re
      S
      Te
      _e
      b
      ce
      de
      fe
      ge
      he
      le
      me
      ne
      oe
      pe
      re
      ue
      v
      w
      we
      ye

      24 dependencies

      C
      D
      Ee
      Ie
      Re
      S
      _e
      b
      ce
      de
      fe
      ge
      he
      le
      me
      ne
      oe
      pe
      re
      ue
      v
      w
      we
      ye

      + Ie
      - Te

    • getCountFromServer

      Size

      TypeBase (4db3d3e)Merge (a84f4fb)Diff
      size119 kB119 kB+17 B (+0.0%)
      size-with-ext-deps191 kB191 kB+17 B (+0.0%)

      Dependency

      TypeBase (4db3d3e)Merge (a84f4fb)Diff
      variables

      24 dependencies

      C
      D
      Ee
      Re
      S
      Te
      _e
      b
      ce
      de
      fe
      ge
      he
      le
      me
      ne
      oe
      pe
      re
      ue
      v
      w
      we
      ye

      24 dependencies

      C
      D
      Ee
      Ie
      Re
      S
      _e
      b
      ce
      de
      fe
      ge
      he
      le
      me
      ne
      oe
      pe
      re
      ue
      v
      w
      we
      ye

      + Ie
      - Te

    • getDoc

      Size

      TypeBase (4db3d3e)Merge (a84f4fb)Diff
      size153 kB153 kB+216 B (+0.1%)
      size-with-ext-deps225 kB225 kB+217 B (+0.1%)
    • getDocFromServer

      Size

      TypeBase (4db3d3e)Merge (a84f4fb)Diff
      size153 kB153 kB+216 B (+0.1%)
      size-with-ext-deps225 kB225 kB+217 B (+0.1%)
    • getDocs

      Size

      TypeBase (4db3d3e)Merge (a84f4fb)Diff
      size154 kB155 kB+216 B (+0.1%)
      size-with-ext-deps226 kB227 kB+217 B (+0.1%)
    • getDocsFromServer

      Size

      TypeBase (4db3d3e)Merge (a84f4fb)Diff
      size154 kB155 kB+216 B (+0.1%)
      size-with-ext-deps226 kB226 kB+217 B (+0.1%)
    • loadBundle

      Size

      TypeBase (4db3d3e)Merge (a84f4fb)Diff
      size120 kB120 kB+17 B (+0.0%)
      size-with-ext-deps192 kB192 kB+17 B (+0.0%)
    • memoryLocalCache

      Size

      TypeBase (4db3d3e)Merge (a84f4fb)Diff
      size105 kB105 kB+17 B (+0.0%)
      size-with-ext-deps177 kB177 kB+17 B (+0.0%)
    • onSnapshot

      Size

      TypeBase (4db3d3e)Merge (a84f4fb)Diff
      size155 kB155 kB+216 B (+0.1%)
      size-with-ext-deps227 kB227 kB+217 B (+0.1%)
    • onSnapshotsInSync

      Size

      TypeBase (4db3d3e)Merge (a84f4fb)Diff
      size144 kB144 kB+216 B (+0.2%)
      size-with-ext-deps216 kB216 kB+217 B (+0.1%)
    • persistentLocalCache

      Size

      TypeBase (4db3d3e)Merge (a84f4fb)Diff
      size183 kB183 kB+17 B (+0.0%)
      size-with-ext-deps255 kB255 kB+17 B (+0.0%)

      Dependency

      TypeBase (4db3d3e)Merge (a84f4fb)Diff
      variables

      53 dependencies

      $
      Ae
      B
      C
      D
      Ee
      F
      G
      H
      J
      K
      L
      M
      N
      O
      Q
      Re
      S
      Te
      U
      Ve
      W
      X
      Y
      Z
      _e
      ae
      b
      ce
      de
      ee
      fe
      ge
      he
      ie
      j
      k
      le
      me
      ne
      oe
      pe
      q
      re
      se
      te
      ue
      v
      w
      we
      x
      ye
      z

      53 dependencies

      $
      Ae
      B
      C
      D
      Ee
      F
      G
      H
      Ie
      J
      K
      L
      M
      N
      O
      Q
      Re
      S
      U
      Ve
      W
      X
      Y
      Z
      _e
      ae
      b
      ce
      de
      ee
      fe
      ge
      he
      ie
      j
      k
      le
      me
      ne
      oe
      pe
      q
      re
      se
      te
      ue
      v
      w
      we
      x
      ye
      z

      + Ie
      - Te

    • persistentMultipleTabManager

      Size

      TypeBase (4db3d3e)Merge (a84f4fb)Diff
      size218 kB218 kB+216 B (+0.1%)
      size-with-ext-deps290 kB290 kB+217 B (+0.1%)
    • persistentSingleTabManager

      Size

      TypeBase (4db3d3e)Merge (a84f4fb)Diff
      size182 kB182 kB+17 B (+0.0%)
      size-with-ext-deps254 kB254 kB+17 B (+0.0%)

      Dependency

      TypeBase (4db3d3e)Merge (a84f4fb)Diff
      variables

      53 dependencies

      $
      Ae
      B
      C
      D
      Ee
      F
      G
      H
      J
      K
      L
      M
      N
      O
      Q
      Re
      S
      Te
      U
      Ve
      W
      X
      Y
      Z
      _e
      ae
      b
      ce
      de
      ee
      fe
      ge
      he
      ie
      j
      k
      le
      me
      ne
      oe
      pe
      q
      re
      se
      te
      ue
      v
      w
      we
      x
      ye
      z

      53 dependencies

      $
      Ae
      B
      C
      D
      Ee
      F
      G
      H
      Ie
      J
      K
      L
      M
      N
      O
      Q
      Re
      S
      U
      Ve
      W
      X
      Y
      Z
      _e
      ae
      b
      ce
      de
      ee
      fe
      ge
      he
      ie
      j
      k
      le
      me
      ne
      oe
      pe
      q
      re
      se
      te
      ue
      v
      w
      we
      x
      ye
      z

      + Ie
      - Te

    • runTransaction

      Size

      TypeBase (4db3d3e)Merge (a84f4fb)Diff
      size132 kB132 kB+17 B (+0.0%)
      size-with-ext-deps204 kB204 kB+17 B (+0.0%)
    • setDoc

      Size

      TypeBase (4db3d3e)Merge (a84f4fb)Diff
      size131 kB131 kB+17 B (+0.0%)
      size-with-ext-deps203 kB203 kB+17 B (+0.0%)
    • updateDoc

      Size

      TypeBase (4db3d3e)Merge (a84f4fb)Diff
      size132 kB132 kB+17 B (+0.0%)
      size-with-ext-deps203 kB204 kB+17 B (+0.0%)
    • waitForPendingWrites

      Size

      TypeBase (4db3d3e)Merge (a84f4fb)Diff
      size111 kB111 kB+17 B (+0.0%)
      size-with-ext-deps183 kB183 kB+17 B (+0.0%)
    • writeBatch

      Size

      TypeBase (4db3d3e)Merge (a84f4fb)Diff
      size134 kB134 kB+17 B (+0.0%)
      size-with-ext-deps205 kB205 kB+17 B (+0.0%)

Test Logs

  1. https://storage.googleapis.com/firebase-sdk-metric-reports/RIcwzCQRIN.html

Copy link
Contributor

@DellaBitta DellaBitta left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please add a changeset, and could you rename the PR to be descriptive. Feel free to keep the "Fix for 8474" but also describe what has changed.

@MarkDuckworth MarkDuckworth changed the title Fix for 8474 Fix for 8474 - Prevent a possible condition of slow snapshots, caused by a rapid series of document update(s) followed by a delete. Oct 25, 2024
.changeset/tasty-boxes-brake.md Outdated Show resolved Hide resolved
@MarkDuckworth MarkDuckworth merged commit 0f5714b into main Oct 30, 2024
49 of 50 checks passed
@MarkDuckworth MarkDuckworth deleted the markduckworth/8474-spec branch October 30, 2024 16:05
@google-oss-bot google-oss-bot mentioned this pull request Nov 12, 2024
ashish-kothari added a commit that referenced this pull request Nov 24, 2024
Squashed commit of the following:

commit ffbf5a6
Author: Google Open Source Bot <[email protected]>
Date:   Thu Nov 14 07:04:30 2024 -0800

    Version Packages (#8635)

    Co-authored-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com>

commit 2c27206
Merge: a75082f e3e2078
Author: Google Open Source Bot <[email protected]>
Date:   Tue Nov 12 07:48:12 2024 -0800

    Merge main into release

commit e3e2078
Author: Daniel La Rocque <[email protected]>
Date:   Wed Nov 6 09:57:57 2024 -0500

    Consolidate CI test output into a single string (#8489)

    * Consolidate CI test output into a single string

    Having CI test process stdout and stderr in a single string makes it
    easier to read when looking through failures, since you can see the test
    output alongside the error messages.

    Without this, any stderr output written during a test will be captured
    seperately from the test output, so when we then log it after a test
    failure, we can't tell which test logged which errors.

    * Prefix stdout and stderr output

commit 274e9a5
Author: Daniel La Rocque <[email protected]>
Date:   Tue Nov 5 17:25:54 2024 -0500

    Remove unused `convertPropertiesForEnclosingClass" (#8618)

commit caf3090
Author: Daniel La Rocque <[email protected]>
Date:   Wed Oct 30 15:12:32 2024 -0400

    Upgrade ts-node to 10.19.2 (#8531)

commit 0f5714b
Author: Mark Duckworth <[email protected]>
Date:   Wed Oct 30 10:05:19 2024 -0600

    Fix for 8474 - Prevent a possible condition of slow snapshots, caused by a rapid series of document update(s) followed by a delete. (#8595)

commit d4cb3f8
Author: Daniel La Rocque <[email protected]>
Date:   Mon Oct 28 14:32:13 2024 -0400

    Upgrade workflows Node version from `20.x` to `22.10.0` (#8601)

    Node 22 enters LTS on October 29th, 2024, so we should upgrade CI to run
    on Node 22.

commit b807119
Author: Daniel La Rocque <[email protected]>
Date:   Fri Oct 25 15:16:08 2024 -0400

    Remove modifiers from compat overloads (#8604)

    * Remove modifiers from compat overloads

    * format

    * Add changeset

commit 612335d
Author: Daniel La Rocque <[email protected]>
Date:   Fri Oct 25 14:31:32 2024 -0400

    Upgrade webpack dependencies in e2e tests (#8605)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

randomly freezes for 45 seconds when getDocs after update transaction
5 participants