Skip to content

Use orphaned docs as part of GC calculation #80

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

Merged
merged 5 commits into from
Oct 23, 2018

Conversation

gsoltis
Copy link
Contributor

@gsoltis gsoltis commented Oct 18, 2018

We had originally decided to only look at targets when assessing how much to run GC. However, based on running a write-heavy workload test, we need to include documents that ended up cached without being part of a target.

This is a port of a portion of firebase/firebase-ios-sdk#1961

Note that merge base is into the LRU branch, not master.

Integration tests pass :)

long orphanedDocumentCount =
persistence
.query(
"SELECT COUNT(*) FROM (SELECT sequence_number FROM target_documents GROUP BY path HAVING COUNT(*) = 1 AND target_id = 0)")
Copy link
Contributor

Choose a reason for hiding this comment

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

I don't know SQLite, and I assume you tried "SELECT COUNT() FROM target_documents GROUP BY path HAVING COUNT() = 1 AND target_id = 0"?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I did indeed try that first. I believe COUNT(*) in the projection interacts poorly with GROUP BY in terms of getting what we want here. Using the subquery technique works, and in retrospect is I think a little more obvious when compared with the similar query used to find the sequence numbers.

@gsoltis
Copy link
Contributor Author

gsoltis commented Oct 22, 2018

/test smoke-tests-release

@gsoltis
Copy link
Contributor Author

gsoltis commented Oct 22, 2018

/test smoke-tests-debug

@gsoltis
Copy link
Contributor Author

gsoltis commented Oct 22, 2018

/test smoke-tests-release

1 similar comment
@gsoltis
Copy link
Contributor Author

gsoltis commented Oct 22, 2018

/test smoke-tests-release

@gsoltis gsoltis merged commit b87a3cd into gsoltis/enable_lru Oct 23, 2018
@gsoltis gsoltis deleted the gsoltis/use_orphaned_docs branch October 23, 2018 14:20
@firebase firebase locked and limited conversation to collaborators Oct 14, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants