그래서 데이터 저장소에서 업데이트해야하는 값이 있습니다. 나는 아래와 같이 트랜잭션을 사용하고있다. 업데이트가 커밋 된 후에 클라이언트에 결과를 보내서 업데이트가 완료되었음을 알려줍니다. 그런 다음 클라이언트는 업데이트 된 항목 목록에 대한 다른 요청을 보냅니다. 내가 말할 수있는 한 모든 코드가 올바르게 실행되고 오류가 발생하지 않으며 결국 예상대로 업데이트 요청을 표시합니다.Google App Engine Datastore가 몇 초 전에 업데이트되기 전에 반환
내 문제는 커밋 후에도 가끔 때로는 반환 된 목록에 업데이트가 표시되는 데 몇 초 정도 걸립니다. 그것이 진절머리가 나는 연기 일 뿐이라면 그 이상입니다. 목록은이 기간 동안 올바르지 않거나 업데이트되지 않은 값을 반환합니다. 나는이 아키텍처에서 지연이있을 수 있음을 이해하지만 트랜잭션의 전체 지점은 트랜잭션이 원하는 항목을 가져 왔을 때 어떤 것이 업데이트 된 경우 이전 값을 읽을 수 없다고 생각했습니다. 오래되고 오랜 시간 동안 오래된 가치를 보지 못한 것은 잘못된 것 같습니다. 트랜잭션이 커밋되었다고 말할 때까지 기다리는 시간이 훨씬 줄어들고 전체 300ms + RTT를 가졌지 만 가정 된 후에도 몇 초 동안 여전히 나쁜 값을 얻게됩니다. 내가 여기서 무엇을 놓치고 있니?
/*
We don't actually delete a post, we simply replace it with a [removed]
version of itself.
*/
router.delete('/', function (req, res) {
//Check our parameters
if (req.body == null || req.body["Thread"] == null || typeof req.body["Thread"] !== "string") {
res.json({ success: false, message: "Thread name was not included as a parameter.", data: null});
return;
}
if (req.body == null || req.body["PostNumber"] == null) {
res.json({ success: false, message: "Post Number was not included as a parameter.", data: null });
return;
}
if ((parseInt(req.body["PostNumber"]) || 0) < 1) {
res.json({ success: false, message: "Post Number was not a valid numeric value.", data: null });
return;
}
var transaction = datastore.transaction();
transaction.get(datastore.key(['Post', PostName(req.body["Thread"], 6, parseInt(req.body["PostNumber"]))]), function (err, value) {
if (err)
{
res.json({ success: false, message: "Transaction failed.", data: null });
return;
}
if (value === null)
{
res.json({ success: false, message: "Post and thread combination does not exist.", data: null });
return;
}
value.data.CreatorName = "[removed]";
value.data.CreatorFooter = "";
value.data.Contents = "[removed]";
transaction.save(value);
transaction.commit(function (err) {
if (err)
{
res.json({ success: false, message: "Transaction failed.", data: null });
}
else
{
res.json({ success: true, message: "Erased post information from table", data: null });
}
});
});
});
당신이 그것을 극복하는 방법을 모른다면 그것은 매우 성가신 일입니다. 어쩌면이 문서들이 도움이 될지도 모른다. https://cloud.google.com/datastore/docs/articles/balancing-strong-and-eventual-consistency-with-google-cloud-datastore/ - https://dzone.com/articles/better-explaining-cap -정리 –