Skip to content

Fix max key size using client sizes instead of server sizes#5888

Open
chands10 wants to merge 1 commit intobloomberg:mainfrom
chands10:keysize
Open

Fix max key size using client sizes instead of server sizes#5888
chands10 wants to merge 1 commit intobloomberg:mainfrom
chands10:keysize

Conversation

@chands10
Copy link
Copy Markdown
Contributor

Max key size was based on client sizes for some types, not server.

Max key size is defined as 512, but internally really 513 so we can have a key on byte(512) (+1 for null byte).

Don't allow cstring 513 though, even though this takes up 513 - 1 + 1 = 513 bytes. Subtract one because we don't store '\0' on disk.

Comment thread csc2/macc_so.c
if (ck->expr) {
/* TODO: calculate correct on-disk size for expression index pieces. The current code does this (incorrectly) as
* well. */
return 1;
Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

This will be addressed in a separate pr. This is same as current behavior

Comment thread csc2/macc_so.c
/* For cstrings, artificially add 1 to the size. Since we strip the '\0' at the end when storing on disk, we could
* technically store a cstring of size 513 in a key. But that would be confusing to the client. */
if (sym->type == T_CSTR) {
++sz;
Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

don't allow cstring(513)

Comment thread csc2/macc_so.c Outdated
Comment thread db/macc_glue.c
}
for (ii = 0; ii < tbl->nix; ii++) {
tmpidxsz = dyns_get_idx_size(ii);
if (tmpidxsz < 1 || tmpidxsz > MAXKEYLEN) {
Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

tmpidxsz is not the correct key size

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Think this check is redundant

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Only use it if using old logic (still redundant even then)

Comment thread db/macc_glue.c
cleanup_newdb(tbl);
return NULL;
}
tbl->ix_keylen[ii] = tmpidxsz; /* ix lengths are adjusted later */
Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

ix lengths are adjusted later

Copy link
Copy Markdown

@roborivers roborivers left a comment

Choose a reason for hiding this comment

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

Cbuild submission: Success ✓.
Regression testing: Success ✓.

The first 10 failing tests are:
scindex [failed with core dumped]
sc_truncate [db unavailable at finish]
consumer_non_atomic_default_consumer_generated **quarantined**
longreq_stats
tunables

@chands10 chands10 marked this pull request as draft April 28, 2026 15:44
@chands10
Copy link
Copy Markdown
Contributor Author

Need to add tunable to revert to prev behavior if needed

Comment thread csc2/macc_so.c
int sz;
if (gbl_max_key_size_new)
sz = keyondisksize2(macc_globals->workkey) -
1; /* COMDB2 CURRENTLY SUPPORTS 512 byte KEYS (not including null byte) */
Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

keyondisk basically subtracts 1 inside its function. Subtract 1 on outside here to not include one null byte

@chands10 chands10 marked this pull request as ready for review April 29, 2026 20:16
Copy link
Copy Markdown

@roborivers roborivers left a comment

Choose a reason for hiding this comment

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

Cbuild submission: Success ✓.
Regression testing: Success ✓.

The first 10 failing tests are:
logfill [db unavailable at finish] **quarantined**
consumer_non_atomic_default_consumer_generated **quarantined**
remsql_locks_rte_connect_generated **quarantined**
remsql_locks **quarantined**
tunables
reco-ddlk-sql [timeout] **quarantined**

@chands10
Copy link
Copy Markdown
Contributor Author

cdb2test Apr 29 17:21:56 2026 success keysize.R20260429.9

Signed-off-by: Salil Chandra <schandra107@bloomberg.net>
@chands10
Copy link
Copy Markdown
Contributor Author

^^ update tunables test

Copy link
Copy Markdown

@roborivers roborivers left a comment

Choose a reason for hiding this comment

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

Cbuild submission: Success ✓.
Regression testing: Success ✓.

The first 10 failing tests are:
sc_resume_logicalsc_generated **quarantined**
reco-ddlk-sql **quarantined**
consumer_non_atomic_default_consumer_generated **quarantined**
remsql_locks_rte_connect_generated **quarantined**
remsql_locks **quarantined**
sc_downgrade [timeout] **quarantined**

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants