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

read yaml config file #497

Merged
merged 6 commits into from Nov 13, 2020
Merged

read yaml config file #497

merged 6 commits into from Nov 13, 2020

Conversation

Karsten1987
Copy link
Collaborator

implements to read a config file (.yaml) tailored for sqlite3. As for now, I've only implemented to read pragmas in the style of:

read:
  pragmas: ["schema_version"]
write:
  pragmas: ["synchronous = NORMAL", "journal_mode = WAL"]

I am struggling a bit to write tests for this as I have a hard time to introspect if these pragmas are actually affective. I can't really test for wrong pragmas either as according to the sqlite documentation "No error messages are generated if an unknown pragma is issued."

@Karsten1987
Copy link
Collaborator Author

this is rebased on top of the latest changes in #493

Copy link
Collaborator

@emersonknapp emersonknapp left a comment

Choose a reason for hiding this comment

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

This looks good - a few stylistic notes if you want to take them

@adamdbrw
Copy link
Collaborator

In terms of testing - perhaps querying if the pragma is set would suffice?

PRAGMA pragma_name;

should return the current value of the specific pragma setting.

@adamdbrw
Copy link
Collaborator

@Karsten1987 I would like to suggest some changes as well as discuss overall design. I don't have access rights to comment or push changes to the branch. How do we proceed?

  • Are you going to apply pending review suggestions by @emersonknapp? It would be helpful to resolve them in any way.
  • I can open a PR to this branch with my suggestions and fixes. Would that PR be the right place to discuss design?
  • Would you like to rebase the parent branch before we proceed?

Meanwhile, I will work on it locally

@Karsten1987 Karsten1987 requested a review from a team as a code owner October 19, 2020 22:43
@Karsten1987 Karsten1987 requested review from jaisontj and jikawa-az and removed request for a team October 19, 2020 22:43
@Karsten1987
Copy link
Collaborator Author

@adamdbrw you should have write access now to this repo. Feel free to simply push ontop of this branch. I've rebased and hopefully addressed Emerson's comments.

Copy link
Collaborator

@emersonknapp emersonknapp left a comment

Choose a reason for hiding this comment

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

lgtm

@delete-merged-branch delete-merged-branch bot deleted the branch master October 28, 2020 16:44
@Karsten1987 Karsten1987 changed the base branch from storage_config to master October 28, 2020 16:44
@Karsten1987
Copy link
Collaborator Author

  • Linux Build Status
  • Linux-aarch64 Build Status
  • macOS Build Status
  • Windows Build Status

@Karsten1987
Copy link
Collaborator Author

  • Linux Build Status
  • Linux-aarch64 Build Status
  • macOS Build Status
  • Windows Build Status

@adamdbrw
Copy link
Collaborator

adamdbrw commented Oct 29, 2020

As I am documenting the use of storage configuration parameter, I am struggling to find a good example of a useful PRAGMA setting for read: section in the yaml.
Do we have an example of how this could be useful, considering we can't do much that affects the db and we don't actually have a mechanism to query (read) pragma settings and return them to the user (even for information purposes)?

If not, I would change the --storage-config-file option to be only available to ros2 bag record and simplify yaml section from write/pragmas to pragmas.

Also, we should decide on the default values for journal_mode and synchronous settings. This would have significant impact on user experience in high performace scenarios, but I am also not sure how the db behaves with these settings when a crash occurs, and how common crashes are for users atm.

@pijaro
Copy link
Collaborator

pijaro commented Oct 29, 2020

I think that --storage-config-file is semantically correct for both play and record so we should keep it to simplify the cli interface, even if one scenario is currently lacking utility.

@emersonknapp
Copy link
Collaborator

I think that --storage-config-file is semantically correct for both play and record so we should keep it to simplify the cli interface, even if one scenario is currently lacking utility.

I agree with this, it's more flexible to allow for future use cases

@adamdbrw adamdbrw force-pushed the sqlite3_storage_config branch 2 times, most recently from ac0447d to e32edbb Compare November 2, 2020 11:16
@adamdbrw
Copy link
Collaborator

adamdbrw commented Nov 2, 2020

I had to force push to fix DCO issues

  • Adam Dąbrowski as author vs Adam Dabrowski (ą -> a) in signoff. I have been using plain "a".
  • Tomoya.Fujita vs tomoya in author/signoff mismatch (not sure how this one happened either).

Also, added some documentation earlier (could be more difficult to notice because of force pushes).
One pending decision - whether to change defaults for journal_mode and synchronous.

@Karsten1987
Copy link
Collaborator Author

Tomoya.Fujita vs tomoya in author/signoff mismatch (not sure how this one happened either).

This change seems unrelated to your PR and should not happen. I don't appreciate changing history of committers not participating in this PR.

@adamdbrw
Copy link
Collaborator

adamdbrw commented Nov 2, 2020

@Karsten1987 I assumed I was only reversing what happened as a side effect during a rebase I performed, since the original change was merged in already. Is there a suggestion how to handle this at this moment?

@emersonknapp
Copy link
Collaborator

emersonknapp commented Nov 2, 2020

You should be able to solve your problem with a proper rebase on master with no merges.

One way to get the history quite clean, if you don't care about any intermediate history on this PR, is to just git reset --mixed origin/master and make a single new commit that contains all changes.

Karsten1987 and others added 3 commits November 3, 2020 15:13
Signed-off-by: Karsten Knese <karsten@openrobotics.org>
Signed-off-by: Karsten Knese <Karsten1987@users.noreply.github.com>
- includes documentation of storage-config-file option
- includes adaptation of benchmarking script to cache size semantic change
- tests with valid and invalid storage file

Signed-off-by: Adam Dabrowski <adam.dabrowski@robotec.ai>
@adamdbrw
Copy link
Collaborator

adamdbrw commented Nov 3, 2020

@emersonknapp thanks for the tip, I used your approach but also cherry-picked @Karsten1987 commits so we have contributions properly attributed. Now, this should be much better - I preserved authorship of commits and at the same time merged all mine into what looks to me like a proper, targeted change. Let me know if this looks good to you.

I am looking into Windows build unstability - it seems that opening with a valid storage config file throws an exception.
By the look of it, this could be an issue with newline character & yaml parsing - @Karsten1987 could you check that for me? I would need to setup a Windows machine which is time consuming.

One place to look at is this line in test_sqlite_storage.cpp. I thought that newlines should be correctly converted to \n\r on Windows on flush, but maybe that's not the case:
const auto valid_yaml = "write:\n pragmas: [\"journal_mode = MEMORY\"]\n";

Copy link
Collaborator Author

@Karsten1987 Karsten1987 left a comment

Choose a reason for hiding this comment

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

This looks principally good to me. Just a few outstanding comments inline.

Running CI on this:

  • Linux Build Status
  • Linux-aarch64 Build Status
  • macOS Build Status
  • Windows Build Status

Comment on lines 99 to 100
{"journal_mode", pragma_assign + "WAL"},
{"synchronous", pragma_assign + "NORMAL"}
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

I am not sure how we decided on the default values in the end, but that's the non-optimized pragmas, right? Have we hereby decided that these are the default values?

Copy link
Collaborator

@adamdbrw adamdbrw Nov 10, 2020

Choose a reason for hiding this comment

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

If I recall correctly, we decided to change the defaults in a separate PR (along with changing the default split size to something else than 0 and including information about possible consequences). I can also add this change to current PR, doesn't make a difference to me. Let me know what is better.

Signed-off-by: Adam Dabrowski <adam.dabrowski@robotec.ai>
@pijaro
Copy link
Collaborator

pijaro commented Nov 10, 2020

I've inspected windows issues with rosbag2_storage_defatult_plugins tests. It looks like there is a problem with removing a temp dir when the storage throws an error in the throws_on_ivalid_pragma_in_config_file test (btw, typo in 'invalid' 😄 ). Temp dir can’t be removed because of win32 ERROR_SHARING_VIOLATION: “The process cannot access the file because it is being used by another process.”. You can confirm that by checking return value of SHFileOperation(…) in temporary_directory_fixture.hpp from rosbag2_test_common package.

Dirty workaround is to change tests order (move the test whith EXPECT_THROW to the end) - but still, some folders will remain in windows temp location.

- change pragma tests order as a workaround to fix tests issue on Windows: exception throwing tests don't clean temp folders

Signed-off-by: Adam Dabrowski <adam.dabrowski@robotec.ai>
@adamdbrw
Copy link
Collaborator

This should also pass Windows tests now

Copy link
Collaborator Author

@Karsten1987 Karsten1987 left a comment

Choose a reason for hiding this comment

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

CI

  • Linux Build Status
  • Linux-aarch64 Build Status
  • macOS Build Status
  • Windows Build Status

Signed-off-by: Adam Dabrowski <adam.dabrowski@robotec.ai>
@adamdbrw
Copy link
Collaborator

adamdbrw commented Nov 12, 2020

@Karsten1987: With all review remarks applied, are we good to merge this now?

@Karsten1987
Copy link
Collaborator Author

This looks good to me. Thanks for iterating with me. Just fyi, I can't formerly approve this PR as it's actually still opened under my name, but I just believe that @emersonknapp's approval still counts ;-)

CI for completness:

  • Linux Build Status
  • Linux-aarch64 Build Status
  • macOS Build Status
  • Windows Build Status

@Karsten1987 Karsten1987 merged commit 4bcb631 into master Nov 13, 2020
@delete-merged-branch delete-merged-branch bot deleted the sqlite3_storage_config branch November 13, 2020 05:17
emersonknapp pushed a commit that referenced this pull request Feb 2, 2021
* read yaml config file

Signed-off-by: Karsten Knese <karsten@openrobotics.org>

* address review comments

Signed-off-by: Karsten Knese <Karsten1987@users.noreply.github.com>

* Sqlite storage pragmas handling and validation
- includes documentation of storage-config-file option
- includes adaptation of benchmarking script to cache size semantic change
- tests with valid and invalid storage file

Signed-off-by: Adam Dabrowski <adam.dabrowski@robotec.ai>

* Applied review remarks

Signed-off-by: Adam Dabrowski <adam.dabrowski@robotec.ai>

* - Typo fix
- change pragma tests order as a workaround to fix tests issue on Windows: exception throwing tests don't clean temp folders

Signed-off-by: Adam Dabrowski <adam.dabrowski@robotec.ai>

* Applied review: moved some parsing and key extraction to parse function

Signed-off-by: Adam Dabrowski <adam.dabrowski@robotec.ai>

Co-authored-by: Adam Dabrowski <adam.dabrowski@robotec.ai>
emersonknapp pushed a commit that referenced this pull request Feb 17, 2021
* read yaml config file

Signed-off-by: Karsten Knese <karsten@openrobotics.org>

* address review comments

Signed-off-by: Karsten Knese <Karsten1987@users.noreply.github.com>

* Sqlite storage pragmas handling and validation
- includes documentation of storage-config-file option
- includes adaptation of benchmarking script to cache size semantic change
- tests with valid and invalid storage file

Signed-off-by: Adam Dabrowski <adam.dabrowski@robotec.ai>

* Applied review remarks

Signed-off-by: Adam Dabrowski <adam.dabrowski@robotec.ai>

* - Typo fix
- change pragma tests order as a workaround to fix tests issue on Windows: exception throwing tests don't clean temp folders

Signed-off-by: Adam Dabrowski <adam.dabrowski@robotec.ai>

* Applied review: moved some parsing and key extraction to parse function

Signed-off-by: Adam Dabrowski <adam.dabrowski@robotec.ai>

Co-authored-by: Adam Dabrowski <adam.dabrowski@robotec.ai>
Signed-off-by: Emerson Knapp <eknapp@amazon.com>
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.

None yet

4 participants