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

sql datastore cleanup #564

Merged
merged 1 commit into from
Aug 24, 2018
Merged

sql datastore cleanup #564

merged 1 commit into from
Aug 24, 2018

Conversation

azdagron
Copy link
Member

  • consistent use of transactions.
  • opens sqlite3 databases in WAL mode to improve concurrency performance
  • enforces a lock over write operations for sqlite3.
  • improved error handling.
  • error wrapping for improved diagnostics.
  • fixed Configure() to be safe in the presence of concurrent callers and
    to not overwrite the current database unless the new one opened
    successfully.
  • converts tests to test suite
  • has tests test against database on disk in order to properly exercise
    behavior (in-memory databases have journaling differences)

- consistent use of transactions.
- opens sqlite3 databases in WAL mode to improve concurrency performance
- enforces a lock over write operations for sqlite3.
- improved error handling.
- error wrapping for improved diagnostics.
- fixed Configure() to be safe in the presence of concurrent callers and
to not overwrite the current database unless the new one opened
successfully.
- converts tests to test suite
- has tests test against database on disk in order to properly exercise
behavior (in-memory databases have journaling differences)

Signed-off-by: Andrew Harding <azdagron@gmail.com>
Copy link
Member

@evan2645 evan2645 left a comment

Choose a reason for hiding this comment

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

🥓 👶

defer db.opMu.Unlock()
}

// TODO: as soon as GORM supports it, attach the context
Copy link
Member

Choose a reason for hiding this comment

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

Is there an issue on gorm tracking this?

Copy link
Member Author

Choose a reason for hiding this comment

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

there is a few....

Copy link
Member Author

Choose a reason for hiding this comment

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

I'll find the root issue and put it in the comment in the follow up PR I'm working on.

ds.DatabaseType = config.DatabaseType
ds.ConnectionString = config.ConnectionString
return resp, ds.restart()
if len(entry.SpiffeId) == 0 {
Copy link
Member

Choose a reason for hiding this comment

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

should we do a more stringent validation check here? registration entries should be workload entries that belong to our trust domain

Copy link
Member Author

@azdagron azdagron Aug 24, 2018

Choose a reason for hiding this comment

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

Hmm, that's a good question. Is the datastore layer really the proper layer to be doing these kind of checks? It does place a slightly higher burden on implementors that we'd need to document (along with a few other things, .e.g., which Fetch functions should fail if the record doesn't exist, v.s. returning nil). The core is doing this kind of validation in the registration handler. If the code grew to create registration entries from more than one spot, I think I'd rather see the core go through a layer wrapping the datastore plugin that does the validation consistently in a single spot so we didn't have to rely on plugin implementations...

@azdagron azdagron merged commit 2a5b0fc into spiffe:master Aug 24, 2018
@azdagron azdagron deleted the datastore-cleanup branch August 24, 2018 14:32
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.

2 participants