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

storage/disk: try fix for bader error «txn is too big to fit into one… #3880

Merged

Conversation

floriangasc
Copy link
Contributor

… request»

runtime: unlock choice before disk and in memory storage

Signed-off-by: Gasc Florian florian.gasc@gmail.com
Fixes #3879

@floriangasc floriangasc force-pushed the little-work-on-disk-storage branch from 3b871b1 to fc23131 Compare October 11, 2021 05:05
Copy link
Contributor

@srenatus srenatus left a comment

Choose a reason for hiding this comment

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

Thanks a lot again, this is great. There are a few things to take care of, but let's fix this bug 💯

@floriangasc floriangasc force-pushed the little-work-on-disk-storage branch from eb3dd98 to 94490c0 Compare October 13, 2021 13:14
@floriangasc
Copy link
Contributor Author

floriangasc commented Oct 13, 2021

Hi,

Tanks for your review. I made correction.

  1. use helper for json
  2. clean code on fixed code
  3. (re) hide disk from cli: i restored run.go and runtime.go from main.

ps:

  1. i don't really know/understand the whole process for P.R and work on this kind of project. It's only the second time i contribute to something. (the first is ng2 a long time ago). Please excuse me in advance if i do something wrong.
  2. i don't know if you saw the comment i wrote on issue about : if unit (non regression) test should assert no key are lost. I wonder if it's badger or OPA reponsability to check that when this error occured.

@floriangasc floriangasc force-pushed the little-work-on-disk-storage branch from 94490c0 to 25629e2 Compare October 13, 2021 13:54
Copy link
Contributor

@srenatus srenatus left a comment

Choose a reason for hiding this comment

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

Just some nitpicks, let's get this merged and take it from there 👍 Thanks again for looking into this and bearing with me.

@floriangasc
Copy link
Contributor Author

floriangasc commented Oct 14, 2021

hi

Thanks for pertinent feedback.

i made change, but there is one question in suspend (writed in PS.2 of my previous comment) and i would be sure about what should be test:

unit (non regression) test should assert no key are lost ? ( I wonder if it's badger or OPA reponsability to check that when this error occured.)

@srenatus
Copy link
Contributor

unit (non regression) test should assert no key are lost ? ( I wonder if it's badger or OPA reponsability to check that when this error occured.)

It think it would make sense to have some read-back to assert what's been stored under this condition. After all, it's not obvious to me: if the txn was too big, and we commit it, did it discard stuff or still work...?

That aside, thanks for bearing with me on all the comments 👍

@floriangasc
Copy link
Contributor Author

floriangasc commented Oct 14, 2021

i think too. it's better to assert the state is ok by read what is inserted.

if it's ok for you, i should add this test for assert no key are lost and i repush the test with new assert.

I await your a approvement for doing this assert :)

@srenatus
Copy link
Contributor

@floriangasc thank you! sounds like a good way forward.

@floriangasc
Copy link
Contributor Author

floriangasc commented Oct 14, 2021

the test of read catch a very not cool bug.

I will come back to you when i will have resolved the bug: some keys are lost, and there is a problem with re-assign the txn in the disk store. I study the code now.

May be there will be some question.

@srenatus srenatus marked this pull request as draft October 14, 2021 16:07
@srenatus
Copy link
Contributor

@floriangasc I've converted this to draft, feel free to click "ready for review" when it's time!

@floriangasc floriangasc force-pushed the little-work-on-disk-storage branch 2 times, most recently from d9b1eb4 to fa86ba8 Compare October 14, 2021 17:08
@floriangasc
Copy link
Contributor Author

floriangasc commented Oct 14, 2021

Hi.

i have done with test «no lost key».

The explanation of the previous message:

  1. the first problem is when i change the code according p.r i introduce a bug (I should have run the tests before commit/push :( )
  2. The second problem occured when i generate key. because of generate lot of (140_000) key with 3 random latter, when the array is converted into hashmap (json object) the same key are collapse, so i get less than 140_000 ( with number of missing key is random). But before I release that, for debug, i have introduce a «false bug» with commit transaction 2 times.
  3. In the same time, i have the made a tiny rewrite of my code. Let me see's if you think it's better

At the end

  1. the initial "txn is too big to fit into one request", is fixed
  2. the problem introduce by the P.R are fixed
  3. there a test that insert 140_000 keys with each have value (of 3 characters) that is enough for trigger the bug and test when error occurred, when we read the store after that, the 140_000 key are present

@floriangasc floriangasc marked this pull request as ready for review October 15, 2021 09:05
@floriangasc
Copy link
Contributor Author

hi,

For the P.R there are some points which must be treated with attention

  1. I don't find a better way to (set|delete)WithErrTxnTooBigErrorHandling function. If you have better idea, you are welcome
  2. I don't know how to solve circular import in test: "github.com/open-policy-agent/opa/storage/disk"

@floriangasc
Copy link
Contributor Author

What is the next step ?

@srenatus
Copy link
Contributor

We'll get this reviewed and merged 😄 can you also please squash the commits? One should be fine.

@srenatus
Copy link
Contributor

Also getting the tests green would be great.

@floriangasc
Copy link
Contributor Author

Great. i doing this monday!

@floriangasc floriangasc force-pushed the little-work-on-disk-storage branch 5 times, most recently from 905be3a to b8e8836 Compare October 18, 2021 12:45
}
actualNbKeys := len(result.(map[string]interface{}))
if nbKeys != actualNbKeys {
t.Fatalf("Unexpected <~nbKeys: " + strconv.Itoa(nbKeys) + " ~> read whereas <~actualNbKeys: " + strconv.Itoa(actualNbKeys) + "~> inserted")
Copy link
Contributor

Choose a reason for hiding this comment

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

[nit]

Suggested change
t.Fatalf("Unexpected <~nbKeys: " + strconv.Itoa(nbKeys) + " ~> read whereas <~actualNbKeys: " + strconv.Itoa(actualNbKeys) + "~> inserted")
t.Fatalf("Expected %d keys, read %d", nbKeys, actualNbKeys)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Good, fixed.

@floriangasc floriangasc force-pushed the little-work-on-disk-storage branch from b8e8836 to 3c48577 Compare October 18, 2021 12:49
@floriangasc floriangasc force-pushed the little-work-on-disk-storage branch 2 times, most recently from bfe08b4 to a74e74b Compare October 18, 2021 12:58
@floriangasc
Copy link
Contributor Author

floriangasc commented Oct 18, 2021

All checks have passed \o/\o/ :)

Copy link
Contributor

@srenatus srenatus left a comment

Choose a reason for hiding this comment

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

This is getting close, thanks for bearing with me. One more question re: the delete case, and a small nitpick. I think this is the last round 🤞

@floriangasc floriangasc force-pushed the little-work-on-disk-storage branch 5 times, most recently from 4985d46 to 05efce2 Compare October 20, 2021 05:29
… non regression test

Signed-off-by: Gasc Florian <florian.gasc@gmail.com>
@floriangasc floriangasc force-pushed the little-work-on-disk-storage branch from 05efce2 to 54787cf Compare October 20, 2021 05:30
@floriangasc
Copy link
Contributor Author

Hi, @srenatus

Just for be sure if i have done a good job and all it's ok ?

Copy link
Contributor

@srenatus srenatus left a comment

Choose a reason for hiding this comment

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

LGTM. Thanks again!

@srenatus srenatus merged commit 528836a into open-policy-agent:main Oct 20, 2021
@floriangasc floriangasc deleted the little-work-on-disk-storage branch October 21, 2021 05:17
dolevf pushed a commit to dolevf/opa that referenced this pull request Nov 4, 2021
Fixes #open-policy-agent#3879.

Signed-off-by: Gasc Florian <florian.gasc@gmail.com>
Signed-off-by: Dolev Farhi <farhi.dolev@gmail.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.

Txn is too big to fit into one request when use disk store
2 participants