Skip to content

Mason v0.23.4

Latest

Choose a tag to compare

@github-actions github-actions released this 20 Nov 00:23
· 21 commits to main since this release
7c21318

A group by a time's month or day is faster on a large table in UTC, and so is a group by over a join with a smaller
table. A sync asked by hand shows how far it is, and a date or time unit answers the same under each of its
spellings.
A project pinned to 0.23.3, 0.23.2, 0.23.1 or 0.23.0 runs on 0.23.4 as it is, and no table is read again
("Before you upgrade").

Before you upgrade

  • No table is read again. To see this for your own project, run npx @mason-data/cli@0.23.4 upgrade --check in
    the project's folder while Mason 0.23.3 runs. It lists each table the first start reads again, and changes nothing.
  • The pin needs no change. Before 1.0 the command and the image run a project pinned to their own minor version,
    at their own patch or an older one, so 0.23.4 runs a project pinned version: 0.23.3, 0.23.2, 0.23.1 or
    0.23.0. Moving it to version: 0.23.4 in mason/mason.yml is optional. Once you do, an older 0.23 command or image
    refuses the project, so move it only once everyone and everything that runs the project has 0.23.4. A project
    mason init makes on 0.23.4 is pinned 0.23.4.
  • On Mason Cloud, upgrade the replica first, then move the pin. mason replica upgrade <org>/<name> moves the
    replica to 0.23.4. Mason on the replica restarts, and its connections drop. It goes on running your project pinned
    to an older 0.23 as it is.
  • A few queries that 0.23.3 answered are now refused, with Postgres's own error. Postgres refuses them too: each
    asks for a unit that the function or the type does not have. Examples are date_trunc('dow', t) and
    date_trunc('weeks', i) of an interval. 0.23.3 answered them with values Postgres never gives. If such a query
    fails on Postgres, it now fails on Mason too, with the same SQLSTATE and message ("What was wrong and is now right").
  • A division written as text in a grouped query can now fail. Take a query that groups by a numeric column of no
    precision and writes a division of it with concat, format, ||, to_json or json_build_object, such as
    SELECT amount, concat(amount / 3) FROM t GROUP BY amount. It now fails with SQLSTATE 42803. 0.23.3 answered it,
    with the double's digits. Write the division as (amount / 3)::text instead, which gives Postgres's answer.
  • A Julian day of an infinite date is now refused. extract(jd FROM d) answered NULL for an infinite date in
    0.23.3, where Postgres answers Infinity. Now the query is refused by name (infinite-extract), under every spelling
    of the unit. To answer it, filter the infinite values out first: WHERE isfinite(d).
  • A variable whose name begins MASON_UI_TITLE now stops the start, unless it is MASON_UI_TITLE_FILE. 0.23.3
    ignored one, such as MASON_UI_TITLE. Remove it, or rename it to MASON_UI_TITLE_FILE to set the label of
    mason serve's page ("What changes").
  • The box at the top of the web page no longer names the sources file. It shows the database's name alone, or a
    label you choose with MASON_UI_TITLE_FILE ("What changes"). mason status still names the sources file.

What changes

  • In UTC, a group by a time's hour, day, week, month, quarter or year is faster on a large table. Mason already
    grouped such a query by a stored 15-minute number in other time zones. Now it does so in UTC too, for a table of
    10 M rows or more. The answers are the same. On 30 M orders over two years:
    • Revenue by month, joined to customers, went from 226 ms to 166 ms, and from 1.8 to 1.4 CPU-seconds.
    • Orders by month went from 78 ms to 44 ms, and by day from 63 ms to 44 ms.
    • With ten clients at once, revenue by month went from 2.3 s to 1.8 s, and orders by month from 0.80 s to 0.39 s.
    • A table of fewer rows keeps the plan it had. At 6 M rows that plan is about as fast, and below that it is faster.
      Mason counts a table's rows when it syncs it.
  • A group by over a join can work out a smaller table's value once for each of its rows. In revenue by order month
    and customer signup year, the signup year was worked out once for each order. Now it is worked out once for each
    customer, before the join. On 50 M orders and 2.5 M customers, that query went from 660 ms to 283 ms in
    Asia/Kathmandu, and from 383 ms to 331 ms in UTC. The answers are the same.
    • It applies when the smaller table holds at most half the rows of the largest other table in the join, by the rows
      Mason synced. Every table in the join must be a synced table. No filter may limit the other tables. A filter on
      the smaller table itself is fine.
    • It applies only to a value that reads the smaller table alone, can never fail, and is not random. Examples are a
      time cut to its month, year or other unit (date_trunc), a time's date (::date), date_part() of a time's
      month, quarter, week, day, hour, minute or day of the week, a number compared with a constant, IS NULL, IN a
      list of constants, and a CASE or COALESCE of these with plain number or text constants.
    • lower() of a text applies too, but only under a libc collation other than C, such as en_US.UTF-8.
    • On the side of an outer join that can have no matching row, the value must be NULL where its columns are. So a
      COALESCE there is worked out after the join.
    • Anything else is worked out after the join, as before. That includes upper() under every collation, lower()
      under any other collation, extract(), and arithmetic on a number. It includes date_part() of a year or a longer
      unit, an epoch, a Julian day, a second or a millisecond, and of a date's hour or a smaller unit.
  • The box at the top of the web page shows the database's name alone, or a label you choose. It used to add
    · source <name> after the database. The box was too narrow to show that part, so it is gone. mason status still
    names the sources file.
    • mason serve takes a new setting, MASON_UI_TITLE_FILE. It names a file whose first line is shown in the box
      instead. Use it to tell your deployments apart, such as "Production analytics (EU)".
    • Everyone who opens the page sees the label, so put nothing in it that a user of the page should not read.
    • Mason reads the file again each time the page loads, so an edit shows with no restart.
    • It is shown as plain text. Mason reads at most the first 1024 bytes, takes the first line, makes each control
      character a space, drops invisible ones, and cuts it to 80 characters.
    • If the file is missing or can't be read, the box shows the database, and mason status says why.
    • mason start refuses the setting, as it does the other web page settings of mason serve. A variable whose name
      begins MASON_UI_TITLE but is not this setting, such as MASON_UI_TITLE, stops the start too, and names the right
      one.
  • Mason's MCP server now tells a client its icon, a sentence of what it is and its website. mason mcp and
    mason serve's MCP endpoint send Mason's logo in their serverInfo, so a client that shows server icons shows
    Mason's. A deployment with its own brand sets MASON_MCP_ICON, beside MASON_MCP_URL: a PNG as a data: URL in
    base64, or an https:// address on MASON_MCP_URL's own origin. It takes no SVG, which can carry script: give a
    PNG. Any other value refuses the start. Not every client reads the icon yet. Users report that claude.ai's custom
    connectors show the favicon of the endpoint's domain instead. That favicon is set by the site in front of the
    endpoint.

What was wrong and is now right

  • Mason could say a new table was synced a moment before a query could read it. After a table was added to a
    running Mason, /healthz, mason wait and mason status could count it as synced while a query of it still failed
    with relation does not exist. A client or a platform that queried as soon as Mason said the table was ready could
    meet that error. Now a table counts as synced only once a query can read it.
  • A sync asked by hand showed a full bar at 100% for as long as it ran. After Sync now or mason sync, the Tables
    page said Syncing beside the table's bar from its last sync, full, with nothing moving, for the minutes a big table
    takes. Now the page and mason status say how far that sync is: the changed rows read so far, counted as they
    arrive, and the time since it began; then writing them, counting the table's rows on the database, and, when rows
    were deleted there, how many of the table's keys are read to find them. A bar is shown only against a total Mason
    knows: the keys, against the row count the sync already reads. The changed rows have no total, so there is no bar
    while they are read. mason status --json and /api/state carry it as tables[].syncProgress. Nothing more is
    asked of your database for it.
  • A date or time unit could answer differently under another of its spellings. Postgres reads a unit by any of
    its spellings. For example, second, seconds, sec, secs and s are one unit. Mason now reads every spelling
    Postgres reads, in date_part(), extract() and date_trunc(), and answers as for the unit's usual name. These
    answered wrong before:
    • date_part('seconds', t), 'sec' and 's' dropped the fraction of a second: 59 where Postgres answers
      59.999999. date_part('ms', t) and the other spellings of a millisecond dropped it too. So did extract().
    • date_part('y', t) of an infinite time was NULL where Postgres answers Infinity. The same held for other
      spellings of a year, a decade, a century and a millennium.
    • date_part('hour', d) of a date was refused, where Postgres answers 0. So were a minute, a second, a millisecond
      and a microsecond.
    • extract(h FROM d) of a date answered 0, where Postgres refuses it.
    • date_trunc('dow', t) and date_trunc('weeks', i) of an interval answered, where Postgres refuses them.
    • Spellings such as qtr, mm, timezone_h and extract('dec' FROM t) were refused, where Postgres
      answers. Each spelling Postgres does not take is refused with Postgres's own error.
  • extract(julian FROM …) was refused. Its spelling jd answered of a date, but a filter on it dropped an
    infinite date that Postgres keeps. Now it answers under every spelling, with Postgres's digits: a whole number of a
    date, and of a timestamp the same digits Postgres gives each row. Of an infinite date or timestamp it is refused by
    name, as extract(year FROM d) is.
  • extract(epoch FROM t) of a time with time zone now counts its offset, as Postgres does. Before, it gave the
    time of day alone, so 12:00:00-05 answered 43200 where Postgres answers 61200. date_part('epoch', t) was wrong
    the same way. date_part() of a time with time zone was refused, and is now answered.
  • A numeric division or average written as text by concat, format, ||, to_json or json_build_object now
    has Postgres's digits.
    Before, concat(amount / 3) wrote the nearest double, such as 333.3333333333333 where
    Postgres writes 333.3333333333333333. A cast to text, such as (amount / 3)::text, was already right.
    • One case now fails instead: a query that groups by a numeric column of no precision, and writes a division of
      that column as text this way. SELECT amount, concat(amount / 3) FROM t GROUP BY amount fails with SQLSTATE
      42803, where 0.23.3 wrote the double's digits. A cast to text answers it right: (amount / 3)::text.