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

Add test case to verify freelist in case of TXN rollback #796

Merged
merged 1 commit into from
Jul 22, 2024

Conversation

ahrtr
Copy link
Member

@ahrtr ahrtr commented Jul 17, 2024

The freelist should be unchanged when TXN rollbacks.

@k8s-ci-robot
Copy link

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: ahrtr

The full list of commands accepted by this bot can be found here.

The pull request process is described here

Needs approval from an approver in each of these files:

Approvers can indicate their approval by writing /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

}
return nil
})
require.NoError(t, err)
Copy link
Contributor

@tjungblu tjungblu Jul 22, 2024

Choose a reason for hiding this comment

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

can you add an assertion to count the leafs and free pages here? just in case the numbers change in the future - or below, where you're reading the freelist pgids

Copy link
Member Author

Choose a reason for hiding this comment

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

Added one more check below. We are good as long as the freelist ID isn't empty.

require.Greater(t, len(beforeFreelistPgids), 0)

require.Equal(t, beforeFreelistPgids, afterFreelistPgids)

t.Log("Disable the `beforeWriteMetaError` failpoint.")
require.NoError(t, gofail.Disable("beforeWriteMetaError"))
Copy link
Contributor

Choose a reason for hiding this comment

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

that's probably a better candidate for a defer

Copy link
Member Author

Choose a reason for hiding this comment

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

If we use defer, then we have to remove the require.NoError, something like below,

defer gofail.Disable("beforeWriteMetaError")

Note each time a "defer" statement executes, the function value and parameters to the call are evaluated as usual and saved anew but the actual function is not invoked.

Copy link
Contributor

Choose a reason for hiding this comment

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

we don't have to remove the require to use it in a defer statement, but I'm fine with keeping it the way it is. I'm mostly concerned about a failure in this test impacting the other testcases with the failpoint and then one has to check which one caused the failure to begin with.

It's a separate suite with a few tests, so let's leave it

Copy link
Member Author

Choose a reason for hiding this comment

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

Updated again,

	defer func() {
		t.Log("Disable the `beforeWriteMetaError` failpoint.")
		require.NoError(t, gofail.Disable("beforeWriteMetaError"))
	}()

@tjungblu
Copy link
Contributor

/lgtm

@tjungblu
Copy link
Contributor

thanks!

/lgtm

@ahrtr ahrtr merged commit 2e6b37b into etcd-io:main Jul 22, 2024
18 checks passed
@ahrtr ahrtr deleted the rollback_test_20240717 branch July 22, 2024 15:17
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Development

Successfully merging this pull request may close these issues.

3 participants