feat(core): make partitions attached via soft link read-only, protected from upserts#2710
Merged
bluestreak01 merged 222 commits intomasterfrom Jan 18, 2023
Merged
feat(core): make partitions attached via soft link read-only, protected from upserts#2710bluestreak01 merged 222 commits intomasterfrom
bluestreak01 merged 222 commits intomasterfrom
Conversation
…ion, the 5th is a mask which introduces RO flag
ab2c2c6 to
ec0d08c
Compare
Contributor
Author
|
I have removed the |
ideoma
reviewed
Jan 17, 2023
ideoma
approved these changes
Jan 17, 2023
Collaborator
[PR Coverage check]😍 pass : 480 / 538 (89.22%) file detail
|
Contributor
Author
|
approval!!!! oh!!!!! |
bluestreak01
approved these changes
Jan 18, 2023
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
TLDR:
The partition table segment is a block within the
_txnfile that contains 4 longs per attached partition:Each group of 4 longs is addressed by partitionIndex. These values are updated on commit. When a partition is detached/droppped, its associated 4 longs in the partition segment are removed.
The highest value for a partition's size is 0xFFFFFFFFFFFL (15 Tera Rows), leaving the highest 0xFFFFF of the 64 bit long available to use as a mask. This PR introduces a change in the partition segment size long to be structured in this way:
when read-only bit is set, the partition is read only.
To check a partition's size we obtain
maskedSizefrom the partition table (offset + PARTITION_MASKED_SIZE_OFFSET) and we conduct an&with PARTITION_SIZE_MASK.To update a partition's size we obtain
maskedSizefrom the partition table and update it like this:where PARTITION_MASK_MASK is 0x7FFFF00000000000L.
To check that a partition is read only we obtain
maskedSizeand test the 62nd bit.The read-only flag is set by the attach partition operation, for partitions attached from soft link. There are no other code paths to set it (although in testing I have hacked a way).
When read-only is set, these operations FAIL (ReadOnlyViolationException "skipping RW operation on RO partition"):
When read-only is set, these operations are NO-OP:
These operations will SUCCEED:
Class
Pathmade me constantly make mistakes all due to the requirement that all strings need to be null terminated. Under the scenes we would add a null char to the buffer and move the write pointer forward (a call to.$()). To later use the path again you would have to.chop()it first, to move the write pointer a position back. Now we do not move the pointer when we add the null char, and.chop()no longer exists. The path is ready for.concat()right after a call to.$()(which btw is now idempotent), the write pointer is pointing at the null so it will be overriden.