-
Notifications
You must be signed in to change notification settings - Fork 8.9k
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
[LEDGER] replace Metadata in query API with Limit and Bookmark #1024
[LEDGER] replace Metadata in query API with Limit and Bookmark #1024
Conversation
cf629fe
to
d347d13
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
-
I certainly find using "Options" instead of "Metadata" more meaningful but inconsistent naming causes more confusion. I would prefer to apply this change to this function
ExecuteQueryWithMetadata
as well. -
Moving a tiny piece of code to internal package because it is used in two packages is not that useful - particularly, when you have a similar function for rich queries still sitting
statecouchdb
package. I find keeping the related code as close as possible more useful.
wdyt?
What do you think? |
d347d13
to
a706c6e
Compare
a706c6e
to
f15dd85
Compare
a47974a
to
ebc508d
Compare
@Mergifyio rebase |
@cendhu is not allowed to run commands |
ebc508d
to
5ef925b
Compare
I would prefer we simply change "WithMetadata" to "WithPagination" or "WithOptions". I think that would be more expressive, cleaner, and a smaller change, than saying things like "WithBookmarkAndLimit". What if a database has 10 query options, you wouldn't want the API itself to mention all 10 of the query options. |
core/ledger/kvledger/txmgmt/statedb/statecouchdb/statecouchdb.go
Outdated
Show resolved
Hide resolved
core/ledger/kvledger/txmgmt/statedb/statecouchdb/statecouchdb.go
Outdated
Show resolved
Hide resolved
I can use |
4378fa4
to
2111832
Compare
2111832
to
b7d546b
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
A few comment, mainly on the chaincode side.
core/ledger/kvledger/txmgmt/statedb/stateleveldb/stateleveldb.go
Outdated
Show resolved
Hide resolved
@denyeart, @cendhu - IMO, there is no need to have two variations for the queries. Simply the basic APIs (i.e., neither |
@manish-sethi Valid point. I agree with you. I have created a separate JIRA FAB-17754 to address this once we decide on the following. To define and import |
@btl5037 2 second wait time for CouchDB index creation does not seem to help 😞 We might need to increase the wait time a bit. I hit the flakes twice in this PR. |
Yea. We hit it in 3 other PRs today as well :( |
@btl5037 Do we use SSD or HDD? These tests run in parallel right? If it is SSD, 2 seconds should be adequate and surprising why it fails. If it is HDD, we need to increase the time. Btw, what is the allocated #vCPUs? The CouchDB also consumes 3x higher CPU than GoLevelDB. Even with SSD, if we have allocated lower #vCPUs and run tests in parallel, I am sure that 2 seconds is not adequate. |
2vCPU and 4GB running on SSD |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM. A couple nit-picking comments though, that you may fix when resolving conflicts.
// Get the internalQueryLimit from core.yaml | ||
// pageSize limits the number of results returned | ||
func (vdb *VersionedDB) GetStateRangeScanIteratorWithPagination(namespace string, startKey string, endKey string, pageSize int32) (statedb.QueryResultsIterator, error) { | ||
logger.Debugf("Entering GetStateRangeScanIteratorWithOptions namespace: %s startKey: %s endKey: %s options: %d", namespace, startKey, endKey, pageSize) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
out of sync with new function name and parameter names
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done.
logger.Debugf("Entering ExecuteQueryWithMetadata namespace: %s, query: %s, metadata: %v", namespace, query, metadata) | ||
// ExecuteQueryWithPagination implements method in VersionedDB interface | ||
func (vdb *VersionedDB) ExecuteQueryWithPagination(namespace, query, bookmark string, pageSize int32) (statedb.QueryResultsIterator, error) { | ||
logger.Debugf("Entering ExecuteQueryWithMetadata namespace: %s, query: %s, metadata: %d", namespace, query, pageSize) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
out of sync with new function name and parameter names
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done.
The range query receives metadata such as pagination limit. The execute query at couchdb receives metadata such as the pagination bookmark and pagination limit. ValidateRangeMetadata() and ValidateQueryMetadata() validate the received metadata. However, the term metadata is confusing with the statemetadata which stores the key-based endorsement. Hence, we replace Metadata in range and execute query API with Pagination. As we have removed the metadata map, we also removed ValidateRangeMetadata() and ValidateQueryMetadata() as they are not needed anymore. Signed-off-by: senthil <cendhu@gmail.com>
756bd08
to
4d52a39
Compare
Type of change
Description
GetStateRangeScanIteratorWithMetadata()
at bothstateleveldb
andstatecouchdb
receive metadata such as pagination limit.ExecuteQueryWithMetadata()
atstatecouchdb
receives metadata such as the pagination bookmark and pagination limit.ValidateRangeMetadata()
andValidateQueryMetadata()
validate the received metadata for the respective query.However, the term
Metadata
is confusing with thestatemetadata
which stores the key-based endorsement. The APISetXXXMetadata()
andGetXXXMetadata()
are associated with the per state metadata. To avoid this confusion, we replaceMetadata
in range query and execute query API withPagination
to be explicit. As we have removed the metadata, we also removedValidateRangeMetadata()
andValidateQueryMetadata()
as they are not needed anymore.GetStateRangeScanIteratorWithMetadata()
->GetStateRangeScanIteratorWithPagination()
ExecuteQueryWithMetadata()
->ExecuteQueryWithPagination()
Related issues
FAB-17721