github-actions[bot] commented on code in PR #64647:
URL: https://github.com/apache/doris/pull/64647#discussion_r3441137024


##########
cloud/src/meta-service/meta_service_txn.cpp:
##########
@@ -1853,7 +1853,11 @@ void MetaServiceImpl::commit_txn_immediately(
                 int64_t table_id = i.first;
                 std::string ver_key = table_version_key({instance_id, db_id, 
table_id});
                 std::string ver_val;
-                err = txn->get(ver_key, &ver_val);
+                // snapshot read: the returned table version is only a hint 
for FE's version
+                // cache; the real increment is done by update_table_version() 
via atomic_add.
+                // A non-snapshot read would add ver_key to the read-conflict 
set and make
+                // concurrent commits on the same table conflict 
(KV_TXN_CONFLICT).
+                err = txn->get(ver_key, &ver_val, true);

Review Comment:
   This snapshot read makes the response version come from a pre-commit value 
that is no longer protected by a read conflict. Two concurrent commits on the 
same table can both read table version N, both apply `update_table_version()` 
via `atomic_add`, and both return N+1 in `TableStatsPB`. FE uses that value as 
the table invalidation version (`CloudGlobalTransactionMgr.updateVersion` -> 
`OlapTable.setCachedTableVersion`), and SQL cache/MTMV/statistics consumers 
compare `OlapTable.getVisibleVersion()`. A query cache entry created after the 
first response at N+1 can therefore remain valid after the second response, 
because the table version does not change even though another commit became 
visible. Existing concurrent lazy-commit coverage also expects the two returned 
table versions to be distinct. Please preserve a unique monotonic response 
version per committed table update, or avoid updating FE caches from an 
advisory stale value and force a safe sync, while still addressing the KV 
 conflict.



-- 
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]

Reply via email to