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

[GAIAPLAT-1749] INDEX: Keep track of updated txn id, mark committed txn ids and skip if no work to be done #1121

Merged
merged 4 commits into from
Dec 8, 2021

Conversation

yiwen-wong
Copy link

No description provided.

@@ -89,6 +90,9 @@ class index_t : public base_index_t
T_structure m_data;

private:
gaia_txn_id_t m_last_updated_txn_id;
Copy link
Contributor

Choose a reason for hiding this comment

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

Add a comment to explain what these fields are being used for.

Also, can you move find_physical_key above the field declarations, so that we keep the field declarations last?

@@ -9,6 +9,13 @@ template <typename T_structure, typename T_iterator>
void index_t<T_structure, T_iterator>::insert_index_entry(index_key_t&& key, index_record_t record)
{
std::lock_guard lock(m_index_lock);

// Update the last updated txn id if necessary.
if (m_last_updated_txn_id < record.txn_id)
Copy link
Contributor

Choose a reason for hiding this comment

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

This looks like a Yoda-expression. Same for all other such checks.

@@ -41,6 +55,15 @@ void index_t<T_structure, T_iterator>::remove_index_entry_with_offsets(const std
template <typename T_structure, typename T_iterator>
void index_t<T_structure, T_iterator>::mark_entries_committed(gaia_txn_id_t txn_id)
{
{
std::lock_guard lock(m_index_lock);
if (m_last_updated_txn_id < m_last_mark_committed_txn_id)
Copy link
Contributor

Choose a reason for hiding this comment

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

Should this be <=?

Copy link
Contributor

Choose a reason for hiding this comment

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

Also, the logic is not very clear here. I would have expected some check involving txn_id rather this check between two other values.

Copy link
Contributor

Choose a reason for hiding this comment

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

Does this mean: "if all updates have already been marked as committed, then there is nothing left to be marked"?

Copy link
Author

Choose a reason for hiding this comment

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

Should this be <=?

Yes it should have been <=.

Also, the logic is not very clear here. I would have expected some check involving txn_id rather this check between two other values.

The check for txn_id is incorrect! This is because the m_last_updated_txn_id can fall behind the watermark to truncate the metadata, as such, we could leave the index structure referencing truncated metadata.

Yes, the logic if all updates have already been marked committed, there is nothing left to mark is correct. I will be adding some comments to the effect.

{
std::lock_guard lock(m_index_lock);

if (m_last_updated_txn_id < gc_txn_id)
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 understand this condition. At least, it needs a comment.

Copy link
Contributor

@LaurentiuCristofor LaurentiuCristofor left a comment

Choose a reason for hiding this comment

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

I don't fully understand this logic - I left some comments on the parts that gave me trouble.

Copy link
Contributor

@senderista senderista left a comment

Choose a reason for hiding this comment

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

I'm not confident I understand the logic here; some comments (and a bit of reordering as @LaurentiuCristofor suggested) would go a long way.

// The following txn_ids are internal markers to determine if any work needs to be done for garbage collection.
//
// last_updated_txn_id - txn_id where the last index is updated/modified.
// last_mark_committed_txn_id - the txn_id below which all index entries have been mark committed.
Copy link
Contributor

Choose a reason for hiding this comment

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

"marked"


// The following txn_ids are internal markers to determine if any work needs to be done for garbage collection.
//
// last_updated_txn_id - txn_id where the last index is updated/modified.
Copy link
Contributor

Choose a reason for hiding this comment

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

What does "last index" mean?

@@ -76,7 +75,7 @@ class index_t : public base_index_t

// This method will mark all entries below a specified txn_id as committed.
// This must only be called once all aborted/terminated index entries below the txn_id are garbage collected.
Copy link
Contributor

Choose a reason for hiding this comment

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

"once"->"after"

Copy link
Contributor

@senderista senderista left a comment

Choose a reason for hiding this comment

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

LGTM, just a couple suggestions.

@yiwen-wong yiwen-wong merged commit ef647b0 into master Dec 8, 2021
@yiwen-wong yiwen-wong deleted the yiwen_gc_optimization_watermarks_pr branch December 8, 2021 21:28
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.

3 participants