msyavuz commented on code in PR #43583:
URL: https://github.com/apache/superset/pull/43583#discussion_r3882315459
##########
superset/datasets/api.py:
##########
@@ -626,6 +650,21 @@ def put(self, pk: int) -> Response:
# ``ENABLE_VERSIONING_CAPTURE`` is off).
old_info = current_entity_version_info(SqlaTable, pk)
+ try:
+ raise_for_stale_write(concurrency_token_from(old_info))
+ except StaleEntityError:
+ return set_version_etag(
+ self.response(
+ 412,
+ message=_(
+ "The dataset was changed by another user or browser
tab "
+ "after you opened it. Reopen it to pick up the latest "
+ "version, then reapply your changes."
+ ),
+ ),
+ concurrency_token_from(old_info),
+ )
+
Review Comment:
Fixed in d86ba69a98. The dataset row is now locked before the check, and
since `@transaction()` commits the same scoped session the command writes
through, the lock is held across check and write. Only a conditional save takes
it, so an unconditional PUT is unchanged, and SQLite renders no `FOR UPDATE`
(it serialises writers anyway).
##########
superset-frontend/src/components/Datasource/DatasourceModal/index.tsx:
##########
@@ -111,6 +113,23 @@ const DatasourceModal:
FunctionComponent<DatasourceModalProps> = ({
const [isEditing, setIsEditing] = useState<boolean>(false);
const [modal, contextHolder] = Modal.useModal();
const [confirmModalOpen, setConfirmModalOpen] = useState(false);
+
+ useEffect(() => {
+ setVersionEtag(etag);
+ if (etag || !show || !datasource.id) {
+ return;
+ }
+ SupersetClient.get({
+ endpoint: `/api/v1/dataset/${datasource.id}`,
+ })
+ .then(({ response }) => {
+ setVersionEtag(response.headers.get('ETag') ?? undefined);
Review Comment:
Fixed in d86ba69a98 — and it was worse than the timing window: the form was
seeded from the caller's snapshot but the validator from a later read, so even
a well-timed save could guard a stale payload. The modal now seeds both from
the same read and keeps the editor and Save unavailable until it lands.
One correction: `ChangeDatasourceModal` is the datasource picker and never
renders `DatasourceModal` (it only imports its types), so Explore's
`DatasourceControl` was the one affected path.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]