DAOS-18625 utils: interpret key based to object's type for ddb output#17617
DAOS-18625 utils: interpret key based to object's type for ddb output#17617
Conversation
|
Ticket title is 'Confused ddb ls ouput for integer keys' |
23588dd to
847df11
Compare
|
Test stage Functional on EL 8.8 completed with status FAILURE. https://jenkins-3.daos.hpc.amslabs.hpecorp.net//job/daos-stack/job/daos/view/change-requests/job/PR-17617/6/execution/node/1078/log |
847df11 to
2fe1617
Compare
|
Test stage NLT on EL 8.8 completed with status UNSTABLE. https://jenkins-3.daos.hpc.amslabs.hpecorp.net/job/daos-stack/job/daos//view/change-requests/job/PR-17617/8/testReport/ |
2fe1617 to
7e0a598
Compare
Current ddb logic may print some integer keys' output as not-readable,
for example dkey 10, 60 will be printed as following:
DKEY: (/[4]/[2]/[0]) /b2b37b1a-2894-4970-b51c-1a964526bb02/948289433254841843.256.535.2/ {8}
DKEY: (/[4]/[2]/[2]) /b2b37b1a-2894-4970-b51c-1a964526bb02/948289433254841843.256.535.2/<{8}
That is very confused. The patch defines new ddb_key_to_printable_buf()
interface that will interpret key based to object's type and generate
more readable ddb output.
Test-tag: recovery
Signed-off-by: Xuezhao Liu <xuezhao.liu@hpe.com>
Signed-off-by: Fan Yong <fan.yong@hpe.com>
7e0a598 to
4c0e467
Compare
|
Test stage Functional Hardware Large MD on SSD completed with status FAILURE. https://jenkins-3.daos.hpc.amslabs.hpecorp.net//job/daos-stack/job/daos/view/change-requests/job/PR-17617/9/execution/node/1352/log |
|
looks better to backport to 2.6 when convenient, thx |
Yes, the patch for release/2.6 is #17618. |
knard38
left a comment
There was a problem hiding this comment.
I am probably missing something, but do not see new tests checking print improvements of this PR.
src/utils/ddb/ddb_tree_path.c
Outdated
| d_iov_t *key_iov = &key_part->itp_key; | ||
| itp_print_part_key(struct ddb_ctx *ctx, struct indexed_tree_path_part *part) | ||
| { | ||
| char buf[DDB_MAX_PRITABLE_KEY]; |
There was a problem hiding this comment.
NIT
| char buf[DDB_MAX_PRITABLE_KEY]; | |
| char buf[DDB_MAX_PRINTABLE_KEY]; |
There was a problem hiding this comment.
OK, it was typo in original implementation. I will fix it.
src/utils/ddb/ddb_tree_path.c
Outdated
|
|
||
| len = ddb_key_to_printable_buf(key_iov, part->itp_otype, buf, ARRAY_SIZE(buf)); | ||
| if (len > ARRAY_SIZE(buf)) { | ||
| len += 2; /* +2 for escape character if needed and null terminator. */ |
There was a problem hiding this comment.
Not sure to fully understand this +2: I am probably missing something.
From my understanding, escape character need 2 printable characters.
Do not see why we could only have one escape character.
If I am true, then +2 should be evaluated according to the number of escape characters.
There was a problem hiding this comment.
You are right, +2 is for the escape character.
| (!ddb_key_is_int(part->itp_otype) && ddb_can_print(key_iov))) { | ||
| /* +1 to make sure there's room for a null terminator */ | ||
| char key_str[key_part->itp_key.iov_len + 1]; | ||
| char key_str[key_iov->iov_len + 1]; |
There was a problem hiding this comment.
Are we sure that this size will stay reasonable to allocate key_str on the stack ?
There was a problem hiding this comment.
Generally, we should dynamically allocate the buffer instead of static on stack. Current patch just reused original implementation. I will refresh it.
There was a problem hiding this comment.
Did you plan to keep this stack allocation or change it to heap allocation as indicated in your comments ?
From my side, no real issue to keep on the stack if we are sure that it will always be reasonable.
src/utils/ddb/ddb_tree_path.c
Outdated
| uint32_t len; | ||
|
|
||
| len = ddb_key_to_printable_buf(key_iov, part->itp_otype, buf, ARRAY_SIZE(buf)); | ||
| if (len > ARRAY_SIZE(buf)) { |
There was a problem hiding this comment.
Why the following +2 should not take into account into this test ?
| if (len > ARRAY_SIZE(buf)) { | |
| if (len + 2 > ARRAY_SIZE(buf)) { |
There was a problem hiding this comment.
Because else len = ARRAY_SIZE(buf);
There was a problem hiding this comment.
if len == ARRAY_SIZE(but) and if we have some escape characters then buf will not have enough space from the comment at line 838 ?
Added new test case in check If without the patch, the out will be something like: Please note the invisible output ' ' before |
Test-tag: recovery Signed-off-by: Fan Yong <fan.yong@hpe.com>
|
Test stage Functional Hardware Medium Verbs Provider MD on SSD completed with status FAILURE. https://jenkins-3.daos.hpc.amslabs.hpecorp.net//job/daos-stack/job/daos/view/change-requests/job/PR-17617/11/execution/node/1311/log |
|
CR leader switch cased CR test failure, not related with the ddb patch, to be retested. |
src/utils/ddb/ddb_tree_path.c
Outdated
| if (!itp_key_safe_str(buf, ARRAY_SIZE(buf))) { | ||
| if (!itp_key_safe_str(ptr, len)) { | ||
| ddb_print(ctx, "(ISSUE PRINTING KEY)"); | ||
| D_FREE(key_str); |
There was a problem hiding this comment.
Should free ptr if needed:
if (ptr != buf)
D_FREE(ptr);
There was a problem hiding this comment.
Right. I will fix it. Thanks!
Test-tag: recovery Signed-off-by: Fan Yong <fan.yong@hpe.com>
src/utils/ddb/ddb_tree_path.c
Outdated
| uint32_t len; | ||
|
|
||
| len = ddb_key_to_printable_buf(key_iov, part->itp_otype, buf, ARRAY_SIZE(buf)); | ||
| if (len > ARRAY_SIZE(buf)) { |
There was a problem hiding this comment.
Should it be ?
| if (len > ARRAY_SIZE(buf)) { | |
| if (len >= ARRAY_SIZE(buf)) { |
There was a problem hiding this comment.
The logic is stale. I will refresh the patch soon.
Test-tag: recovery Signed-off-by: Fan Yong <fan.yong@hpe.com>
|
|
||
| ddb_iov_to_printable_buf(key_iov, buf, ARRAY_SIZE(buf)); | ||
| if (ddb_can_print(key_iov)) { | ||
| ddb_key_to_printable_buf(key_iov, part->itp_otype, buf, ARRAY_SIZE(buf)); |
There was a problem hiding this comment.
Should we check if the value return is greater or equal than ARRAY_SIZE(buf).
If yes, maybe we should print a truncation warning message from my understanding.
There was a problem hiding this comment.
If the buffer is not large enough to hold the key, it will be automatically truncated with '\0' terminated. The macro DDB_MAX_PRINTABLE_KEY is for case of very long key string.
We can add warning in ddb_key_to_printable_buf() for the key that is longer than DDB_MAX_PRINTABLE_KEY. Since such case (key length > 1024) is very rare and RC1 branch-time is coming soon, I prefer to do that in subsequent patch.
How do you think? @knard38
Current ddb logic may print some integer keys' output as not-readable, for example dkey 10, 60 will be printed as following: DKEY: (/[4]/[2]/[0]) /b2b37b1a-2894-4970-b51c-1a964526bb02/948289433254841843.256.535.2/ {8} DKEY: (/[4]/[2]/[2]) /b2b37b1a-2894-4970-b51c-1a964526bb02/948289433254841843.256.535.2/<{8}
That is very confused. The patch defines new ddb_key_to_printable_buf() interface that will interpret key based to object's type and generate more readable ddb output.
Test-tag: recovery
Steps for the author:
After all prior steps are complete: