California’s government finances are riding the roller coaster again.

Buoyed by a soaring stock market and rising home prices, personal income tax receipts are flowing into the state treasury at a rate exceeding all expectations.

The result: a surplus of $6 billion or more is likely if Gov. Jerry Brown and the Legislature simply stay the course on spending and taxes for the next 18 months. And that’s after taking into account billions of dollars in higher spending on the schools that the state Constitution will require if tax revenues grow as now projected by the non-partisan Legislative Analyst’s office.

The fiscal outlook is also rosy for several years down the road, because a rising real estate market will likely mean higher local property tax revenue, and when that tax money goes to the schools, it offsets some of the state’s obligation to pay for kindergarten through community college education.

But one big question looms as lawmakers and the governor consider how to spend the government’s new found riches: what will happen when the music stops?

Californians have seen this movie before. The economy grows, revenues rise and the folks in Sacramento commit the money to new programs, expansions or tax cuts. Then the economy slows, revenue growth slows or even declines, and deficits emerge.

This time around, the risk of a crash in state finances during the next economic downturn is greater than ever. Why? Because the state is more dependent than ever on the personal income tax, which is a highly volatile revenue source. At last count, two-thirds of the revenue coming into the state’s general fund is generated by the personal income tax, up from 60 percent a decade ago.

The biggest reason for that growth is that California’s income tax rates are fairly progressive, meaning people with higher incomes pay a significant amount of the tax. And California, for all its problems, has a lot of higher-income people. They pay a lot of tax.

On top of that, the voters in 2012 passed a temporary tax increase pushed by Brown to help balance the budget and preserve funding for the schools, and that tax hike hit the wealthy even harder.

Thanks largely to this surge, the Legislative Analyst now projects that annual state revenues will climb from about $102 billion now to $129 billion in 2019-20, an increase of nearly 30 percent over six years. At the same time, under current law, state spending would grow from $99.6 billion to $119 billion.

In a report issued last month, the analyst cautioned lawmakers to not commit too much of the new money to ongoing programs, since the revenue projections are uncertain at best and at some point, we know, the growth will pause or even reverse itself.

As an alternative, the report suggests lawmakers do something that California has not done in a long time: build a rainy day reserve. The analyst advises that a fund in the neighborhood of $8 billion, built over several years, would be big enough to cushion the state against the inevitable downturn to come.

But that’s not all. The analyst also suggested that lawmakers pay down the remainder of a “wall of debt” leftover from the last cycle of deficits, and begin catching up on billions of unfunded obligations for pensions and health benefits promised to retired public employees. The magic in that strategy is that the spending, rather than creating new commitments, would relieve the state of existing ones.

Finally, like a parent handing out treats to the children, the analyst says lawmakers should satisfy their urge to spend more by giving inflation adjustments to programs that have gone without them and then setting aside $500 million for new and expanded programs, growing that amount by $500 million a year.

That idea flips the normal legislative impulse on its head. Instead of approving new priorities and then finding the money to finance them, lawmakers would create a limited pot of money and then approve only as much new spending as would fit within that limit.

It remains to be seen whether California lawmakers can ever exhibit that kind of discipline. The first test will come next spring, when, for the first time in more than a decade, legislators will be arguing over how to spend a surplus instead of figuring out how to make ends meet.

Daniel Weintraub has covered California public policy for 25 years. He is editor of the California Health Report.

Cross-posted at HealthyCal.