To keep the db logs small, I'm using the -m switch with dbsrv12. I checked the dbinit docs to no avail but is it somehow possible to specify this attribute on db creation? (This way I can forget all about it when starting the db..:)

asked 12 Sep '12, 12:07

henginy's gravatar image

henginy
406151827
accept rate: 0%


No, it is not possible.

You could consider defining a database event that will truncate the transaction log when it reaches a certain size. The sample below, taken from the documentation, limits the size of the transaction log to 10 MB.

CREATE EVENT LogLimit
TYPE GrowLog
WHERE event_condition( 'LogSize' ) > 10
HANDLER
BEGIN
  IF EVENT_PARAMETER( 'NumActive' ) = 1 THEN 
   BACKUP DATABASE
   DIRECTORY 'c:\\logs'
   TRANSACTION LOG ONLY
   TRANSACTION LOG RENAME MATCH;
  END IF;
END;
permanent link

answered 12 Sep '12, 12:58

Reg%20Domaratzki's gravatar image

Reg Domaratzki
5.4k33579
accept rate: 39%

edited 12 Sep '12, 13:00

1

The real advantage over using "dbeng -m" would be that this will create a backup of the log, so you are able to recover in case of a media failure (if the backup is not damaged, as well, obviously) - whereas with -m, you risk data loss.

(12 Sep '12, 16:13) Volker Barth
Replies hidden

Thank you, that will do it.

(14 Sep '12, 02:23) henginy

FWIW, if you do not need a backup at all and just want to truncate the log, use

BACKUP DATABASE DIRECTORY '' 
TRANSACTION LOG ONLY 
TRANSACTION LOG TRUNCATE;

in the above sample.

(Cf. my comment under Breck's anwer...)

(15 Sep '12, 07:39) Volker Barth

Sometimes recovery takes a back seat to administration and performance issues; e.g., when an embedded database is recreated on demand and used for transient data.

You might consider using a DatabaseStart event to confirm that the database was started with -m, and if not, take some action.

AFAIK there is no easy way to determine whether or not -m is in effect, but this code seems to work in Version 12:

SELECT IF PROPERTY ( 'CommandLine' ) LIKE '%-m%' 
          THEN 'Y'
          ELSE 'N'
       END IF AS truncate_log_on_checkpoint;

truncate_log_on_checkpoint
'Y'
permanent link

answered 12 Sep '12, 16:40

Breck%20Carter's gravatar image

Breck Carter
27.0k444614889
accept rate: 21%

...though it could mean any database was started with -m, not necessarily the current one, right?

(Yep, autostarting several embedded databases is rather uncommon, and I'm just splitting hairs:))

(12 Sep '12, 17:12) Volker Barth
Replies hidden
1

One other small caveat to such an approach would be that there are other (undocumented) server switches that also start with "-m", that you may be asked by Technical Support to start the server with for diagnostic purposes. You may want to consider scanning for the switch LIKE '%-m %' instead.

(13 Sep '12, 17:14) Jeff Albion
Replies hidden

Thank you all for the insight.

(14 Sep '12, 02:27) henginy

Since -m is a server option, not a database option, I assume -m applies to all databases named on the command line. However, I don't know what happens to a subsequent START DATABASE command that doesn't have the WITH TRUNCATE AT CHECKPOINT clause... does the command line -m apply to that database as well? I would put money on "yes" since that would obey the rule "Watcom does things the way they should be done.

(14 Sep '12, 09:00) Breck Carter
1

Yes indeed... plus, if one thought it possible to code -m at the end of a command line, the predicate should be extended to cover that case:

IF PROPERTY ( 'CommandLine' ) LIKE '%-m %' OR PROPERTY ( 'CommandLine' ) LIKE '%-m'

(14 Sep '12, 09:02) Breck Carter
Comment Text Removed
1

Many bugs are the result of unsplit hairs... splitting hairs is a job requirement :)

(14 Sep '12, 09:04) Breck Carter

FWIW, like "-n", "-m" does exist both as database server and as database option, so its meaning is influenced by its position on the command line...

(14 Sep '12, 09:23) Volker Barth

I live and learn... perhaps a more reliable (albeit brutish) solution would be to compare the transaction log file size before and after doing an explicit CHECKPOINT :)

(14 Sep '12, 15:25) Breck Carter

I guess the reliable solution is to get rid of "-m" and use a method to backup and truncate the transaction log, as Reg has suggested - at least Henginy seems to be content with that:)

Af if you really don't need to be able to recover, the following backup statement variant would just omit the backup, just truncate:

BACKUP DATABASE DIRECTORY '' 
TRANSACTION LOG ONLY 
TRANSACTION LOG TRUNCATE;

Apparently, that could be used in Reg's event sample, too.

(15 Sep '12, 07:37) Volker Barth
showing 3 of 9 show all flat view
Your answer
toggle preview

Follow this question

By Email:

Once you sign in you will be able to subscribe for any updates here

By RSS:

Answers

Answers and Comments

Markdown Basics

  • *italic* or _italic_
  • **bold** or __bold__
  • link:[text](http://url.com/ "title")
  • image?![alt text](/path/img.jpg "title")
  • numbered list: 1. Foo 2. Bar
  • to add a line break simply add two spaces to where you would like the new line to be.
  • basic HTML tags are also supported

Question tags:

×415
×34

question asked: 12 Sep '12, 12:07

question was seen: 8,993 times

last updated: 15 Sep '12, 07:39