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

chore: TX management with entity manager #37646

Closed
wants to merge 42 commits into from
Closed
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
42 commits
Select commit Hold shift + click to select a range
a987818
chore: Working state
abhvsn Nov 20, 2024
ced4062
wip
abhvsn Nov 20, 2024
2092571
wip
abhvsn Nov 20, 2024
d1f4a42
wip
abhvsn Nov 20, 2024
fb7f072
wip
abhvsn Nov 20, 2024
21e2297
wip
abhvsn Nov 21, 2024
661442e
wip
abhvsn Nov 21, 2024
bbe83e4
wip
abhvsn Nov 22, 2024
76059a8
chore: Build is passing now
abhvsn Nov 22, 2024
71da8a2
Merge branch 'pg' of github.com:appsmithorg/appsmith into poc/tx-enti…
abhvsn Nov 22, 2024
1b8b3a0
chore: Add CRUDRepository extension
abhvsn Nov 22, 2024
8ae5fa1
now we are talking 🎉, we have a testcase passing with custom transaction
abhvsn Nov 26, 2024
ddeb58e
Multi repo test
abhvsn Nov 26, 2024
b41542c
chore: Fix tests with save op
abhvsn Nov 27, 2024
66de4c5
chore: Fix delete repo method
abhvsn Nov 27, 2024
1d49fab
chore: Merge pg and add entity manager in getDefaultTenant
abhvsn Nov 27, 2024
24495f7
chore: Handle cacheable repo methods
abhvsn Nov 27, 2024
aeaefdc
Merge branch 'pg' of github.com:appsmithorg/appsmith into poc/tx-enti…
abhvsn Nov 27, 2024
2cc9f0a
chore: Close entity manager in custom transaction
abhvsn Nov 27, 2024
668c121
chore: Fix conflicts
abhvsn Nov 28, 2024
58da953
Merge branch 'pg' of github.com:appsmithorg/appsmith into poc/tx-enti…
abhvsn Nov 29, 2024
9a1069f
chore: Create transactional operator
abhvsn Nov 29, 2024
cbd91c0
chore: Commit to show the illegal pop exception and move to transacti…
abhvsn Dec 2, 2024
9a10e35
fix: Add seperate scheduler for DB ops
abhvsn Dec 3, 2024
a0b18c0
feat: Effectively utilise the db and transaction threads
abhvsn Dec 3, 2024
ba9d0dd
fix: Tests
abhvsn Dec 5, 2024
0e53fb0
Merge branch 'pg' of github.com:appsmithorg/appsmith into poc/tx-enti…
abhvsn Dec 5, 2024
daa3fa4
chore: Persist entities for bulk ops
abhvsn Dec 5, 2024
e03c819
fix: Out of memory exception, add custom transactions on base cake class
abhvsn Dec 6, 2024
4958f96
Merge branch 'pg' of github.com:appsmithorg/appsmith into poc/tx-enti…
abhvsn Dec 6, 2024
7d37c51
chore: Merge pg and resolve conflicts
abhvsn Dec 11, 2024
db7d709
chore: Fix findAllById method
abhvsn Dec 11, 2024
4073ddc
fix: CommonGitTest for id modification error
abhvsn Dec 11, 2024
56add0e
fix: LayoutServiceTest to use single transaction
abhvsn Dec 11, 2024
3420456
fix: Forking test by fixing constraint violation exception in baseCak…
abhvsn Dec 11, 2024
67c74c8
fix: bulkUpdate and bulkInsert by using saveAll
abhvsn Dec 11, 2024
e7ad71e
fix: usage pulse test by adding transactional for updateById in user …
abhvsn Dec 11, 2024
99e6f8f
fix: data integrity exceptions by relying on message
abhvsn Dec 11, 2024
59c5c8e
fix: Serialise DB calls for user workspace service test (look into th…
abhvsn Dec 11, 2024
d017d0a
fix: Appsmith repository test by moving JPA methods to custom reposit…
abhvsn Dec 11, 2024
3acbe10
fix: NewActionRepositoryTest as we are using the saveAll instead of b…
abhvsn Dec 11, 2024
95ca387
Merge branch 'pg' of github.com:appsmithorg/appsmith into poc/tx-enti…
abhvsn Dec 26, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
fix: CommonGitTest for id modification error
  • Loading branch information
abhvsn committed Dec 11, 2024
commit 4073ddc50a7149e004d8c7fb6a96c765c1421fc0
Original file line number Diff line number Diff line change
Expand Up @@ -1321,12 +1321,10 @@ public Mono<? extends Artifact> checkoutBranch(
Mono<Tuple2<? extends Artifact, ? extends Artifact>> baseAndBranchedArtifactMono =
getBaseAndBranchedArtifacts(branchedArtifactId, artifactType);

return baseAndBranchedArtifactMono
.flatMap(artifactTuples -> {
Artifact sourceArtifact = artifactTuples.getT1();
return checkoutBranch(sourceArtifact, branchToBeCheckedOut, addFileLock);
})
.as(transactionalOperator::transactional);
return baseAndBranchedArtifactMono.flatMap(artifactTuples -> {
Artifact sourceArtifact = artifactTuples.getT1();
return checkoutBranch(sourceArtifact, branchToBeCheckedOut, addFileLock);
});
}

protected Mono<? extends Artifact> checkoutBranch(
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
package com.appsmith.server.repositories.ce;

import com.appsmith.server.domains.Application;
import com.appsmith.server.projections.IdOnly;
import com.appsmith.server.repositories.BaseRepository;
import com.appsmith.server.repositories.CustomApplicationRepository;
import org.springframework.stereotype.Repository;
Expand All @@ -12,19 +11,9 @@
@Repository
public interface ApplicationRepositoryCE extends BaseRepository<Application, String>, CustomApplicationRepository {

Optional<Application> findByName(String name);

List<Application> findByIdIn(List<String> ids);

List<Application> findByWorkspaceId(String workspaceId);

Optional<Long> countByWorkspaceId(String workspaceId);

List<IdOnly> findIdsByWorkspaceId(String workspaceId);

List<Application> findByClonedFromApplicationId(String clonedFromApplicationId);

Optional<Long> countByDeletedAtNull();

Optional<Application> findByIdAndExportWithConfiguration(String id, boolean exportWithConfiguration);
}
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
import com.appsmith.server.domains.Application;
import com.appsmith.server.domains.ApplicationPage;
import com.appsmith.server.domains.User;
import com.appsmith.server.projections.IdOnly;
import com.appsmith.server.repositories.AppsmithRepository;
import jakarta.persistence.EntityManager;

Expand Down Expand Up @@ -124,4 +125,11 @@ int protectBranchedApplications(

List<String> findAllBranchedApplicationIdsByBranchedApplicationId(
String branchedApplicationId, AclPermission permission, User currentUser, EntityManager entityManager);

List<Application> findByWorkspaceId(String workspaceId, EntityManager entityManager);

List<IdOnly> findIdsByWorkspaceId(String workspaceId, EntityManager entityManager);

Optional<Application> findByIdAndExportWithConfiguration(
String id, boolean exportWithConfiguration, EntityManager entityManager);
}
Original file line number Diff line number Diff line change
Expand Up @@ -417,4 +417,31 @@ public List<String> findAllBranchedApplicationIdsByBranchedApplicationId(
return List.of(application.getId());
}
}

@Override
public List<Application> findByWorkspaceId(String workspaceId, EntityManager entityManager) {
return queryBuilder()
.criteria(Bridge.equal(Application.Fields.workspaceId, workspaceId))
.entityManager(entityManager)
.all();
}

@Override
public List<IdOnly> findIdsByWorkspaceId(String workspaceId, EntityManager entityManager) {
return queryBuilder()
.criteria(Bridge.equal(Application.Fields.workspaceId, workspaceId))
.entityManager(entityManager)
.all(IdOnly.class);
}

@Override
public Optional<Application> findByIdAndExportWithConfiguration(
String id, boolean exportWithConfiguration, EntityManager entityManager) {
return queryBuilder()
.byId(id)
.criteria(Bridge.equal(
Application.Fields.exportWithConfiguration, String.valueOf(exportWithConfiguration)))
.entityManager(entityManager)
.one();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
import jakarta.persistence.EntityManager;
import org.springframework.data.domain.Sort;

import java.util.Collection;
import java.util.List;
import java.util.Optional;
import java.util.Set;
Expand Down Expand Up @@ -145,4 +146,8 @@ List<NewAction> findAllPublishedActionsByContextIdAndContextType(

List<NewAction> findAllByApplicationIds(
List<String> branchedArtifactIds, List<String> includedFields, EntityManager entityManager);

List<NewAction> findByApplicationId(String applicationId, EntityManager entityManager);

List<NewAction> findAllByIdIn(Collection<String> ids, EntityManager entityManager);
}
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
import org.springframework.data.jpa.repository.Modifying;

import java.time.Instant;
import java.util.Collection;
import java.util.List;
import java.util.Optional;
import java.util.Set;
Expand Down Expand Up @@ -571,4 +572,20 @@ public List<NewAction> findAllByApplicationIds(
.entityManager(entityManager)
.all();
}

@Override
public List<NewAction> findByApplicationId(String applicationId, EntityManager entityManager) {
return queryBuilder()
.criteria(getCriterionForFindByApplicationId(applicationId))
.entityManager(entityManager)
.all();
}

@Override
public List<NewAction> findAllByIdIn(Collection<String> ids, EntityManager entityManager) {
return queryBuilder()
.criteria(Bridge.in(NewAction.Fields.id, ids))
.entityManager(entityManager)
.all();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -8,23 +8,16 @@
import com.appsmith.server.repositories.CustomNewActionRepository;
import org.springframework.data.jpa.repository.Query;

import java.util.Collection;
import java.util.List;
import java.util.Optional;

public interface NewActionRepositoryCE extends BaseRepository<NewAction, String>, CustomNewActionRepository {

@Query(value = "SELECT a FROM NewAction a WHERE a.applicationId = :applicationId AND a.deletedAt IS NULL")
List<NewAction> findByApplicationId(String applicationId);

List<NewAction> findAllByIdIn(Collection<String> ids);

Optional<Long> countByDeletedAtNull();

List<IdPoliciesOnly> findIdsAndPolicyMapByApplicationIdIn(List<String> applicationIds);

List<IdAndDatasourceIdNewActionView> findIdAndDatasourceIdByApplicationIdIn(List<String> applicationIds);

Optional<Long> countByDeletedAtNull();

@Query(
"""
SELECT new com.appsmith.server.dtos.PluginTypeAndCountDTO(a.pluginType, count(a)) as count
Expand Down
Loading