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

[Enhancement] Support large json in image (backport #48569) #49895

Merged
merged 2 commits into from
Aug 19, 2024

Conversation

mergify[bot]
Copy link
Contributor

@mergify mergify bot commented Aug 16, 2024

Why I'm doing:

Currently, JSON serialization supports a maximum of 2G, because serialization converts the object into a JSON string first, and then writes the string into the image file, and the maximum size of a string in Java is only 2G.

What I'm doing:

To support large json string, we can use the stream api of GSON: JsonWriter and JsonReader.
Since we cannot know the length of the string in advance, so a new image file format is introduced: a json string must begin with "{" or "[", so primitive type is not supported, and there is nothing between the json string. To support rollback, we use a double write solution. The dir format is as follows

meta/image
         image.111
         /v2
              image.111
              checksum.111

meta/image/image.111 is the old format image file, and meta/image/v2/image.111 is the new format image file. Since the JsonReader will cache some chars in advance, so we cannot calculate the checksum of the specific meta-block, and the checksum is put into another file checksum.111;

What type of PR is this:

  • BugFix
  • Feature
  • Enhancement
  • Refactor
  • UT
  • Doc
  • Tool

Does this PR entail a change in behavior?

  • Yes, this PR will result in a change in behavior.
  • No, this PR will not result in a change in behavior.

If yes, please specify the type of change:

  • Interface/UI changes: syntax, type conversion, expression evaluation, display information
  • Parameter changes: default values, similar parameters but with different default values
  • Policy changes: use new policy to replace old one, functionality automatically enabled
  • Feature removed
  • Miscellaneous: upgrade & downgrade compatibility, etc.

Checklist:

  • I have added test cases for my bug fix or my new feature
  • This pr needs user documentation (for new or modified features or behaviors)
    • I have added documentation for my new feature or new function
  • This is a backport pr

Bugfix cherry-pick branch check:

  • I have checked the version labels which the pr will be auto-backported to the target branch
    • 3.3
    • 3.2
    • 3.1
    • 3.0
    • 2.5

This is an automatic backport of pull request #48569 done by [Mergify](https://mergify.com). ## Why I'm doing: Currently, JSON serialization supports a maximum of 2G, because serialization converts the object into a JSON string first, and then writes the string into the image file, and the maximum size of a string in Java is only 2G.

What I'm doing:

To support large json string, we can use the stream api of GSON: JsonWriter and JsonReader.
Since we cannot know the length of the string in advance, so a new image file format is introduced: a json string must begin with "{" or "[", so primitive type is not supported, and there is nothing between the json string. To support rollback, we use a double write solution. The dir format is as follows

meta/image
         image.111
         /v2
              image.111
              checksum.111

meta/image/image.111 is the old format image file, and meta/image/v2/image.111 is the new format image file. Since the JsonReader will cache some chars in advance, so we cannot calculate the checksum of the specific meta-block, and the checksum is put into another file checksum.111;

What type of PR is this:

  • BugFix
  • Feature
  • Enhancement
  • Refactor
  • UT
  • Doc
  • Tool

Does this PR entail a change in behavior?

  • Yes, this PR will result in a change in behavior.
  • No, this PR will not result in a change in behavior.

If yes, please specify the type of change:

  • Interface/UI changes: syntax, type conversion, expression evaluation, display information
  • Parameter changes: default values, similar parameters but with different default values
  • Policy changes: use new policy to replace old one, functionality automatically enabled
  • Feature removed
  • Miscellaneous: upgrade & downgrade compatibility, etc.

Checklist:

  • I have added test cases for my bug fix or my new feature
  • This pr needs user documentation (for new or modified features or behaviors)
    • I have added documentation for my new feature or new function
  • This is a backport pr

Signed-off-by: gengjun-git <[email protected]>
(cherry picked from commit 78715a7)

# Conflicts:
#	fe/fe-core/src/main/java/com/starrocks/authentication/AuthenticationMgr.java
#	fe/fe-core/src/main/java/com/starrocks/http/meta/MetaService.java
#	fe/fe-core/src/main/java/com/starrocks/leader/Checkpoint.java
#	fe/fe-core/src/main/java/com/starrocks/server/LocalMetastore.java
@mergify mergify bot added the conflicts label Aug 16, 2024
Copy link
Contributor Author

mergify bot commented Aug 16, 2024

Cherry-pick of 78715a7 has failed:

On branch mergify/bp/branch-3.3/pr-48569
Your branch is up to date with 'origin/branch-3.3'.

You are currently cherry-picking commit 78715a708a.
  (fix conflicts and run "git cherry-pick --continue")
  (use "git cherry-pick --skip" to skip this patch)
  (use "git cherry-pick --abort" to cancel the cherry-pick operation)

Changes to be committed:
	modified:   fe/fe-core/src/main/java/com/starrocks/alter/AlterJobMgr.java
	modified:   fe/fe-core/src/main/java/com/starrocks/backup/BackupHandler.java
	modified:   fe/fe-core/src/main/java/com/starrocks/catalog/CatalogRecycleBin.java
	modified:   fe/fe-core/src/main/java/com/starrocks/catalog/ColocateTableIndex.java
	modified:   fe/fe-core/src/main/java/com/starrocks/catalog/DictionaryMgr.java
	modified:   fe/fe-core/src/main/java/com/starrocks/catalog/GlobalFunctionMgr.java
	modified:   fe/fe-core/src/main/java/com/starrocks/catalog/ResourceGroupMgr.java
	modified:   fe/fe-core/src/main/java/com/starrocks/catalog/ResourceMgr.java
	modified:   fe/fe-core/src/main/java/com/starrocks/common/util/SmallFileMgr.java
	modified:   fe/fe-core/src/main/java/com/starrocks/encryption/KeyMgr.java
	modified:   fe/fe-core/src/main/java/com/starrocks/http/meta/MetaBaseAction.java
	modified:   fe/fe-core/src/main/java/com/starrocks/lake/compaction/CompactionMgr.java
	modified:   fe/fe-core/src/main/java/com/starrocks/leader/MetaHelper.java
	modified:   fe/fe-core/src/main/java/com/starrocks/load/DeleteMgr.java
	modified:   fe/fe-core/src/main/java/com/starrocks/load/ExportMgr.java
	modified:   fe/fe-core/src/main/java/com/starrocks/load/InsertOverwriteJobMgr.java
	modified:   fe/fe-core/src/main/java/com/starrocks/load/loadv2/LoadMgr.java
	modified:   fe/fe-core/src/main/java/com/starrocks/load/pipe/PipeManager.java
	modified:   fe/fe-core/src/main/java/com/starrocks/load/pipe/PipeRepo.java
	modified:   fe/fe-core/src/main/java/com/starrocks/load/routineload/RoutineLoadMgr.java
	modified:   fe/fe-core/src/main/java/com/starrocks/load/streamload/StreamLoadMgr.java
	new file:   fe/fe-core/src/main/java/com/starrocks/persist/ImageFormatVersion.java
	new file:   fe/fe-core/src/main/java/com/starrocks/persist/ImageLoader.java
	new file:   fe/fe-core/src/main/java/com/starrocks/persist/ImageWriter.java
	modified:   fe/fe-core/src/main/java/com/starrocks/persist/MetaCleaner.java
	modified:   fe/fe-core/src/main/java/com/starrocks/persist/Storage.java
	modified:   fe/fe-core/src/main/java/com/starrocks/persist/StorageInfo.java
	new file:   fe/fe-core/src/main/java/com/starrocks/persist/metablock/IntObject.java
	new file:   fe/fe-core/src/main/java/com/starrocks/persist/metablock/LongObject.java
	modified:   fe/fe-core/src/main/java/com/starrocks/persist/metablock/SRMetaBlockReader.java
	new file:   fe/fe-core/src/main/java/com/starrocks/persist/metablock/SRMetaBlockReaderV1.java
	new file:   fe/fe-core/src/main/java/com/starrocks/persist/metablock/SRMetaBlockReaderV2.java
	modified:   fe/fe-core/src/main/java/com/starrocks/persist/metablock/SRMetaBlockWriter.java
	new file:   fe/fe-core/src/main/java/com/starrocks/persist/metablock/SRMetaBlockWriterV1.java
	new file:   fe/fe-core/src/main/java/com/starrocks/persist/metablock/SRMetaBlockWriterV2.java
	modified:   fe/fe-core/src/main/java/com/starrocks/plugin/PluginMgr.java
	modified:   fe/fe-core/src/main/java/com/starrocks/privilege/AuthorizationMgr.java
	modified:   fe/fe-core/src/main/java/com/starrocks/qe/VariableMgr.java
	modified:   fe/fe-core/src/main/java/com/starrocks/replication/ReplicationMgr.java
	modified:   fe/fe-core/src/main/java/com/starrocks/scheduler/TaskManager.java
	modified:   fe/fe-core/src/main/java/com/starrocks/scheduler/mv/MaterializedViewMgr.java
	modified:   fe/fe-core/src/main/java/com/starrocks/server/CatalogMgr.java
	modified:   fe/fe-core/src/main/java/com/starrocks/server/GlobalStateMgr.java
	modified:   fe/fe-core/src/main/java/com/starrocks/server/NodeMgr.java
	modified:   fe/fe-core/src/main/java/com/starrocks/server/StorageVolumeMgr.java
	modified:   fe/fe-core/src/main/java/com/starrocks/statistic/AnalyzeMgr.java
	modified:   fe/fe-core/src/main/java/com/starrocks/transaction/GlobalTransactionMgr.java
	modified:   fe/fe-core/src/test/java/com/starrocks/alter/AlterJobV2Test.java
	modified:   fe/fe-core/src/test/java/com/starrocks/alter/AlterTableTest.java
	modified:   fe/fe-core/src/test/java/com/starrocks/analysis/CreateMaterializedViewTest.java
	modified:   fe/fe-core/src/test/java/com/starrocks/authentication/AuthenticationManagerTest.java
	modified:   fe/fe-core/src/test/java/com/starrocks/backup/BackupHandlerTest.java
	modified:   fe/fe-core/src/test/java/com/starrocks/catalog/ColocateTableIndexTest.java
	modified:   fe/fe-core/src/test/java/com/starrocks/catalog/CreateTableTest.java
	modified:   fe/fe-core/src/test/java/com/starrocks/common/util/SmallFileMgrTest.java
	modified:   fe/fe-core/src/test/java/com/starrocks/encryption/KeyMgrTest.java
	modified:   fe/fe-core/src/test/java/com/starrocks/ha/BDBHATest.java
	modified:   fe/fe-core/src/test/java/com/starrocks/lake/compaction/CompactionMgrTest.java
	modified:   fe/fe-core/src/test/java/com/starrocks/load/ExportMgrTest.java
	modified:   fe/fe-core/src/test/java/com/starrocks/load/loadv2/LoadMgrTest.java
	modified:   fe/fe-core/src/test/java/com/starrocks/load/pipe/PipeManagerTest.java
	modified:   fe/fe-core/src/test/java/com/starrocks/load/routineload/RoutineLoadManagerTest.java
	new file:   fe/fe-core/src/test/java/com/starrocks/persist/ImageLoaderTest.java
	modified:   fe/fe-core/src/test/java/com/starrocks/persist/StorageInfoTest.java
	modified:   fe/fe-core/src/test/java/com/starrocks/persist/StorageTest.java
	renamed:    fe/fe-core/src/test/java/com/starrocks/persist/metablock/SRMetaBlockTest.java -> fe/fe-core/src/test/java/com/starrocks/persist/metablock/SRMetaBlockV1Test.java
	new file:   fe/fe-core/src/test/java/com/starrocks/persist/metablock/SRMetaBlockV2Test.java
	modified:   fe/fe-core/src/test/java/com/starrocks/privilege/AuthorizationMgrTest.java
	modified:   fe/fe-core/src/test/java/com/starrocks/server/CatalogMgrTest.java
	modified:   fe/fe-core/src/test/java/com/starrocks/server/GlobalStateMgrTest.java
	modified:   fe/fe-core/src/test/java/com/starrocks/server/LocalMetaStoreTest.java
	modified:   fe/fe-core/src/test/java/com/starrocks/server/SharedDataStorageVolumeMgrTest.java
	modified:   fe/fe-core/src/test/java/com/starrocks/sql/analyzer/AlterSystemStmtAnalyzerTest.java
	modified:   fe/fe-core/src/test/java/com/starrocks/statistic/AnalyzeMgrTest.java
	modified:   fe/fe-core/src/test/java/com/starrocks/transaction/GlobalTransactionMgrTest.java
	modified:   fe/fe-core/src/test/java/com/starrocks/utframe/UtFrameUtils.java

Unmerged paths:
  (use "git add <file>..." to mark resolution)
	both modified:   fe/fe-core/src/main/java/com/starrocks/authentication/AuthenticationMgr.java
	both modified:   fe/fe-core/src/main/java/com/starrocks/http/meta/MetaService.java
	both modified:   fe/fe-core/src/main/java/com/starrocks/leader/Checkpoint.java
	both modified:   fe/fe-core/src/main/java/com/starrocks/server/LocalMetastore.java

To fix up this pull request, you can check it out locally. See documentation: https://docs.github.com/en/pull-requests/collaborating-with-pull-requests/reviewing-changes-in-pull-requests/checking-out-pull-requests-locally

Copy link
Contributor Author

mergify bot commented Aug 16, 2024

@mergify[bot]: Backport conflict, please reslove the conflict and resubmit the pr

@mergify mergify bot deleted the mergify/bp/branch-3.3/pr-48569 branch August 16, 2024 06:09
@gengjun-git gengjun-git restored the mergify/bp/branch-3.3/pr-48569 branch August 19, 2024 02:49
Signed-off-by: gengjun-git <[email protected]>
@gengjun-git gengjun-git reopened this Aug 19, 2024
@wanpengfei-git wanpengfei-git enabled auto-merge (squash) August 19, 2024 06:27
Copy link

sonarcloud bot commented Aug 19, 2024

@wanpengfei-git wanpengfei-git merged commit 21bec5c into branch-3.3 Aug 19, 2024
43 of 44 checks passed
@wanpengfei-git wanpengfei-git deleted the mergify/bp/branch-3.3/pr-48569 branch August 19, 2024 07:11
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants