GGT_DATABASE_OPERATION_TIMEOUT: One operation in the backend database took too long to execute

Hi all, I'm seeing a lot of errors like this on my app. What could be the cause? Example trace id: 8966ac30681066556164bd007c3f98ea
8 Replies
RenanVSouza
RenanVSouzaOP•7mo ago
Some help here? 😅
Unknown User
Unknown User•7mo ago
Message Not Public
Sign In & Join Server To View
Chocci_Milk
Chocci_Milk•7mo ago
Hello, Are you possibly running a lot of code in the transactions (run functions) of nested records? Lets say you have a logic in the productVariant create/update run function and there are lots of productVariants. That can cause a timeout to occur. I haven't had a chance to look more into this yet as I'm jut jumping on this. Thought I'd give you somethig to think about while I dig a little
RenanVSouza
RenanVSouzaOP•7mo ago
Hi @Chocci_Milk, just coming back to this The errors seems to be coming from the product/update webhook handlers. I'm not running any heavy code inside the run action, the only code running on product update is a side effect that runs on the onSuccess method of the product/update action:
// shopifyProduct/actions/update
export async function onSuccess({ params, record, logger, api, trigger }) {
if (trigger.type === 'shopify_webhook') {
void api.shopifyProduct.updateMediaStatus(record.id);
}
}
// shopifyProduct/actions/update
export async function onSuccess({ params, record, logger, api, trigger }) {
if (trigger.type === 'shopify_webhook') {
void api.shopifyProduct.updateMediaStatus(record.id);
}
}
On the updateMediaStatus action I'm actually making an api call inside the run method, but is that enough to cause a timeout?
// shopifyProduct/actions/updateMediaStatus
export const run = async ({ params, record, logger, api, connections }) => {
applyParams(params, record);
await preventCrossShopDataAccess(params, record);

const product = await api.shopifyProduct.findOne(record.id, {
select: { mediaStatus: true },
});

const { totalMedia, totalMediaWithoutAlt } = product.mediaStatus;

let altTextOnImages = null;
if (totalMedia > 0) {
if (totalMediaWithoutAlt === 0) {
altTextOnImages = 'all';
} else if (totalMedia === totalMediaWithoutAlt) {
altTextOnImages = 'none';
} else {
altTextOnImages = 'some';
}
} else {
altTextOnImages = 'no-images';
}

if (record.altTextOnImages === altTextOnImages) {
return;
}

record.altTextOnImages = altTextOnImages;

await save(record);
};
// shopifyProduct/actions/updateMediaStatus
export const run = async ({ params, record, logger, api, connections }) => {
applyParams(params, record);
await preventCrossShopDataAccess(params, record);

const product = await api.shopifyProduct.findOne(record.id, {
select: { mediaStatus: true },
});

const { totalMedia, totalMediaWithoutAlt } = product.mediaStatus;

let altTextOnImages = null;
if (totalMedia > 0) {
if (totalMediaWithoutAlt === 0) {
altTextOnImages = 'all';
} else if (totalMedia === totalMediaWithoutAlt) {
altTextOnImages = 'none';
} else {
altTextOnImages = 'some';
}
} else {
altTextOnImages = 'no-images';
}

if (record.altTextOnImages === altTextOnImages) {
return;
}

record.altTextOnImages = altTextOnImages;

await save(record);
};
Chocci_Milk
Chocci_Milk•7mo ago
Side note: What does updateMediaStatus do? Does it simply update a field on the current record? If so, why aren't you using record.mediaStatus = something in the run function Btw, are you still seeing these timeouts? Also, why are you fetching the same product while in the run function? Why aren't you using record.mediaStatus? I don't think thats enough to cause db timeouts though
RenanVSouza
RenanVSouzaOP•7mo ago
@Chocci_Milk Yes, still seeing them. The reason for the fetch is because mediaStatus is a computed field, so I don't have direct access to it through the record object Hi guys, any insight about this? I'm still seeing those errors
Chocci_Milk
Chocci_Milk•7mo ago
Hello, I've been swamped with work and haven't yet had any time to look into this. Rest assured that I didn't forget about you I just did a quick check on the trace and will be asking some questions to the infra team. At first glance it looks like an issue on our end but I need more information to determine for sure Ok, we've made some changes to your tables. Can you keep an eye for more timeouts? It should be faster now
RenanVSouza
RenanVSouzaOP•7mo ago
Will do. Thank you!

Did you find this page helpful?