Menu

Putting a time limit on batch writes in a PL/SQL API
📰

Putting a time limit on batch writes in a PL/SQL API

DEV Community: java·Darkø Tasevski·about 18 hours ago
#QIJoKGQH
#devtojava#devto#dev#stop#every
Long article (1510 words) — no AI summary yet.
Reading 0:00
15s threshold

This post is about giving a write request a time limit in an API that lives mostly in Oracle PL/SQL, where one request can create, update, upsert or delete a whole list of objects, and the layer in front of it wanted to be able to say "you have this many seconds, then stop". For a read that's simple, you cancel the query and nothing changed, but for a write it isn't, because by the time the limit passes some objects are saved, one may be halfway through, and the rest never started, and the caller has to be able to tell which is which.

Most of the work went into two questions, where the deadline gets checked, and what happens to work that can't be cut in the middle when it passes.

One deadline, computed once

Every write already went through one entry procedure, so the limit comes in there as an optional number of seconds and gets turned into one absolute point in time right at the start, which is then passed down to every loop that does the writing:

if p_limit_s is not null then l_stop_at := systimestamp…

Continue reading — create a free account

Join HashtagPLUS to read full articles, follow hashtags, vote, and join the conversation.