fix: Attempting fix of tenant deserialization error with forcing a serialUID to override the runtime value (#38836)

## Description
> [!TIP]  
> _Add a TL;DR when the description is longer than 500 words or
extremely technical (helps the content, marketing, and DevRel team)._
>
> _Please also include relevant motivation and context. List any
dependencies that are required for this change. Add links to Notion,
Figma or any other documents that might be relevant to the PR._


Fixes #`Issue Number`  
_or_  
Fixes `Issue URL`
> [!WARNING]  
> _If no issue exists, please create an issue first, and check with the
maintainers if the issue is valid._

## Automation

/test sanity

### 🔍 Cypress test results
<!-- This is an auto-generated comment: Cypress test results  -->
> [!TIP]
> 🟢 🟢 🟢 All cypress tests have passed! 🎉 🎉 🎉
> Workflow run:
<https://github.com/appsmithorg/appsmith/actions/runs/12947096482>
> Commit: 177e408c87c4a09920d599210c6f126955cd13e2
> <a
href="https://internal.appsmith.com/app/cypress-dashboard/rundetails-65890b3c81d7400d08fa9ee5?branch=master&workflowId=12947096482&attempt=1"
target="_blank">Cypress dashboard</a>.
> Tags: `@tag.Sanity`
> Spec:
> <hr>Fri, 24 Jan 2025 10:15:44 UTC
<!-- end of auto-generated comment: Cypress test results  -->


## Communication
Should the DevRel and Marketing teams inform users about this change?
- [ ] Yes
- [ ] No


<!-- This is an auto-generated comment: release notes by coderabbit.ai
-->

## Summary by CodeRabbit

- **Chores**
- Updated serialization version control for the Tenant class to ensure
proper object deserialization in multi-pod deployments.
- Modified tenant retrieval method in the tenant service implementation
to potentially improve caching mechanism.

<!-- end of auto-generated comment: release notes by coderabbit.ai -->
This commit is contained in:
Trisha Anand 2025-01-24 16:16:37 +05:30 committed by GitHub
parent be2133eda8
commit eb72ece5e8
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 14 additions and 6 deletions

View File

@ -10,6 +10,7 @@ import org.checkerframework.common.aliasing.qual.Unique;
import org.springframework.data.annotation.Transient;
import org.springframework.data.mongodb.core.mapping.Document;
import java.io.Serial;
import java.io.Serializable;
@Getter
@ -20,6 +21,11 @@ import java.io.Serializable;
@FieldNameConstants
public class Tenant extends BaseDomain implements Serializable {
// When changing tenant object, update the serialization version number to ensure that in a multi pod
// deployment, new pods only read the new tenant object and not the old one from redis cache.
@Serial
private static final long serialVersionUID = 1459916000401322518L;
@Unique String slug;
String displayName;

View File

@ -194,12 +194,14 @@ public class TenantServiceCEImpl extends BaseService<TenantRepository, Tenant, S
log.info("Evicting the default tenant from cache and fetching from the database!");
return cacheableRepositoryHelper
.evictCachedTenant(tenantId)
.then(repository.findBySlug(FieldName.DEFAULT).map(tenant -> {
if (tenant.getTenantConfiguration() == null) {
tenant.setTenantConfiguration(new TenantConfiguration());
}
return tenant;
}))
.then(cacheableRepositoryHelper
.fetchDefaultTenant(tenantId)
.map(tenant -> {
if (tenant.getTenantConfiguration() == null) {
tenant.setTenantConfiguration(new TenantConfiguration());
}
return tenant;
}))
.name(FETCH_TENANT_CACHE_POST_DESERIALIZATION_ERROR_SPAN)
.tap(Micrometer.observation(observationRegistry))
.flatMap(tenant -> repository