[OPIK-5437] [BE] fix: correct agent configuration version ordering#6071
Conversation
Backend Tests - Integration Group 15273 tests +31 273 ✅ +31 4m 46s ⏱️ -4s Results for commit f9f1b26. ± Comparison against base commit d295a1e. This pull request removes 33 and adds 64 tests. Note that renamed tests count towards both.♻️ This comment has been updated with latest results. |
Backend Tests - Integration Group 16 15 files ± 0 15 suites ±0 5m 19s ⏱️ -8s Results for commit ad55d86. ± Comparison against base commit d295a1e. This pull request removes 21 and adds 23 tests. Note that renamed tests count towards both.♻️ This comment has been updated with latest results. |
LifeXplorer
left a comment
There was a problem hiding this comment.
The sorting change is functionally a no-op. This project enforces UUIDv7 exclusively, and UUIDv7 is designed so that lexicographic UUID ordering equals chronological ordering — the timestamp occupies the top 48 bits.
Since blueprint IDs are generated via idGenerator.generateId() right before insert, ORDER BY id DESC and ORDER BY created_at DESC produce identical results.
If there's a real ordering bug, the root cause is likely elsewhere. This change isn't harmful, but it may mask the actual issue — and could be slightly worse for performance if created_at isn't indexed while id (PK) is.
andrescrz
left a comment
There was a problem hiding this comment.
Please review open comments before moving forward.
|
@andrescrz @LifeXplorer As we discussed this is not generally a valid use case, as blueprints/configurations are not supposed to be used like this and SDK should be mindful about ordering and generally waits for blueprint creation completion before creating next one. This was discovered during tests when script used more low level SDK functionality. It shouldn't be used like this by actual users. When we tried to reproduce with normal scenario it never happened. Regarding performance it should be ok, even we don't have index for |
Details
Agent configuration version numbers were not displayed in the correct order because blueprint history was sorted by
id(UUID) instead ofcreated_attimestamp. This change fixes the ordering and also makes the distributed lock duration for blueprint create/update operations configurable viaAgentConfigConfiguration.ORDER BY b.id DESCtoORDER BY b.created_at DESCin blueprint history queryblueprintLockDuration(default 5000ms) usingexecuteWithLockCustomExpireAgentConfigConfigurationclass and wired it through Dropwizard/Guice configChange checklist
Issues
AI-WATERMARK
AI-WATERMARK: yes
Testing
created_atinstead of UUID-basedidmvn compile -DskipTestsDocumentation
N/A