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

return error if the vlog writes exceeds more that 4GB. #1400

Merged
merged 5 commits into from
Jul 10, 2020

Conversation

poonai
Copy link
Contributor

@poonai poonai commented Jul 8, 2020

This PR check whether vlog writes are bigger than 4GB. If it's bigger than 4GB, it returns an error.
Signed-off-by: பாலாஜி balaji@dgraph.io


This change is Reviewable

…ceding

more than 4GB.

Signed-off-by: பாலாஜி <balaji@dgraph.io>
பாலாஜி added 2 commits July 9, 2020 10:50
Signed-off-by: பாலாஜி <balaji@dgraph.io>
Signed-off-by: பாலாஜி <balaji@dgraph.io>
Copy link
Contributor

@ashish-goswami ashish-goswami left a comment

Choose a reason for hiding this comment

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

:lgtm:

Reviewable status: 0 of 2 files reviewed, 4 unresolved discussions (waiting on @ashish-goswami, @balajijinnah, @jarifibrahim, and @manishrjain)


value.go, line 49 at r1 (raw file):

// maxVlogFileSize is the maximum size of the vlog file which can be created. Vlog Offset is of
// uint32, so limiting at max uint32

full stop.


value.go, line 1371 at r1 (raw file):

}

// validateWrites will check whether the given request can fit into 4GB vlog file.

*requests


value.go, line 1390 at r1 (raw file):

			continue
		}
		// estimated vlog offset will become current vlog offset if the vlog is not rotated.

*Estimated


value.go, line 1410 at r1 (raw file):

		return nil
	}
	// validate writes before writing to vlog. Because, we don't want to partially write and return

*Validate

Signed-off-by: பாலாஜி <balaji@dgraph.io>
Copy link
Contributor Author

@poonai poonai left a comment

Choose a reason for hiding this comment

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

Reviewable status: 0 of 2 files reviewed, 4 unresolved discussions (waiting on @ashish-goswami, @jarifibrahim, and @manishrjain)


value.go, line 49 at r1 (raw file):

Previously, ashish-goswami (Ashish Goswami) wrote…

full stop.

Done.


value.go, line 1371 at r1 (raw file):

Previously, ashish-goswami (Ashish Goswami) wrote…

*requests

Done.


value.go, line 1390 at r1 (raw file):

Previously, ashish-goswami (Ashish Goswami) wrote…

*Estimated

Done.


value.go, line 1410 at r1 (raw file):

Previously, ashish-goswami (Ashish Goswami) wrote…

*Validate

Done.

Copy link
Contributor

@jarifibrahim jarifibrahim left a comment

Choose a reason for hiding this comment

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

Reviewable status: 0 of 2 files reviewed, 6 unresolved discussions (waiting on @ashish-goswami, @balajijinnah, @jarifibrahim, and @manishrjain)


value.go, line 1381 at r2 (raw file):

		estimatedVlogOffset := vlogOffset + size
		if estimatedVlogOffset > uint64(maxVlogFileSize) {
			return errors.Errorf("Request size is bigger than %d", maxVlogFileSize)

Put the actual value as well. Request size %d is bigger than %d


value_test.go, line 1243 at r2 (raw file):

func TestValidateWrite(t *testing.T) {
	// Mocking the file size, so that we don't allocate big memory while running test.
	maxVlogFileSize = 400

You should reset this value in a defer call otherwise other tests will fail.

Copy link

@parasssh parasssh left a comment

Choose a reason for hiding this comment

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

:lgtm: but get LGTM from Ibrahim as well.

Reviewable status: 0 of 2 files reviewed, 6 unresolved discussions (waiting on @ashish-goswami, @balajijinnah, and @manishrjain)

Signed-off-by: பாலாஜி <balaji@dgraph.io>
@poonai poonai merged commit d981f47 into master Jul 10, 2020
@poonai poonai deleted the balaji/vlog_assert branch July 10, 2020 06:25
jarifibrahim pushed a commit to dgraph-io/dgraph that referenced this pull request Jul 11, 2020
Also, disable conflict detection in badger to save memory.

```
0dfb8b4 Changelog for v20.07.0 (dgraph-io/badger#1411)
03ba278 Add missing changelog for v2.0.3 (dgraph-io/badger#1410)
6001230 Revert "Compress/Encrypt Blocks in the background (dgraph-io/badger#1227)" (dgraph-io/badger#1409)
800305e Revert "Buffer pool for decompression
(dgraph-io/badger#1308)"
(dgraph-io/badger#1408)
63d9309 Revert "fix: Fix race condition in block.incRef
(dgraph-io/badger#1337)"
(dgraph-io/badger#1407)
e0d058c Revert "add assert to check integer overflow for table size (dgraph-io/badger#1402)" (dgraph-io/badger#1406)
d981f47 return error if the vlog writes exceeds more that 4GB.
(dgraph-io/badger#1400)
7f4e4b5 add assert to check integer overflow for table size
(dgraph-io/badger#1402)
8e896a7 Add a contribution guide
(dgraph-io/badger#1379)
b79aeef Avoid panic on multiple closer.Signal calls
(dgraph-io/badger#1401)
717b89c Enable cross-compiled 32bit tests on TravisCI
(dgraph-io/badger#1392)
09dfa66 Update ristretto to commit f66de99
(dgraph-io/badger#1391)
509de73 Update head while replaying value log
(dgraph-io/badger#1372)
e013bfd Rework DB.DropPrefix (dgraph-io/badger#1381)
3042e37 pre allocate cache key for the block cache and the bloom filter cache (dgraph-io/badger#1371)
675efcd Increase default valueThreshold from 32B to 1KB
(dgraph-io/badger#1346)
158d927 Remove second initialization of writech in Open
(dgraph-io/badger#1382)
d37ce36 Tests: Use t.Parallel in TestIteratePrefix tests
(dgraph-io/badger#1377)
3f4761d Force KeepL0InMemory to be true when InMemory is true
(dgraph-io/badger#1375)
dd332b0 Avoid panic in filltables()
(dgraph-io/badger#1365)
c45d966 Fix assert in background compression and encryption.
(dgraph-io/badger#1366)
```
jarifibrahim pushed a commit to dgraph-io/dgraph that referenced this pull request Jul 11, 2020
This commit brings the following new changes from badger.
This commit also disable conflict detection in badger to save memory.
```
Fix assert in background compression and encryption. (dgraph-io/badger#1366)
Avoid panic in filltables() (dgraph-io/badger#1365)
Force KeepL0InMemory to be true when InMemory is true (dgraph-io/badger#1375)
Tests: Use t.Parallel in TestIteratePrefix tests (dgraph-io/badger#1377)
Remove second initialization of writech in Open (dgraph-io/badger#1382)
Increase default valueThreshold from 32B to 1KB (dgraph-io/badger#1346)
pre allocate cache key for the block cache and the bloom filter cache (dgraph-io/badger#1371)
Rework DB.DropPrefix (dgraph-io/badger#1381)
Update head while replaying value log (dgraph-io/badger#1372)
Update ristretto to commit f66de99 (dgraph-io/badger#1391)
Enable cross-compiled 32bit tests on TravisCI (dgraph-io/badger#1392)
Avoid panic on multiple closer.Signal calls (dgraph-io/badger#1401)
Add a contribution guide (dgraph-io/badger#1379)
add assert to check integer overflow for table size (dgraph-io/badger#1402)
return error if the vlog writes exceeds more that 4GB. (dgraph-io/badger#1400)
Revert "add assert to check integer overflow for table size (dgraph-io/badger#1402)" (dgraph-io/badger#1406)
Revert "fix: Fix race condition in block.incRef (dgraph-io/badger#1337)" (dgraph-io/badger#1407)
Revert "Buffer pool for decompression (dgraph-io/badger#1308)" (dgraph-io/badger#1408)
Revert "Compress/Encrypt Blocks in the background (dgraph-io/badger#1227)" (dgraph-io/badger#1409)
Add missing changelog for v2.0.3 (dgraph-io/badger#1410)
Changelog for v20.07.0 (dgraph-io/badger#1411)
```
jarifibrahim pushed a commit to dgraph-io/dgraph that referenced this pull request Jul 11, 2020
This commit brings following new changes from badger
This commit also disable conflict detection in badger to save memory.

```
Fix assert in background compression and encryption. (dgraph-io/badger#1366)
Avoid panic in filltables() (dgraph-io/badger#1365)
Force KeepL0InMemory to be true when InMemory is true (dgraph-io/badger#1375)
Tests: Use t.Parallel in TestIteratePrefix tests (dgraph-io/badger#1377)
Remove second initialization of writech in Open (dgraph-io/badger#1382)
Increase default valueThreshold from 32B to 1KB (dgraph-io/badger#1346)
pre allocate cache key for the block cache and the bloom filter cache (dgraph-io/badger#1371)
Rework DB.DropPrefix (dgraph-io/badger#1381)
Update head while replaying value log (dgraph-io/badger#1372)
Update ristretto to commit f66de99 (dgraph-io/badger#1391)
Enable cross-compiled 32bit tests on TravisCI (dgraph-io/badger#1392)
Avoid panic on multiple closer.Signal calls (dgraph-io/badger#1401)
Add a contribution guide (dgraph-io/badger#1379)
add assert to check integer overflow for table size (dgraph-io/badger#1402)
return error if the vlog writes exceeds more that 4GB. (dgraph-io/badger#1400)
Revert "add assert to check integer overflow for table size (dgraph-io/badger#1402)" (dgraph-io/badger#1406)
Revert "fix: Fix race condition in block.incRef (dgraph-io/badger#1337)" (dgraph-io/badger#1407)
Revert "Buffer pool for decompression (dgraph-io/badger#1308)" (dgraph-io/badger#1408)
Revert "Compress/Encrypt Blocks in the background (dgraph-io/badger#1227)" (dgraph-io/badger#1409)
Add missing changelog for v2.0.3 (dgraph-io/badger#1410)
Changelog for v20.07.0 (dgraph-io/badger#1411)
```
jarifibrahim pushed a commit to dgraph-io/dgraph that referenced this pull request Jul 11, 2020
This commit brings following new changes from badger
This commit also disable conflict detection in badger to save memory.

```
Fix assert in background compression and encryption. (dgraph-io/badger#1366)
Avoid panic in filltables() (dgraph-io/badger#1365)
Force KeepL0InMemory to be true when InMemory is true (dgraph-io/badger#1375)
Tests: Use t.Parallel in TestIteratePrefix tests (dgraph-io/badger#1377)
Remove second initialization of writech in Open (dgraph-io/badger#1382)
Increase default valueThreshold from 32B to 1KB (dgraph-io/badger#1346)
pre allocate cache key for the block cache and the bloom filter cache (dgraph-io/badger#1371)
Rework DB.DropPrefix (dgraph-io/badger#1381)
Update head while replaying value log (dgraph-io/badger#1372)
Update ristretto to commit f66de99 (dgraph-io/badger#1391)
Enable cross-compiled 32bit tests on TravisCI (dgraph-io/badger#1392)
Avoid panic on multiple closer.Signal calls (dgraph-io/badger#1401)
Add a contribution guide (dgraph-io/badger#1379)
add assert to check integer overflow for table size (dgraph-io/badger#1402)
return error if the vlog writes exceeds more that 4GB. (dgraph-io/badger#1400)
Revert "add assert to check integer overflow for table size (dgraph-io/badger#1402)" (dgraph-io/badger#1406)
Revert "fix: Fix race condition in block.incRef (dgraph-io/badger#1337)" (dgraph-io/badger#1407)
Revert "Buffer pool for decompression (dgraph-io/badger#1308)" (dgraph-io/badger#1408)
Revert "Compress/Encrypt Blocks in the background (dgraph-io/badger#1227)" (dgraph-io/badger#1409)
Add missing changelog for v2.0.3 (dgraph-io/badger#1410)
Changelog for v20.07.0 (dgraph-io/badger#1411)
```
jarifibrahim pushed a commit to dgraph-io/dgraph that referenced this pull request Jul 11, 2020
This commit brings following new changes from badger
This commit also disable conflict detection in badger to save memory.

```
Fix assert in background compression and encryption. (dgraph-io/badger#1366)
Avoid panic in filltables() (dgraph-io/badger#1365)
Force KeepL0InMemory to be true when InMemory is true (dgraph-io/badger#1375)
Tests: Use t.Parallel in TestIteratePrefix tests (dgraph-io/badger#1377)
Remove second initialization of writech in Open (dgraph-io/badger#1382)
Increase default valueThreshold from 32B to 1KB (dgraph-io/badger#1346)
pre allocate cache key for the block cache and the bloom filter cache (dgraph-io/badger#1371)
Rework DB.DropPrefix (dgraph-io/badger#1381)
Update head while replaying value log (dgraph-io/badger#1372)
Update ristretto to commit f66de99 (dgraph-io/badger#1391)
Enable cross-compiled 32bit tests on TravisCI (dgraph-io/badger#1392)
Avoid panic on multiple closer.Signal calls (dgraph-io/badger#1401)
Add a contribution guide (dgraph-io/badger#1379)
add assert to check integer overflow for table size (dgraph-io/badger#1402)
return error if the vlog writes exceeds more that 4GB. (dgraph-io/badger#1400)
Revert "add assert to check integer overflow for table size (dgraph-io/badger#1402)" (dgraph-io/badger#1406)
Revert "fix: Fix race condition in block.incRef (dgraph-io/badger#1337)" (dgraph-io/badger#1407)
Revert "Buffer pool for decompression (dgraph-io/badger#1308)" (dgraph-io/badger#1408)
Revert "Compress/Encrypt Blocks in the background (dgraph-io/badger#1227)" (dgraph-io/badger#1409)
Add missing changelog for v2.0.3 (dgraph-io/badger#1410)
Changelog for v20.07.0 (dgraph-io/badger#1411)
```
parasssh pushed a commit to dgraph-io/dgraph that referenced this pull request Jul 13, 2020
* Update badger to v20.07.0-rc1

This commit brings following new changes from badger
This commit also disable conflict detection in badger to save memory.

```
Fix assert in background compression and encryption. (dgraph-io/badger#1366)
Avoid panic in filltables() (dgraph-io/badger#1365)
Force KeepL0InMemory to be true when InMemory is true (dgraph-io/badger#1375)
Tests: Use t.Parallel in TestIteratePrefix tests (dgraph-io/badger#1377)
Remove second initialization of writech in Open (dgraph-io/badger#1382)
Increase default valueThreshold from 32B to 1KB (dgraph-io/badger#1346)
pre allocate cache key for the block cache and the bloom filter cache (dgraph-io/badger#1371)
Rework DB.DropPrefix (dgraph-io/badger#1381)
Update head while replaying value log (dgraph-io/badger#1372)
Update ristretto to commit f66de99 (dgraph-io/badger#1391)
Enable cross-compiled 32bit tests on TravisCI (dgraph-io/badger#1392)
Avoid panic on multiple closer.Signal calls (dgraph-io/badger#1401)
Add a contribution guide (dgraph-io/badger#1379)
add assert to check integer overflow for table size (dgraph-io/badger#1402)
return error if the vlog writes exceeds more that 4GB. (dgraph-io/badger#1400)
Revert "add assert to check integer overflow for table size (dgraph-io/badger#1402)" (dgraph-io/badger#1406)
Revert "fix: Fix race condition in block.incRef (dgraph-io/badger#1337)" (dgraph-io/badger#1407)
Revert "Buffer pool for decompression (dgraph-io/badger#1308)" (dgraph-io/badger#1408)
Revert "Compress/Encrypt Blocks in the background (dgraph-io/badger#1227)" (dgraph-io/badger#1409)
Add missing changelog for v2.0.3 (dgraph-io/badger#1410)
Changelog for v20.07.0 (dgraph-io/badger#1411)
```

* Remove unnecessary detect conflicts
parasssh pushed a commit to dgraph-io/dgraph that referenced this pull request Jul 13, 2020
* Update badger to v20.07.0-rc1

This commit brings the following new changes from badger.
This commit also disable conflict detection in badger to save memory.
```
Fix assert in background compression and encryption. (dgraph-io/badger#1366)
Avoid panic in filltables() (dgraph-io/badger#1365)
Force KeepL0InMemory to be true when InMemory is true (dgraph-io/badger#1375)
Tests: Use t.Parallel in TestIteratePrefix tests (dgraph-io/badger#1377)
Remove second initialization of writech in Open (dgraph-io/badger#1382)
Increase default valueThreshold from 32B to 1KB (dgraph-io/badger#1346)
pre allocate cache key for the block cache and the bloom filter cache (dgraph-io/badger#1371)
Rework DB.DropPrefix (dgraph-io/badger#1381)
Update head while replaying value log (dgraph-io/badger#1372)
Update ristretto to commit f66de99 (dgraph-io/badger#1391)
Enable cross-compiled 32bit tests on TravisCI (dgraph-io/badger#1392)
Avoid panic on multiple closer.Signal calls (dgraph-io/badger#1401)
Add a contribution guide (dgraph-io/badger#1379)
add assert to check integer overflow for table size (dgraph-io/badger#1402)
return error if the vlog writes exceeds more that 4GB. (dgraph-io/badger#1400)
Revert "add assert to check integer overflow for table size (dgraph-io/badger#1402)" (dgraph-io/badger#1406)
Revert "fix: Fix race condition in block.incRef (dgraph-io/badger#1337)" (dgraph-io/badger#1407)
Revert "Buffer pool for decompression (dgraph-io/badger#1308)" (dgraph-io/badger#1408)
Revert "Compress/Encrypt Blocks in the background (dgraph-io/badger#1227)" (dgraph-io/badger#1409)
Add missing changelog for v2.0.3 (dgraph-io/badger#1410)
Changelog for v20.07.0 (dgraph-io/badger#1411)
```

* Remove unnecessary detect conflicts
parasssh pushed a commit to dgraph-io/dgraph that referenced this pull request Jul 13, 2020
* Update badger to v20.07.0-rc1

This commit brings following new changes from badger
This commit also disable conflict detection in badger to save memory.

```
Fix assert in background compression and encryption. (dgraph-io/badger#1366)
Avoid panic in filltables() (dgraph-io/badger#1365)
Force KeepL0InMemory to be true when InMemory is true (dgraph-io/badger#1375)
Tests: Use t.Parallel in TestIteratePrefix tests (dgraph-io/badger#1377)
Remove second initialization of writech in Open (dgraph-io/badger#1382)
Increase default valueThreshold from 32B to 1KB (dgraph-io/badger#1346)
pre allocate cache key for the block cache and the bloom filter cache (dgraph-io/badger#1371)
Rework DB.DropPrefix (dgraph-io/badger#1381)
Update head while replaying value log (dgraph-io/badger#1372)
Update ristretto to commit f66de99 (dgraph-io/badger#1391)
Enable cross-compiled 32bit tests on TravisCI (dgraph-io/badger#1392)
Avoid panic on multiple closer.Signal calls (dgraph-io/badger#1401)
Add a contribution guide (dgraph-io/badger#1379)
add assert to check integer overflow for table size (dgraph-io/badger#1402)
return error if the vlog writes exceeds more that 4GB. (dgraph-io/badger#1400)
Revert "add assert to check integer overflow for table size (dgraph-io/badger#1402)" (dgraph-io/badger#1406)
Revert "fix: Fix race condition in block.incRef (dgraph-io/badger#1337)" (dgraph-io/badger#1407)
Revert "Buffer pool for decompression (dgraph-io/badger#1308)" (dgraph-io/badger#1408)
Revert "Compress/Encrypt Blocks in the background (dgraph-io/badger#1227)" (dgraph-io/badger#1409)
Add missing changelog for v2.0.3 (dgraph-io/badger#1410)
Changelog for v20.07.0 (dgraph-io/badger#1411)
```

* Remove unnecessary detect conflicts

Co-authored-by: parasssh <paras@dgraph.io>
parasssh pushed a commit to dgraph-io/dgraph that referenced this pull request Jul 13, 2020
* Update badger to v20.0.7-rc1

This commit brings following new changes from badger
This commit also disable conflict detection in badger to save memory.

```
Fix assert in background compression and encryption. (dgraph-io/badger#1366)
Avoid panic in filltables() (dgraph-io/badger#1365)
Force KeepL0InMemory to be true when InMemory is true (dgraph-io/badger#1375)
Tests: Use t.Parallel in TestIteratePrefix tests (dgraph-io/badger#1377)
Remove second initialization of writech in Open (dgraph-io/badger#1382)
Increase default valueThreshold from 32B to 1KB (dgraph-io/badger#1346)
pre allocate cache key for the block cache and the bloom filter cache (dgraph-io/badger#1371)
Rework DB.DropPrefix (dgraph-io/badger#1381)
Update head while replaying value log (dgraph-io/badger#1372)
Update ristretto to commit f66de99 (dgraph-io/badger#1391)
Enable cross-compiled 32bit tests on TravisCI (dgraph-io/badger#1392)
Avoid panic on multiple closer.Signal calls (dgraph-io/badger#1401)
Add a contribution guide (dgraph-io/badger#1379)
add assert to check integer overflow for table size (dgraph-io/badger#1402)
return error if the vlog writes exceeds more that 4GB. (dgraph-io/badger#1400)
Revert "add assert to check integer overflow for table size (dgraph-io/badger#1402)" (dgraph-io/badger#1406)
Revert "fix: Fix race condition in block.incRef (dgraph-io/badger#1337)" (dgraph-io/badger#1407)
Revert "Buffer pool for decompression (dgraph-io/badger#1308)" (dgraph-io/badger#1408)
Revert "Compress/Encrypt Blocks in the background (dgraph-io/badger#1227)" (dgraph-io/badger#1409)
Add missing changelog for v2.0.3 (dgraph-io/badger#1410)
Changelog for v20.07.0 (dgraph-io/badger#1411)
```

* Remove unnecessary detect conflicts

Co-authored-by: parasssh <paras@dgraph.io>
dna2github pushed a commit to dna2fork/dgraph that referenced this pull request Jul 18, 2020
* Update badger to v20.07.0-rc1

This commit brings the following new changes from badger.
This commit also disable conflict detection in badger to save memory.
```
Fix assert in background compression and encryption. (dgraph-io/badger#1366)
Avoid panic in filltables() (dgraph-io/badger#1365)
Force KeepL0InMemory to be true when InMemory is true (dgraph-io/badger#1375)
Tests: Use t.Parallel in TestIteratePrefix tests (dgraph-io/badger#1377)
Remove second initialization of writech in Open (dgraph-io/badger#1382)
Increase default valueThreshold from 32B to 1KB (dgraph-io/badger#1346)
pre allocate cache key for the block cache and the bloom filter cache (dgraph-io/badger#1371)
Rework DB.DropPrefix (dgraph-io/badger#1381)
Update head while replaying value log (dgraph-io/badger#1372)
Update ristretto to commit f66de99 (dgraph-io/badger#1391)
Enable cross-compiled 32bit tests on TravisCI (dgraph-io/badger#1392)
Avoid panic on multiple closer.Signal calls (dgraph-io/badger#1401)
Add a contribution guide (dgraph-io/badger#1379)
add assert to check integer overflow for table size (dgraph-io/badger#1402)
return error if the vlog writes exceeds more that 4GB. (dgraph-io/badger#1400)
Revert "add assert to check integer overflow for table size (dgraph-io/badger#1402)" (dgraph-io/badger#1406)
Revert "fix: Fix race condition in block.incRef (dgraph-io/badger#1337)" (dgraph-io/badger#1407)
Revert "Buffer pool for decompression (dgraph-io/badger#1308)" (dgraph-io/badger#1408)
Revert "Compress/Encrypt Blocks in the background (dgraph-io/badger#1227)" (dgraph-io/badger#1409)
Add missing changelog for v2.0.3 (dgraph-io/badger#1410)
Changelog for v20.07.0 (dgraph-io/badger#1411)
```

* Remove unnecessary detect conflicts
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

Successfully merging this pull request may close these issues.

4 participants