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

[FAB-11334] Adds a function to purge a ledger's transient storage #2769

Merged

Conversation

jkneubuh
Copy link
Contributor

@jkneubuh jkneubuh commented Jul 20, 2021

Type of change

  • New feature

Description

This introduces a transientstore.Delete(ledgerID) routine to assist with the bookkeeping while unjoining a peer from a channel. Before removing the transient storage, the store is marked as UNDER_DELETION in a system leveldb, providing an opportunity to recover from a failed deletion at the next peer initialization.

Signed-off-by: Josh Kneubuhl jkneubuh@us.ibm.com

Additional details

Related issues

Resolves #2786

core/transientstore/store.go Outdated Show resolved Hide resolved
core/transientstore/store.go Outdated Show resolved Hide resolved
core/transientstore/store.go Outdated Show resolved Hide resolved
core/transientstore/store.go Outdated Show resolved Hide resolved
core/transientstore/store.go Outdated Show resolved Hide resolved
core/transientstore/store.go Outdated Show resolved Hide resolved
core/transientstore/delete_store_test.go Show resolved Hide resolved
core/transientstore/delete_store_test.go Outdated Show resolved Hide resolved
core/transientstore/store.go Outdated Show resolved Hide resolved
core/transientstore/delete_store_test.go Show resolved Hide resolved
@jkneubuh jkneubuh force-pushed the feature/unjoin-transient-store branch 2 times, most recently from db72f29 to daca3db Compare July 23, 2021 19:43
@jkneubuh jkneubuh marked this pull request as ready for review July 23, 2021 19:51
@jkneubuh jkneubuh requested a review from a team as a code owner July 23, 2021 19:51
@jkneubuh jkneubuh force-pushed the feature/unjoin-transient-store branch from daca3db to 666846e Compare July 26, 2021 13:25
Comment on lines +222 to +226
// Determine if the lock is currently held open.
func (f *FileLock) IsLocked() bool {
return f.db != nil
}

Copy link
Contributor

Choose a reason for hiding this comment

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

I won't over-emphasize this but just to take a note - as the introduction of this function now assumes (at this level of code) that this struct can be used by a more than one go routines, access to field f.db should be protected. Else, a caller can get a wrong result from this function.

However, we are using this struct in a very limited way and don't foresee any plan to use this function in a test with concurrent go-routines, I am fine leaving it as is; but appreciate if you want to fix this for cleanliness at this level of the code.

@jkneubuh jkneubuh force-pushed the feature/unjoin-transient-store branch 3 times, most recently from b475cb8 to 09d21a2 Compare July 26, 2021 20:13
Copy link
Contributor

@manish-sethi manish-sethi left a comment

Choose a reason for hiding this comment

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

LGTM now. A few final clean up comments.

core/transientstore/store.go Outdated Show resolved Hide resolved
core/transientstore/store.go Outdated Show resolved Hide resolved
core/transientstore/store.go Outdated Show resolved Hide resolved
This introduces a transientstore.Delete(ledgerID) routine to assist with the bookkeeping
while unjoining a peer from a channel.  Before removing the transient storage, the store
is marked as UNDER_DELETION in a system leveldb, providing an opportunity to recover from
a failed deletion at the next peer initialization.

Signed-off-by: Josh Kneubuhl <jkneubuh@us.ibm.com>
@jkneubuh jkneubuh force-pushed the feature/unjoin-transient-store branch from 09d21a2 to c1dc94e Compare July 26, 2021 23:02
@jkneubuh
Copy link
Contributor Author

OK. I think this one is a wrap. I agree we should look to find a wider grain / common lock to handle "peer is running" concurrently with CLI activities requiring the peer to be shut down.

Comment on lines +168 to +169
defer lock.Unlock()
defer os.RemoveAll(lockPath)
Copy link
Contributor

Choose a reason for hiding this comment

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

I think that your intent was the following. The defers are executed in reverse order.

Suggested change
defer lock.Unlock()
defer os.RemoveAll(lockPath)
defer func(){
lock.Unlock()
os.RemoveAll(lockPath)
}()

Copy link
Contributor

@manish-sethi manish-sethi left a comment

Choose a reason for hiding this comment

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

Approving with a minor comment that can be fixed later.

@manish-sethi manish-sethi merged commit bb8bada into hyperledger:main Jul 27, 2021
jkneubuh added a commit to jkneubuh/fabric that referenced this pull request Jul 28, 2021
… from a channel (hyperledger#2769)

This change adds a Viper cobra.Command to unjoin the peer from a specified channel.

Signed-off-by: Josh Kneubuhl <jkneubuh@us.ibm.com>
denyeart pushed a commit that referenced this pull request Jul 30, 2021
… from a channel (#2769)

This change adds a Viper cobra.Command to unjoin the peer from a specified channel.

Signed-off-by: Josh Kneubuhl <jkneubuh@us.ibm.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Add a function to purge a ledger's transient storage
3 participants