-
Notifications
You must be signed in to change notification settings - Fork 7
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
Basic support for siva files #6
Conversation
Signed-off-by: Javi Fontan <jfontan@gmail.com>
Signed-off-by: Javi Fontan <jfontan@gmail.com>
Signed-off-by: Javi Fontan <jfontan@gmail.com>
Signed-off-by: Manuel Carmona <manu.carmona90@gmail.com>
siva: implement method Get for Library and other minor changes.
Signed-off-by: Javi Fontan <jfontan@gmail.com>
If a *.siva.checkpoint is found it tries to fix the siva file truncating it to the size written in the checkpoint. Signed-off-by: Javi Fontan <jfontan@gmail.com>
add fixing code using checkpoint files
Signed-off-by: Manuel Carmona <manu.carmona90@gmail.com>
siva: move repositoryIterator to its own file and other minor changes
Now library has a flag to set it transactional and is used with all locations and repositories below it. Transaction is managed from the location with Commit and Rollback methods. While a transaction is being made no other transaction can start. When a transaction starts a new siva filesystem is created for it and the previous cachedFS kept. This way previously created repositories from that location should work the same as before. It should also be able to create new repositories. Signed-off-by: Javi Fontan <jfontan@gmail.com>
Signed-off-by: Javi Fontan <jfontan@gmail.com>
Signed-off-by: Javi Fontan <jfontan@gmail.com>
add transactions to repositories
Signed-off-by: Manuel Carmona <manu.carmona90@gmail.com>
siva: add checkpoint as its own type.
Signed-off-by: Manuel Carmona <manu.carmona90@gmail.com>
It's cache size is hardcoded for now until a library options is implemented. Transactions should call startTransaction and endTransaction to make sure that subsequent Location calls return the correct location. Signed-off-by: Javi Fontan <jfontan@gmail.com>
Now transactions and registry cache size can be configured with LibraryOptions struct. Also added tests for location registry. Signed-off-by: Javi Fontan <jfontan@gmail.com>
…ransactional and write operations. Signed-off-by: Manuel Carmona <manu.carmona90@gmail.com>
siva: location registry + transactioner
Signed-off-by: Manuel Carmona <manu.carmona90@gmail.com>
Signed-off-by: Manuel Carmona <manu.carmona90@gmail.com>
siva: manage fs caching and repositories idempotent operations
Signed-off-by: Javi Fontan <jfontan@gmail.com>
Also deleted unused Location functions Signed-off-by: Javi Fontan <jfontan@gmail.com>
Signed-off-by: Javi Fontan <jfontan@gmail.com>
Signed-off-by: Javi Fontan <jfontan@gmail.com>
implement AddLocation in siva Library
Signed-off-by: Manuel Carmona <manu.carmona90@gmail.com>
Signed-off-by: Javi Fontan <jfontan@gmail.com>
Signed-off-by: Javi Fontan <jfontan@gmail.com>
Signed-off-by: Javi Fontan <jfontan@gmail.com>
Signed-off-by: Javi Fontan <jfontan@gmail.com>
Signed-off-by: Javi Fontan <jfontan@gmail.com>
siva testing and bug fixes
Signed-off-by: Manuel Carmona <manu.carmona90@gmail.com>
siva: gather helper functions
Signed-off-by: Manuel Carmona <manu.carmona90@gmail.com>
siva: add repo iterator test
Signed-off-by: Manuel Carmona <manu.carmona90@gmail.com>
Signed-off-by: Javi Fontan <jfontan@gmail.com>
siva: return error in repositoy commit if not transactional
Signed-off-by: Javi Fontan <jfontan@gmail.com>
siva: add package documentation
Signed-off-by: Manuel Carmona <manu.carmona90@gmail.com>
siva: add repository tests
Writing file by file as it is done now can cause slowdowns and higher number of IOPS. To improve writing to the siva files all the changes will be written locally and copied as a block when they are committed.
func NewTransactionalStorer(base billy.Filesystem, siva string) *TransactionalStorer
// newRepository creates a new siva backed Repository.
func newRepository(
id borges.RepositoryID,
sto storage.Storer,
m borges.Mode,
transactional bool,
l *Location,
) (*Repository, error) {
...
}
|
Now the siva files are not modified in-place. Checkpoint is still used so the final step of appending the temporary siva can be recovered. Signed-off-by: Javi Fontan <jfontan@gmail.com>
Also do not clean cached fs on failed commit. Signed-off-by: Javi Fontan <jfontan@gmail.com>
siva: do transactions to a tmp siva file and then append
Gopkg.testing.toml
Outdated
@@ -0,0 +1,4 @@ | |||
[[constraint]] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
since this is a library we shouldn't use gopkg
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It was needed before transactions in go-git
was in a release. I believe we should add at least go.mod
for these cases.
I'm deleting Gopkg.testing.toml
and dep
calls in .travis.yml
.
borges "github.com/src-d/go-borges" | ||
billy "gopkg.in/src-d/go-billy.v4" | ||
"gopkg.in/src-d/go-billy.v4/util" | ||
errors "gopkg.in/src-d/go-errors.v1" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
remove the useless package allias
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
These aliases are now added automatically by goimports
:
siva/doc.go
Outdated
loc, _ := library.AddLocation("test") | ||
r1, _ := loc.Init("repo1") # the first repo initializes the git repository | ||
r1.Commit() | ||
r2, := loc.Init("repos2) # the second just adds a new remote |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Missing quote at the end of repos2
} | ||
|
||
// TODO: find if we have to use ".git" suffix for repository ids | ||
func toRepoID(endpoint string) borges.RepositoryID { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
At the plain implementation is without: https://github.com/src-d/go-borges/blob/master/plain/location.go#L124
siva/location.go
Outdated
} | ||
|
||
// Get implements the borges.Location interface. | ||
func (l *Location) Get( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This can be one line
// for the siva filesystem that can be later deleted with Cleanup. | ||
func NewStorage( | ||
base billy.Filesystem, | ||
path string, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
what for you need a path?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It needs to know where the siva file is to open and update it.
Signed-off-by: Javi Fontan <jfontan@gmail.com>
Signed-off-by: Javi Fontan <jfontan@gmail.com>
In this storage each location is a siva file and can contain multiple virtual repositories. These virtual repositories are in fact remotes. They can be searched by name or by URL.
This storage model implements transactions at siva file level. When a new repository is opened in read write mode in a library with transactions enabled it creates a checkpoint file that contains the size of the siva file before the transaction. This file is used to restore the siva file to the last good known state if the process dies. On
Commit
the siva file is synced (index written to it) and checkpoint file closed.Close
(rollback) truncates the file to the saved file size.While the transaction is being made read only repositories can be used in the same location (siva file) but opening repositories in RW mode are blocked.
It does not support addressing repositories by its location, for example:
It does not feel natural. There is a method to get the location and with it we can open the desired repository:
Unimplemented features:
transactioner
should be renamed and its implementation be pluggable. The current one works for a single process but we need other implementations that can lock using different methods.Package documentation: