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

Executions stored in Database #560

Merged
merged 38 commits into from
Nov 2, 2018
Merged

Executions stored in Database #560

merged 38 commits into from
Nov 2, 2018

Conversation

antho1404
Copy link
Member

I've created a database to store all executions. For now it is a leveldb database but this can be changed in the future if needed. The purpose of this PR is really to not store any execution state in memory to avoid huge memory consumption.

interface/grpc/core/core_test.go Outdated Show resolved Hide resolved
execution/leveldb.go Outdated Show resolved Hide resolved
execution/execution.go Outdated Show resolved Hide resolved
execution/leveldb.go Outdated Show resolved Hide resolved
execution/execution_test.go Outdated Show resolved Hide resolved
execution/execution_test.go Outdated Show resolved Hide resolved
execution/leveldb.go Outdated Show resolved Hide resolved
api/api_test.go Outdated Show resolved Hide resolved
execution/execution_test.go Outdated Show resolved Hide resolved
execution/execution_test.go Outdated Show resolved Hide resolved
@ilgooz
Copy link
Contributor

ilgooz commented Oct 29, 2018

this one has some conflicts that needs to be resolved

@antho1404
Copy link
Member Author

I've done some update like splitting the database part (and put it in the database package) and also have the execution package that only manage the business logic related to the execution object. The responsibility to save this execution is done directly in the api package.

Waiting more feedbacks on that

krhubert
krhubert previously approved these changes Oct 30, 2018
database/execution_db.go Outdated Show resolved Hide resolved
database/execution_db.go Outdated Show resolved Hide resolved
// Save an instance of executable in the database
// Returns an error if anything from marshaling to database saving goes wrong
func (db *LevelDBExecutionDB) Save(execution *execution.Execution) (*execution.Execution, error) {
id := fmt.Sprintf("%x", sha1.Sum(structhash.Dump(execution, 1)))
Copy link
Contributor

Choose a reason for hiding this comment

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

id shouldn't be generated from hash calculation of execution struct. there is no a specific need for this so we can avoid doing it and use uuid. otherwise while updating something from execution, the ID also needs to be changed for no real reason.

database/execution_db.go Outdated Show resolved Hide resolved
execution/execution.go Outdated Show resolved Hide resolved
execution/execution.go Outdated Show resolved Hide resolved
execution/execution.go Outdated Show resolved Hide resolved
@antho1404
Copy link
Member Author

I changed slightly the current implementation, now the hash is not calculated on the execution date but based on an eventID, executions should always be executed based on an event and every events should have an unique identifier. For now we generate the unique Id only based on an UUID but with decentralized services this should be the ID of the event (like the transaction hash on ethereum for example)

@ilgooz
Copy link
Contributor

ilgooz commented Oct 31, 2018

I changed slightly the current implementation, now the hash is not calculated on the execution date but based on an eventID, executions should always be executed based on an event and every events should have an unique identifier. For now we generate the unique Id only based on an UUID but with decentralized services this should be the ID of the event (like the transaction hash on ethereum for example)

I don't get these changes. Why are we complicating unique id generation? To me, we can create and set execution.Execution.ID with a randomly generated uuid inside execution.New() or execution.Save(). Why do we need to generate a hash over execution.Execution data structure? We're not looking for uniqueness of executions. The only thing needed is a random unique id for identifying each execution.

@antho1404
Copy link
Member Author

We actually need "uniqueness of executions". When we have the distributed version of MESG, the execution will be created by one node but all other nodes should be able to reproduce the same id based on the same data to ensure that they are verifying/executing the exact same execution. For now it's not mandatory to use a hash but it will be and it doesn't add much complexity, we already have the exact same principle for services for the same reason.

hasError bool
}{
{e.ID, false},
{"doesn't exists", true},
Copy link
Contributor

Choose a reason for hiding this comment

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

I'm removing this because I think, it's forgotten here.

krhubert
krhubert previously approved these changes Nov 1, 2018
Copy link
Contributor

@ilgooz ilgooz left a comment

Choose a reason for hiding this comment

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

manual tests are ok

@krhubert krhubert merged commit a940f93 into dev Nov 2, 2018
@ilgooz ilgooz deleted the feature/execution-databse branch November 2, 2018 08:47
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